Hypergeometric Distribution Calculator
Exact probabilities for sampling without replacement: drawing cards from a deck, inspecting units from a small batch, or matching lottery numbers. Enter the population, the successes it contains and your sample to get exactly, at most, at least and between probabilities, with a chart and a table.
How many you draw without replacement
Related Calculators
Binomial Distribution Calculator
Exact, at-most, at-least and range probabilities for the number of successes in n independent trials, with the mean, variance, a bar chart and a table.
Combination Calculator (nCr)
Count combinations exactly with big-integer nCr results, even for very large n.
Dice Probability Calculator
Find exact odds of rolling a dice sum exactly, at least, or at most a target value.
Learn More
Binomial vs Poisson vs Hypergeometric
Three questions decide the right counting distribution (fixed trials, independence, replacement) with one inspection scenario computed all three ways.
Probability Distributions
Compare the binomial, Poisson, normal, uniform, and exponential distributions and learn how to choose the right model for counts, measurements, and waiting times.
Before you calculate
- N is the whole population (52 cards, 50 units in the batch) and K is how many of them count as successes (4 aces, 5 defective units).
- n is how many you draw, and k is how many successes you ask about.
- Use this instead of the binomial distribution whenever each draw changes the remaining pool: that is what “without replacement” means.
- For lottery games, the lottery odds calculator applies this distribution to the main draw and adds the bonus draw, the odds of every prize level and the chance with many tickets.
The hypergeometric formula
P(X = k) = C(K, k) × C(N − K, n − k) / C(N, n)
Mean = nK/N Variance = n × (K/N) × (1 − K/N) × (N − n)/(N − 1)
Possible values: k from max(0, n − (N − K)) to min(n, K)
The numerator counts the samples that contain exactly k of the K successes (and therefore n − k of the N − K non-successes); the denominator counts all possible samples of size n. Every draw is a plain count of equally likely hands, so the result is exact. The combination calculator computes the individual C(a, b) terms if you want to verify by hand. You cannot draw more successes than exist (k ≤ K) or than you draw (k ≤ n), and if the sample is larger than the number of non-successes some successes are forced in. For a k outside that range the calculator shows a probability of exactly 0 and lists the values that are possible. With very large populations (up to 1,000,000,000) the terms are evaluated with the saddle-point method used by R's dhyper rather than as huge factorials.
Hypergeometric vs binomial: the correction factor
The mean is the same as the binomial's (np with p = K/N), but the variance carries the extra factor (N − n)/(N − 1), the finite population correction. It is less than 1 whenever you sample more than one item: each success drawn depletes the pool, pulling later draws toward fewer successes and shrinking the spread compared with independent draws.
When the sample is a small fraction of the population (a common working rule is n/N ≤ 0.05) the correction is nearly 1 and the binomial with p = K/N is an excellent approximation. Sampling 10 units from a batch of 10,000 barely dents the pool; sampling 10 from 50 dents it badly, and the exact hypergeometric answer is then meaningfully different.
Worked example: acceptance sampling
A batch of N = 50 units contains K = 5 defective ones. An inspector draws n = 10 units without replacement. What are the chances of finding defects?
- No defects: P(X = 0) = C(45, 10)/C(50, 10) ≈ 0.310563.
- Exactly one: P(X = 1) = C(5, 1) × C(45, 9)/C(50, 10) ≈ 0.431337.
- At least one: 1 − 0.310563 ≈ 0.689437: the batch fails a zero-tolerance inspection about 69% of the time.
The summary reads mean = 10 × 5/50 = 1 defect per sample and variance 10 × 0.1 × 0.9 × 40/49 ≈ 0.7347 (SD ≈ 0.8571). Compare the binomial approximation with p = 0.1: it gives P(X = 0) = 0.910 ≈ 0.3487, about 12% too high, because drawing 10 from 50 is a 20% bite of the population. Load example reproduces these numbers.
Cards work the same way. In a five-card hand from a 52-card deck (N = 52, K = 4, n = 5) the chance of exactly two aces is 0.03993, and the chance of at least one ace is 0.341158.
Lottery odds as a hypergeometric probability
Matching lottery numbers is sampling without replacement: the draw picks 6 balls from 49 and your ticket marks 6 of them as successes (N = 49, K = 6, n = 6). The chance of matching exactly 3 is 0.01765, about 1.77%, and the chance of at least 3 matches is 0.018638, about 1 in 54. The jackpot, P(X = 6), is 1/C(49, 6) = one in 13,983,816.
Excel, R and Python
| Software | P(X = k) | P(X ≤ k) |
|---|---|---|
| Excel | HYPGEOM.DIST(k, n, K, N, FALSE) | HYPGEOM.DIST(k, n, K, N, TRUE) |
| R | dhyper(k, K, N - K, n) | phyper(k, K, N - K, n) |
| Python (SciPy) | scipy.stats.hypergeom.pmf(k, N, K, n) | scipy.stats.hypergeom.cdf(k, N, K, n) |
The argument order differs between programs, so match the letters above with care: R takes the number of failures in the population (N − K) as its third argument, and SciPy takes the population size first.
Related guides and calculators
The combination calculator counts the samples behind the formula, and the dice probability calculator covers draws with replacement. To compare two groups on the same kind of table, the Fisher exact test is a hypergeometric test. Read binomial vs Poisson vs hypergeometric to choose the right model.
Frequently Asked Questions
When should I use the hypergeometric distribution instead of the binomial?
Use the hypergeometric whenever draws are made without replacement from a finite population, so each draw changes the composition of what remains: card hands, lottery matches, or inspecting a small batch. The binomial assumes every trial has the same success probability, which only holds with replacement or when the sample is a tiny fraction of the population (roughly n/N <= 5%).
What do the four inputs N, K, n, and k mean?
N is the total population size, K is how many members of that population are 'successes', n is how many you draw, and k is the number of successes in the draw you are asking about. For the chance of two aces in a five-card hand: N = 52, K = 4, n = 5, k = 2, giving about 0.0399.
What is the finite population correction?
It is the factor (N - n)/(N - 1) that multiplies the binomial variance. It reflects that sampling without replacement depletes the pool, making the count of successes less variable than independent draws would be. The correction approaches 1 when the population dwarfs the sample and reaches zero when you sample everything: at n = N the count is exactly K with no variability at all.
How do lottery odds come from this distribution?
Matching lottery numbers is sampling without replacement: the draw picks n balls from N, and your ticket marks K = n of them as 'successes'. In a 6-of-49 lottery, the chance of matching exactly 3 is [C(6,3) x C(43,3)]/C(49,6), about 1.77%, and the jackpot P(X = 6) is 1/C(49,6), one in 13,983,816. All of them are direct hypergeometric probabilities.
Why is the probability 0 for my k?
The possible values are limited by counting logic: you cannot draw more successes than exist in the population (k <= K) or than you draw (k <= n), and if the sample is bigger than the number of non-successes, some successes are forced in (k >= n - (N - K)). For a k outside that range the probability is exactly 0, and the calculator says which values are possible instead of leaving you to guess.
Are the results exact or approximated?
Exact in the sense of the definition: each probability is a ratio of combination counts evaluated with a numerically stable method, not a normal or binomial approximation, and cumulative values are sums of those terms. The results have been checked against high-precision arithmetic to about ten significant digits for populations up to 1,000,000,000. That matters most in the tails and for small populations, where approximations can be off by several percentage points; the worked example shows a 12% relative error in the binomial's P(X = 0).
Embed This Calculator
Add this free calculator to your course page or LMS.
Adjust the height value to fit your page.