Tech Tips: Hypergeometric Distributions

Calculating Hypergeometric Probabilities

To find the hypergeometric probability of seeing exactly $x$ white balls when drawing $k$ balls from an urn containing $m$ white balls and $n$ black balls, or equivalently $$P(x) = \frac{{}_m C_x \cdot {}_n C_{k-x}}{{}_{m+n} C_k}$$


Calculating Cumulative Hypergeometric Probabilities

Suppose one wishes to find the cumulative hypergeometric probability of seeing $x$ or fewer white balls when drawing $k$ balls from an urn containing $m$ white balls and $n$ black balls, or equivalently $$P(X <= x) = P(0) + P(1) + P(2) + \cdots + P(x) = \sum_{0 \le i \le x} \frac{{}_m C_i \cdot {}_n C_{k-i}}{{}_{m+n} C_k}$$


Simulating Random Variables following a Hypergeometric Distributions

To simulate numbers randomly chosen from a hypergeometric distribution, such as the count of white balls seen when drawing $k$ balls without replacement from an urn containing $m$ white balls and $n$ black balls ...