 Syntactic Confectionery Delight PerlMonks

### Re^2: Fastest way to calculate hypergeometric distribution probabilities (i.e. BIG factorials)?

 on Apr 05, 2010 at 21:15 UTC ( #832923=note: print w/replies, xml ) Need Help??

I could be mistaken but I think this calculates the probability of i successful selections, not i or more successful selections as claimed above. For the cdf, prob of i or more successes, you need to do the following:
```my \$hypercdf = 0;
for (my \$iref=\$i; \$iref < min(\$N,\$n); \$iref++)
{
\$hypercdf += hypergeom(\$n,\$m,\$N,\$iref);
}
print \$hypercdf;
• Comment on Re^2: Fastest way to calculate hypergeometric distribution probabilities (i.e. BIG factorials)?

Replies are listed 'Best First'.
Re^3: Fastest way to calculate hypergeometric distribution probabilities (i.e. BIG factorials)?
by Alokito (Novice) on Jun 06, 2011 at 11:30 UTC
You may need a less than or equal to in the condition of the for loop. This probably won't make a difference in most cases, as the final probability is usually very small.
```my \$hypercdf = 0;
for (my \$iref=\$i; \$iref <= min(\$N,\$n); \$iref++)
{
\$hypercdf += hypergeom(\$n,\$m,\$N,\$iref);
}
print \$hypercdf;

Create A New User
Node Status?
node history
Node Type: note [id://832923]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2021-05-10 22:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Perl 7 will be out ...

Results (108 votes). Check out past polls.

Notices?