Re: Estimating the mean of the cumulative hypergeometric?



On Jan 13, 3:43 pm, petertwocakes <petertwoca...@xxxxxxxxxxxxxx>
wrote:
This is my routine for calculating the cumulative _Binomial_
distribution, with relacement, given n and p:

double q = 1-p,  c = pow(q,n); // i.e. when k=0
double cp = c; // cumulative probability
for(double k=1; k<=n; k++)
{
    c = ((n-(k-1))/k)*c*(p/q);
    cp += c;

}

It's fast, and (for me) clear to understand, and as it's iterative,
the cost of calculating the cumulative probability is little more than
for calculating a specific probability.
So... I REALLY thought I would be able to modify this to work with no-
replacement, after all the only difference is that p&q are changing as
a result of N and m being reduced.
(m = number successes in N; k = number successes in sample(n))
Surely, in the loop above, if I could recalculate p&q by how N and m
are changing, then this would give the same result as the
hypergeometric??

I don't see that this is an efficient way to approach it. p and q are
changing, sure, but they're changing in a way that depends on the
history of the previous selections, and you don't want to be tracking
all those possibilities individually.

Your loop code for the hypergeometric should not be that different
from the binomial. You keep a running count of the product of the
binomial coefficients involving k: this is what I was alluding to
earlier. Each iteration involves multiplying by two ratios, something
like c = c*(m - k)/(k + 1)*(n - k)/(N - m - n + k + 1), depending on
exactly how you implement it. Of course, you can pre-calculate N - m -
n + 1. You do also have the overhead of initialising this multiplier
to (N - m)C(n) and calculating the denominator Ncn.
.



Relevant Pages

  • Re: formula calculation
    ... references, so it is difficult to debug/validate the model unless you take ... What is the problem with Iteration? ... year in which we assume we will pay the majority of the tax. ... 'unwind' the circular calculation by calculating interest on cash ...
    (microsoft.public.excel.misc)
  • Re: comare tow int
    ... overriding. ... will be a polynomial approximation. ... level of accuracy is just a matter repeating the iteration long ... The main exception is the method that basically involves calculating ...
    (comp.lang.c)
  • Re: Straight Line is not straight
    ... XL is calculating by rows, so B1:B4 are calculated using the value in G4 ... XL to recalculate all its dependents. ... iteration set to 1, that recalculation doesn't occur. ...
    (microsoft.public.excel.misc)
  • Re: a question about ode45
    ... If I disregard the constraint, ... during the iteration, when calculating ...
    (comp.soft-sys.matlab)
  • Re: Biquad Peaking Filter
    ... When calculating the Q of the peaking filter, I was multiplying by the ... gain so that a negative gain of the same magnitude as a positive boost ...
    (comp.dsp)

Loading