Hypergeometric Distribution Calculator
The hypergeometric distribution models how many 'successes' appear in a sample drawn without replacement from a finite population. If a population of N units contains K units of interest and n units are drawn from it, the number of successes X in the sample follows a hypergeometric distribution. Drawing balls from an urn, taking a sample from a production lot for inspection, dealing cards from a deck, and pre-election polling all fit this model.
Its only difference from the binomial distribution is the independence assumption: because the population shrinks with every draw, the success probability changes and the trials are not independent. This calculator returns P(X = k), P(X ≤ k), P(X ≥ k), and the probability of any range [a, b] you choose; it reports the mean nK/N, the variance with the finite population correction, the standard deviation, and the mode; and it shows how closely the binomial approximation matches the same scenario.
Hypergeometric Distribution Formulas
Mass function: P(X = k) = [C(K, k) · C(N − K, n − k)] / C(N, n) Support: max(0, n + K − N) ≤ k ≤ min(n, K) Cumulative: P(X ≤ k) = Σᵢ P(X = i) Upper tail: P(X ≥ k) = 1 − P(X ≤ k − 1) Mean: μ = n · K / N Variance: σ² = n · (K/N) · (1 − K/N) · (N − n) / (N − 1) Finite pop. corr.: (N − n) / (N − 1) Mode: ⌊(n + 1)(K + 1) / (N + 2)⌋ Binomial approx.: X ≈ Binomial(n, K/N) when n / N ≤ 0.05
The cumulative function of the hypergeometric distribution has no closed form; because the support is finite, the probabilities are summed from the nearer tail. For large values of N the combinations are evaluated in log space to prevent overflow.
How to Calculate
- Enter the population size (N): the total number of units the draw is made from.
- Enter the number of successes in the population (K): how many units carry the property you care about.
- Type in the sample size drawn without replacement (n) and the number of successes (k) whose probability you want.
- Optionally set the range bounds (a and b); the calculator also returns P(a ≤ X ≤ b).
- Read the mean, the variance with the finite population correction, and the mode alongside the exact and cumulative probabilities.
- Check the sampling fraction (n/N): below 5% the binomial approximation may also be used, and the last column of the table compares the two values.
Worked Examples
10 units sampled from 50: finding 3 defectives
In a lot of 50 products containing 12 defectives, the probability that a sample of 10 contains exactly 3 defectives is P(X = 3) = 0.2703. The probability of at most 3 defectives is 0.8209 and of at least 3 defectives 0.4493. P(2 ≤ X ≤ 5) = 0.7562; the mean is 2.4 defectives and the standard deviation with the finite population correction is 1.2202. Because the sampling fraction is 20%, the binomial approximation is not appropriate.
Exactly 3 successes — P(X = 3): 0.2703 · At most 3 successes — P(X ≤ 3): 0.8209 · Fewer than 3 — P(X < 3): 0.5507
Cards: 2 hearts in a 5-card hand
The probability that a 5-card hand dealt from a 52-card deck contains exactly 2 hearts is P(X = 2) = 0.2743. The probability of at most 2 hearts is 0.9072, and the probability of getting between 1 and 3 hearts is P(1 ≤ X ≤ 3) = 0.7672. The expected number of hearts is 1.25 with a standard deviation of 0.9295. Because the sampling fraction is 9.62%, the binomial approximation (0.2637) drifts away from the exact value.
Exactly 2 successes — P(X = 2): 0.2743 · At most 2 successes — P(X ≤ 2): 0.9072 · Fewer than 2 — P(X < 2): 0.6330
Large population: where the binomial approximation holds
In a population of 10,000 units containing 500 successes, the probability of exactly 5 successes in a sample of 100 is P(X = 5) = 0.1809; the binomial approximation of the same probability is 0.1800, an absolute difference of only 0.0009. Since the sampling fraction is n/N = 1% ≤ 5%, the approximation can be used safely. The mean is 5 successes, the standard deviation 2.1686, and P(3 ≤ X ≤ 7) = 0.7561.
Exactly 5 successes — P(X = 5): 0.1809 · At most 5 successes — P(X ≤ 5): 0.6160 · Fewer than 5 — P(X < 5): 0.4351