Hypergeometric Distribution
Probability Distributions
Sampling Without Replacement — Finite Populations
The hypergeometric distribution models the number of successes when sampling without replacement from a finite population. Every draw changes the odds.
- Card games — probability of drawing aces in a poker hand
- Quality inspection — defective items in a batch sample
- Ecology — capture-recapture population estimation
- Legal sampling — random drug testing from a workforce
Unlike the binomial, the hypergeometric accounts for the fact that each draw depletes the population.
Core Concepts
The hypergeometric distribution models the number of successes when sampling without replacement from a finite population. It is the correct distribution for card games, quality inspection of small batches, and any scenario where the population is depleted as items are drawn.
DfHypergeometric Distribution
A random variable follows a hypergeometric distribution with parameters , written , if its PMF is:
where is the population size, is the number of successes in the population, is the sample size, and satisfies .
Why This PMF Is Correct
The total number of ways to choose items from is . The number of ways to choose exactly successes from available and failures from available is . The ratio gives the probability, since each subset of size is equally likely.
Mean and Variance
Hypergeometric Mean and Variance
Here,
- =Population size
- =Successes in population
- =Sample size
- =Finite population correction factor
Derivation of the Mean
Let be the indicator that the -th draw is a success. By linearity of expectation:
since by symmetry each draw has probability of being a success, regardless of the order. (Note: this holds even though the are not independent.)
Derivation of the Variance
Using :
-
For : (negative because drawing a success on draw makes a success on draw slightly less likely without replacement).
Therefore:
The Finite Population Correction Factor
ThFinite Population Correction
The ratio of hypergeometric to binomial variance is:
This factor is always less than 1 for , meaning sampling without replacement produces less variability than sampling with replacement.
Why Without Replacement Has Lower Variance
When you sample without replacement and observe a success, the remaining population has one fewer success, making the next draw slightly less likely to succeed. This negative correlation between draws reduces the overall variability of the count. The effect is negligible when .
Convergence to Binomial
ThBinomial Approximation
As with and fixed, the hypergeometric distribution converges to the binomial:
Proof Sketch
For fixed and :
As with , each factor and , yielding .
Symmetry Property
ThHypergeometric Symmetry
The hypergeometric distribution is symmetric under the transformation when :
More generally, has the same distribution as where : counting successes is equivalent to counting failures.
Worked Example: Lottery / Card Draw
Example: Drawing Aces from a Deck
A standard deck has cards, aces. We draw cards without replacement. Let = number of aces drawn.
PMF:
Compute each value:
Mean: .
Variance: .
Compare with binomial approximation: gives .
The finite population correction factor reduces the variance by about .
Python Implementation
import numpy as np
from scipy import stats
np.random.seed(42)
# Hypergeometric parameters
N, K, n = 52, 4, 5 # deck, aces, draws
# Theoretical mean and variance
mean_theory = n * K / N
var_theory = n * (K/N) * (1 - K/N) * (N - n) / (N - 1)
print(f"Hyp({N}, {K}, {n}):")
print(f" Theoretical mean: {mean_theory:.4f}")
print(f" Theoretical variance: {var_theory:.4f}")
# Simulate
n_sims = 100000
samples = np.random.hypergeometric(K, N - K, n, size=n_sims)
print(f" Empirical mean: {np.mean(samples):.4f}")
print(f" Empirical variance: {np.var(samples, ddof=0):.4f}")
# Compare with binomial (with replacement)
binom_var = n * (K/N) * (1 - K/N)
fpc = (N - n) / (N - 1)
print(f"\n Binomial variance (with replacement): {binom_var:.4f}")
print(f" Finite population correction: {fpc:.4f}")
print(f" Hyp var / Bin var = {var_theory / binom_var:.4f} (should be {fpc:.4f})")
Python Implementation: Batch Quality Inspection
import numpy as np
from scipy import stats
np.random.seed(42)
# Quality control: batch of 100 items, 8 defective, sample 10
N, K, n = 100, 8, 10
samples = np.random.hypergeometric(K, N - K, n, size=50000)
print(f"Quality Inspection: N={N}, K={K} defective, sample n={n}")
print(f"PMF values:")
for k in range(min(n, K) + 1):
pmf = stats.hypergeom.pmf(k, N, K, n)
print(f" P(X={k}) = {pmf:.4f}")
print(f"\nSimulated mean: {np.mean(samples):.4f} (theoretical: {n*K/N:.4f})")
# Probability of finding at least 2 defectives
prob_ge_2 = 1 - stats.hypergeom.cdf(1, N, K, n)
print(f"P(X >= 2 defectives in sample) = {prob_ge_2:.4f}")
Key Takeaways
Summary: Hypergeometric Distribution
- Models sampling without replacement from a finite population of size with successes
- PMF:
- Mean: (same as binomial — expectation doesn't need independence)
- Variance: — includes finite population correction
- Negative covariance between draws:
- Converges to Binomial as with fixed
- Variance is always less than the binomial counterpart (less variability without replacement)