Hypergeometric Distribution
Count marked items in finite samples without replacement, explore exact event probabilities, and compare the variance with a replacement model.
By Riano · Published · Report a correction
Hypergeometric Distribution
Concept Overview
Take a fixed-size random sample from a finite collection containing marked and unmarked items. If items are not returned, draws depend on one another. The hypergeometric distribution describes the number of marked items selected. Here “marked” names a category, not a desirable outcome: it could mean defective parts, tagged animals or red cards.
Mathematical Definition
Let N be the population size, K the number marked and n the sample size. Every subset of n distinct items has the same chance of selection. X counts marked items in the subset; C(a, b) denotes a binomial coefficient.
Choose k of the K marked items, then n − k of the N − K unmarked items. Their product counts favorable subsets. Divide by all C(N, n) subsets. Integer counts outside the feasible interval have probability zero. The upper-tail event includes equality, so P(X ≥ x) equals 1 − F(x − 1), rather than 1 − F(x).
Key Concepts
Same mean, different dependence
Each draw has marginal marked probability p = K/N. After observing a marked item, the next conditional probability becomes (K − 1)/(N − 1). Let Ii indicate whether draw i is marked. For N > 1, distinct indicators have covariance −p(1 − p)/(N − 1). Adding their means and covariances gives:
For N > 1 and 1 ≤ n ≤ N the finite population correction (N − n)/(N − 1) lies between zero and one. A census (n = N) removes uncertainty. With fixed n and K/N approaching p as N grows, the hypergeometric distribution approaches the binomial distribution. The module overlays this replacement model; it does not treat it as an exact substitute.
A counted example
For N = 10, K = 4 and n = 3 there are C(10, 3) = 120 subsets. Exactly one marked item occurs in 4 × C(6, 2) = 60 subsets, so its probability is 1/2. Zero marked items occurs in C(6, 3) = 20 subsets. Thus P(X ≤ 1) = 80/120 = 2/3 and P(X ≥ 1) = 100/120 = 5/6. The mean is 1.2 and the variance is 3(0.4)(0.6)(7/9) = 0.56.
Boundary cases and scope
An empty sample has X = 0. If K = 0 or K = N, every sample count is fixed. A one-item population also has variance zero; the displayed formula must not be evaluated as 0/0. The explorer supports integer N from 1 to 100, K and n from 0 to N, and query x from −100 to 100. Blank, fractional and incompatible inputs are rejected. Numerical probabilities are displayed to six decimal places; a very small positive probability may round to zero. Selection must be uniform without replacement; biased selection requires a different model.
Historical Context
The name reflects a connection with hypergeometric series: the ratio of neighboring nonzero probability masses is a rational function of the count. The finite-sampling interpretation offers a direct way to understand the distribution through counting.
Real-world Applications
- Batch inspection: Calculate the chance that a random sample contains a specified number of defective items when the batch composition is known.
- Card hands: Count cards of a chosen suit in a hand dealt from a fixed deck.
- Tagged populations: Model how many previously tagged animals appear in a uniformly selected recapture sample, under the required sampling assumptions.
Related Concepts
- Conditional Probability Tree — changing conditional probabilities explain dependence between draws.
- Negative Binomial Distribution — independent trials continue until a target count, rather than a fixed sample without replacement.
- Bootstrapping — resampling with replacement permits repeated selection of the same item.
References
- Kyle Siegrist, Random: The Hypergeometric Distribution — derivation, moments and replacement comparison.
- SciPy documentation: hypergeom — PMF and feasible support. Its parameter letters differ from this explorer.
Experience it interactively
Adjust parameters, observe in real time, and build deep intuition with Riano’s interactive Hypergeometric Distribution module.
Try Hypergeometric Distribution on Riano →