The Hypergeometric Distribution, Explained
After reading this you can compute the chance of drawing a given number of successes from a finite pool without replacement, and you will know when to use the hypergeometric model instead of the binomial.
What it is, with one card example
Deal 5 cards from a standard deck of 52. The deck holds 4 aces. What is the probability that your hand contains exactly 1 ace? That is a hypergeometric question. You draw a fixed number of items from a finite population, each item is either a success or a failure, and once you take an item it is gone. There is no replacement.
The distribution has four inputs: the population size N, the number of successes in that population K, the number of draws n, and the number of successes you want to see, k. For the card example N = 52, K = 4, n = 5, and k = 1. The answer works out to about 0.2995, which you can verify below.
The key feature is dependence between draws. After you pull one ace, only 3 aces remain among 51 cards, so the odds shift. That is what separates this from a coin-flip model.
When to use it and when not to
Use the hypergeometric distribution when three things hold: the population is finite and of known size, each item is a clear success or failure, and you sample without replacement.
- Quality control
- A crate holds 200 parts, 12 of them defective. You inspect 20 without putting any back. The count of defectives you find is hypergeometric.
- Card and lottery problems
- Any "deal a hand" or "draw numbers" setup fits, because drawn items are not returned.
- Audit sampling
- Pull 30 invoices from a batch of 500 that contains 40 with errors.
Do not use it when you replace each item before the next draw, or when the population is effectively infinite. In those cases the draws are independent and the Binomial calculator is the right tool. As a rule of thumb, when n is less than about 5 percent of N, the binomial approximation is close enough that the difference rarely matters.
The formula and why it looks that way
Read this as counting favorable arrangements over total arrangements. The denominator \binom{N}{n} is the number of ways to choose any n items from the full population, treating all choices as equally likely. In the numerator, \binom{K}{k} counts the ways to pick k of your successes, and \binom{N-K}{n-k} counts the ways to fill the rest of the sample with failures drawn from the N-K non-successes. Multiply them because each choice of successes can pair with each choice of failures.
The symbol \binom{a}{b} is a binomial coefficient, the number of ways to choose b items from a without regard to order. For example \binom{4}{1} = 4 and \binom{52}{5} = 2{,}598{,}960.
The count k is only possible when it fits both the successes and the sample. Formally \max(0,\, n-(N-K)) \le k \le \min(n, K). Outside that range the probability is exactly 0.
A worked example that reproduces the demo
Exactly one ace in a 5-card hand
Use the defaults: N = 52, K = 4, n = 5, k = 1.
- Count ways to choose 1 ace from 4: \binom{4}{1} = 4.
- Count ways to choose the other 4 cards from the 48 non-aces: \binom{48}{4} = 194{,}580.
- Multiply for the favorable hands: 4 \times 194{,}580 = 778{,}320.
- Count all 5-card hands: \binom{52}{5} = 2{,}598{,}960.
- Divide: 778{,}320 / 2{,}598{,}960 \approx 0.2995.
So about 30 percent of random 5-card hands hold exactly one ace. Press Calculate with the defaults to see the same 0.2995.
The full distribution for the demo
The number of aces in a 5-card hand can be 0, 1, 2, 3, or 4. Computing the probability for each value gives the complete picture.
| k aces | P(X = k) |
|---|---|
| 0 | 0.6588 |
| 1 | 0.2995 |
| 2 | 0.03993 |
| 3 | 0.001736 |
| 4 | 0.00001847 |
The five probabilities sum to 1. Notice how fast the tail falls: getting all 4 aces in one hand happens roughly once in 54,000 deals.
Reading and interpreting the output
The calculator reports the point probability P(X = k) and usually the cumulative values as well. Match the quantity to your question:
- Exactly k: use P(X = k) directly. For the demo,
0.2995. - At most k: add the probabilities from 0 up to k. For at most 1 ace, 0.6588 + 0.2995 = 0.9583.
- At least k: use 1 - P(X \le k-1). For at least 1 ace, 1 - 0.6588 = 0.3412.
Two summary numbers help you sanity-check a result. The mean is E[X] = n\frac{K}{N}, which for the demo is 5 \times 4/52 \approx 0.3846 aces per hand. The variance is
Every term except the last matches the binomial variance. The last factor \frac{N-n}{N-1} is the finite population correction. It is always less than or equal to 1, so drawing without replacement always produces a variance no larger than the binomial case. For the demo it equals 47/51 \approx 0.9216, shrinking the variance by about 8 percent.
Common mistakes
The single most frequent error is swapping K and n. Here K is how many successes exist in the whole population, and n is how many items you draw. In the deck example K = 4 aces and n = 5 cards. Getting these backwards changes the answer completely.
Two more traps to avoid:
- Impossible counts. If you ask for
k = 5successes when onlyK = 4exist, the true probability is 0. A correct calculator returns 0, not an error. - Using it with replacement. If items are returned between draws, the trials are independent and you want the binomial model instead. The hypergeometric answer will be slightly off, understating the tails.
Related calculators
When your draws are independent (sampling with replacement, or a very large population), reach for the Binomial calculator. If you are counting rare events over time or space rather than a fixed sample, the Poisson calculator fits. When a large-sample count behaves like a bell curve, the Normal calculator gives a quick approximation. For "how many trials until the first success" questions, see the Geometric calculator, and for "how many failures before the r-th success" see the Negative Binomial calculator.
Frequently asked questions
What is the difference between hypergeometric and binomial?
Both count successes in a fixed number of draws. The binomial assumes each draw is independent with a constant success probability, which happens when you replace items or the population is huge. The hypergeometric assumes no replacement, so each draw changes the odds. For the deck example the hypergeometric gives 0.2995 for one ace; the binomial with p = 4/52 gives 0.2995 as well to four figures here, but the two diverge as the sample grows relative to the population.
When can I approximate it with the binomial?
When your sample is a small fraction of the population, roughly n under 5 percent of N. The finite population correction \frac{N-n}{N-1} is then close to 1, so the shapes almost coincide.
Can the number of successes drawn exceed the number available?
No. You cannot draw more aces than exist, so k \le \min(n, K). There is also a lower bound: if the sample is larger than the failure pool, some successes are forced, giving k \ge n - (N-K). Outside that window the probability is 0.
What is the mean and standard deviation for the demo?
The mean number of aces is 5 \times 4/52 \approx 0.3846. The variance is 0.3417, so the standard deviation is about 0.5846 aces.
Does draw order matter?
No. The hypergeometric probability treats the sample as an unordered set. Whether the ace comes first or last, the hand is the same, and the formula counts combinations, not sequences.