The hypergeometric distribution counts successes when you draw a sample without putting items back. Picture a box of N items, K of which are “successes” – defective parts, red cards, winning numbers, dark chocolate bars. You draw n items at random. How likely is it that exactly k of them are successes?
Because each draw changes what is left in the box, the trials are not independent and the binomial distribution does not quite apply. The hypergeometric formula counts the ways to choose k successes from K and n − k failures from N − K, and divides by all the ways to choose n items from N. That makes it exact for card games, lotteries, acceptance sampling in quality control, capture–recapture studies in ecology and Fisher’s exact test.
The calculator gives the exact and cumulative probabilities, highlights them on the distribution chart, shows the possible range of k, and compares the result with the binomial approximation that would apply if you sampled with replacement. When the population is large compared with the sample, the two agree closely.
How to use the Hypergeometric Distribution Calculator
- Population size (N)
- Number of successes in the population (K)
- Sample size (n)
- Number of successes in the sample (k)
- What to compute?
Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.
How it works
P(X = k) is computed from binomial coefficients (via log-gamma, so large populations work); cumulative probabilities add these terms over the possible values of k, from max(0, n + K − N) to min(n, K).
Worked example
A box holds 48 chocolate bars, 12 dark and 36 white. You take 10 at random. The probability of exactly 4 dark bars is C(12, 4) × C(36, 6) / C(48, 10) = 495 × 1,947,792 / 6,540,715,896 = 14.74%. The probability of at least 4 is 20.23%. On average you get 10 × 12/48 = 2.5 dark bars with variance 1.516. Sampling with replacement (binomial, p = 0.25) would give 14.60% for exactly 4.
Hypergeometric versus binomial
| Hypergeometric | Binomial | |
|---|---|---|
| Sampling | Without replacement | With replacement / independent trials |
| Success probability | Changes after each draw | Constant p |
| Mean | n·K/N | n·p |
| Variance | n·p(1 − p)(N − n)/(N − 1) | n·p(1 − p) |
Formula
P(X = k) = C(K, k) × C(N − K, n − k) ÷ C(N, n) · mean = n·K/N · variance = n·(K/N)·(1 − K/N)·(N − n)/(N − 1)
Worked example
Inputs — Population size (N): 48; Number of successes in the population (K): 12; Sample size (n): 10; Number of successes in the sample (k): 4; What to compute?: Exactly k – P(X = k).
Results — Requested probability = 14.7408 %; P(X = k) = 14.7408 %; P(X ≤ k) = 94.5116 %; P(X ≥ k) = 20.2292 %; P(X < k) = 79.7708 %; P(X > k) = 5.4884 %.
Key terms
- Without replacement
- Each drawn item is not returned, so the population changes after every draw.
- Population successes (K)
- The number of items in the population that have the property of interest.
- Finite population correction
- The factor (N − n)/(N − 1) that makes the variance smaller than the binomial one.
- Binomial coefficient C(n, k)
- The number of ways to choose k items from n.
Frequently asked questions
When should I use the hypergeometric instead of the binomial distribution?
When you sample without replacement from a finite population, so each draw changes the odds. If the sample is under about 5% of the population the binomial is a fine approximation.
What is the chance of matching exactly 3 numbers in a 6/49 lottery?
C(6, 3) × C(43, 3) / C(49, 6) = 1.765%; at least 3 matches is 1.864%.
What is the probability of exactly 2 aces in a 5-card poker hand?
C(4, 2) × C(48, 3) / C(52, 5) = 3.99%; no ace at all is 65.88%.
What are the mean and variance?
Mean n·K/N and variance n·(K/N)(1 − K/N)(N − n)/(N − 1). The last factor is the finite population correction.
What values can k take?
From max(0, n + K − N) to min(n, K). Outside that range the probability is 0.
Where is it used in quality control?
Acceptance sampling: draw n items from a lot of N and accept the lot if the number of defectives is at most a limit.