Hypergeometric distribution calculator
Enter the population size N, the number of successes K in it, the number of draws n and the count k you are interested in. You get the exact probability, the cumulative and tail probabilities, the mean and standard deviation, and a chart of the distribution.
Runs in your browser: nothing you enter is sent anywhere.
How to use it
- Enter N, K, n and k.
- Read P(X = k) first, then the cumulative and tail probabilities.
- The chart shows the whole distribution with k highlighted.
How it works
The possible counts run from max(0, n − (N − K)) to min(n, K). The calculator starts from the lowest count and uses the ratio between neighbours, P(k + 1) / P(k) = (K − k)(n − k) / ((k + 1)(N − K − n + k + 1)), in logarithms so that large populations do not overflow, then scales the values to add up to 1.
Worked example
An urn holds 10 balls, 5 of them red. Draw 3 without looking: P(exactly 2 red) = C(5, 2) · C(5, 1) / C(10, 3) = 10 · 5 / 120 = 0.4167, and P(at least 2 red) = (50 + 10) / 120 = 0.5.
Tips
- Card games, lottery matches, defect sampling and capture–recapture counts are all hypergeometric.
- A k outside the possible range has probability 0, which the tool shows rather than an error.
Frequently asked questions
What is the hypergeometric formula?
P(X = k) = C(K, k) · C(N − K, n − k) / C(N, n): the ways to pick k of the successes and n − k of the failures, divided by all ways to pick n items. For one ace in a five-card hand: C(4, 1) · C(48, 4) / C(52, 5) = 4 · 194580 / 2598960 ≈ 0.2995.
How is it different from the binomial distribution?
The binomial assumes each draw has the same chance, as when items are put back. Without replacement the chance changes after every draw, which the hypergeometric distribution accounts for. When the population is much larger than the sample, the two give almost the same numbers.
How do I get the chance of at least one?
Set k = 1 and read P(X ≥ 1). For at least one ace in five cards it is 1 − C(48, 5)/C(52, 5) ≈ 0.3412.
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, the finite population correction, makes the spread smaller than for the binomial.