Hypergeometric distribution calculator
Drawing without replacement? Get the probability of k successes.
What is the hypergeometric distribution?
The probability of getting k successes when you draw n items without replacement from a population of N that contains K successes: P = C(K, k) × C(N − K, n − k) ÷ C(N, n). OpenStax (Introductory Statistics 2e, section 4.5) lists the conditions: the items come from two groups, you are interested in one of them, you sample without replacement, and each pick depends on the previous ones.
Example: aces in a poker hand
The chance of exactly 2 aces in 5 cards from a 52-card deck is C(4, 2) × C(48, 3) ÷ C(52, 5) = 0.0399, about 4%.
Worked example: a committee of four
OpenStax picks a committee of 4 from 6 men and 5 women and asks for the number of men. Here N = 11, K = 6, n = 4. The chance of exactly 2 men is C(6, 2) × C(5, 2) ÷ C(11, 4) = 15 × 10 ÷ 330 = 0.4545, about 45%. The expected number of men is 4 × 6 ÷ 11 = 2.18, and the variance is 0.694.
How is it different from the binomial?
The binomial assumes each draw has the same chance — drawing with replacement. Without replacement the chances change after each draw, which the hypergeometric accounts for. For the committee, treating each pick as an independent 6/11 chance of a man would give 0.3688 instead of 0.4545, a large error, because the sample is a third of the whole group.
When can I use the binomial instead?
When the sample is a small part of a large population, removing items barely changes the odds. Drawing 10 from a lot of 1,000 that holds 100 defects, the chance of exactly 2 is 0.1945; the binomial with p = 0.1 gives 0.1937. In a lot of 50 with 10 defects the same sample gives 0.3369 against 0.3020, and the shortcut is no longer safe.
What are the mean and variance?
Mean = nK ÷ N. Variance = n(K/N)(1 − K/N)(N − n) ÷ (N − 1); the last factor is the correction for sampling without replacement. It shrinks to 0 when the sample is the whole population, since nothing is left to chance.
Where is it used?
Card and lottery odds, quality control (defective items in a sample from a lot), and ecology (tagged animals in a recapture sample).
Common mistakes with the hypergeometric distribution
First, swapping the inputs: N is the whole population, K the number of successes in it, n the size of the sample, and k the number of successes you want in the sample. Second, asking for an impossible k. The sample cannot hold more successes than K or n, nor fewer than n − (N − K), because only so many failures exist; the table lists every possible k, and outside that range the probability is 0. Third, using it with replacement, which is the binomial case. Fourth, treating a sample as random when it was picked by hand: the probabilities assume every combination of n items is equally likely.
Worked example: the chance a sample finds at least one defect
A lot holds 200 parts, 10 of them defective, and an inspector pulls 15 at random. The chance of finding none is C(190, 15) ÷ C(200, 15) = 0.4500, so the chance of at least one defective part is 1 − 0.4500 = 0.5500, about 55.0%. The mean number found is 15 × 10 ÷ 200 = 0.75. The practical reading is that a 5% defect rate in the lot will be caught by this sample only about 55 times in 100, so a sampling plan that must catch rare defects needs a larger sample. Use "at least" for questions about finding any or several, and "exactly" for one particular count.
Worked example: matching numbers in a 6-of-49 lottery
The draw is a hypergeometric case: the population is the 49 numbers (N = 49), 6 are winners (K = 6), and your ticket is a sample of 6 (n = 6). Matching exactly 3 has probability C(6, 3) × C(43, 3) ÷ C(49, 6) = 0.01765, about 1 in 57. Matching all 6 has a probability of 1 in 13,983,816. Real lotteries add bonus balls and differing prize tiers, so use this only for the basic counts, not for a specific game's published odds.
Sources: OpenStax, Introductory Statistics 2e, section 4.5 (Hypergeometric Distribution, committee example). Related: binomial probability calculator, lottery odds calculator, permutation and combination calculator, probability calculator and Fisher’s exact test calculator.