Hypergeometric Distribution Calculator

StatisticsLast updated: August 22, 2026

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.

The total number of units being drawn from. For example, a lot of 50 products.
The number of units of interest inside the population. For example, how many defective products the lot contains.
The sample size drawn without replacement. It cannot exceed N.
The number of successes whose probability is to be computed.
The lower bound for P(a ≤ X ≤ b). If left empty, the smallest value of the support is used.
The upper bound for P(a ≤ X ≤ b). If left empty, the largest value of the support is used.

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

  1. Enter the population size (N): the total number of units the draw is made from.
  2. Enter the number of successes in the population (K): how many units carry the property you care about.
  3. Type in the sample size drawn without replacement (n) and the number of successes (k) whose probability you want.
  4. Optionally set the range bounds (a and b); the calculator also returns P(a ≤ X ≤ b).
  5. Read the mean, the variance with the finite population correction, and the mode alongside the exact and cumulative probabilities.
  6. 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

Frequently Asked Questions

What is the difference between the hypergeometric and binomial distributions?
The binomial distribution assumes sampling with replacement (or an infinite population): the success probability p is constant across trials and the trials are independent. In the hypergeometric distribution the drawn unit is not returned, the population shrinks, and the probability changes at every step. That dependence shrinks the variance; the difference is captured by the finite population correction (N − n)/(N − 1).
When can the binomial approximation be used?
The common criterion is a sampling fraction of n/N ≤ 0.05, that is, the sample should be at most one twentieth of the population. Under that condition drawing a few units does not appreciably change the success rate, and the binomial comes very close to the hypergeometric. As the fraction rises above 5%, the binomial distorts the true probabilities more and more.
Why do some values of k have probability zero?
The support of the hypergeometric distribution runs from max(0, n + K − N) to min(n, K). The sample cannot contain more successes than the population holds, so k > K is impossible; likewise, if the population does not hold enough failures, the lower bound rises above zero. Values outside that range are mathematically impossible, not a computational error.
How is it computed in Excel, SPSS, and R?
In Excel, =HYPGEOM.DIST(k, n, K, N, FALSE) returns the exact probability and the TRUE flag returns the cumulative one. In R use dhyper(k, K, N-K, n) and phyper(k, K, N-K, n), and in Python scipy.stats.hypergeom.pmf(k, N, K, n). SPSS has no direct function; the ratio of combinations is usually written with COMPUTE, or the value is obtained through Fisher's exact test.
How is it related to Fisher's exact test?
Fisher's exact test rests on the fact that, with the row and column totals of a 2x2 table held fixed, the cell counts follow a hypergeometric distribution. The p-value of the test is the sum of the hypergeometric probabilities of all tables at least as extreme as the observed one. That is why the hypergeometric distribution enters directly into categorical analysis with small samples.
Why is the mean the same as the binomial one while the variance differs?
In both distributions the expected number of successes is n·p; for the hypergeometric, p is replaced by K/N and the mean becomes n·K/N. The variance, however, is smaller when drawing without replacement, because the outcome becomes more determined as the population is used up. That reduction is measured by the factor (N − n)/(N − 1); when n = N the factor drops to 0 and the variance vanishes entirely.
Can this distribution be used for lotteries and games of chance?
Yes, most draw-based games are exactly hypergeometric. In a game where 6 numbers are drawn out of 49, for example, how many of the 6 numbers on your ticket will match is computed with N = 49, K = 6, and n = 6. The same model applies to hand probabilities in tombola, bingo, and card games.