Hypergeometric Distribution Calculator
Find the exact probability of k successes when you draw n items without replacement from N items containing K successes, as with cards or lot inspection.
Hypergeometric Distribution Calculator
Background.
Draw a card from a deck without putting it back and the odds for the next card have already changed. Whenever you sample from a finite group without replacement, whether cards from a deck, balls from a lottery drum or parts pulled from a production lot for inspection, each draw alters what remains, and the hypergeometric distribution is the exact way to account for it.
It answers one question. If a population of N items contains K of the kind you care about and you take n of them at random, what is the probability of getting exactly k? The answer is pure counting. There are C(K, k) ways to choose which k of the success items you get, C(N − K, n − k) ways to fill the rest of the sample from everything else, and C(N, n) possible samples altogether. Favourable samples divided by all samples is the probability.
The binomial distribution answers a similar-sounding question but assumes every draw has the same chance of success, which holds only if items go back after each draw or the population is so large that removing a few changes nothing. With small populations the gap is real. Taking 5 from 50 items of which 10 are defective, the chance of exactly 2 defectives is 0.20984, while a binomial with p = 0.2 gives 0.2048; the chance of none is 0.31056 against 0.32768.
That is why the distribution turns up in acceptance sampling for quality control, in card and lottery odds, and in Fisher's exact test for 2 × 2 tables, which rests on the same count. The page gives the probability of exactly k successes, not k or more, and works with whole-number counts for populations of up to 10,000.
What is hypergeometric distribution calculator?
The hypergeometric distribution gives the probability of exactly k successes in n draws made without replacement from a finite population of N items, K of which are successes. Its probabilities over all possible values of k add up to 1. The mean is n × K ÷ N, and the variance is smaller than the matching binomial variance by the finite-population factor (N − n) ÷ (N − 1). All four quantities are whole-number counts.
How to use this calculator.
- Enter the total number of items in Population size N: the whole deck, lot or lottery drum, up to 10,000.
- Enter how many of those count as a success in Success states K, for example the 4 aces in a 52-card deck or the defective units in a lot.
- Enter the sample size in Draw count n and the exact number of successes you want a probability for in Observed successes k. The combination has to be possible: k cannot exceed K or n, and the failures in the sample, n − k, cannot exceed N − K.
- For at-least or at-most questions, run the page once for each value of k and add the results. At least 2 defectives in the example lot is 1 minus the results for k = 0 and k = 1.
The formula.
P(X = k) = C(K, k) × C(N − K, n − k) ÷ C(N, n), where C(a, b) = a! ÷ (b! × (a − b)!) is the number of ways to choose b items from a. The first factor counts the ways to pick k of the K successes, the second counts the ways to pick the remaining n − k items from the N − K failures, and the denominator counts every possible sample of size n. Because every sample is equally likely, their ratio is the probability. The result depends most on the success share K ÷ N and on how large the sample is relative to the population. When n is a small fraction of N it approaches the binomial probability with p = K ÷ N: with 5,000 items of which 1,000 are successes, exactly 2 in a draw of 5 has probability 0.20485, almost the binomial 0.2048.
A worked example.
A lot of 50 parts contains 10 defectives, and an inspector pulls 5 at random. What is the chance of finding exactly 2 defectives? The ways to pick 2 of the 10 defectives are C(10, 2) = 45. The ways to fill the other 3 places from the 40 good parts are C(40, 3) = 9,880. Multiplying gives 45 × 9,880 = 444,600 favourable samples. The number of possible 5-part samples is C(50, 5) = 2,118,760, so the probability is 444,600 ÷ 2,118,760 = 0.2098, about 21%. The neighbouring outcomes put this in context: no defectives has probability 0.31056 and exactly 1 has 0.43134, so the chance of 2 or more is 1 − 0.31056 − 0.43134 = 0.2581. An inspector who rejects the lot only when 2 or more turn up would pass this 20%-defective lot almost three times in four.
Frequently asked questions.
When should I use the hypergeometric distribution instead of the binomial?
What is the chance of drawing at least one of four copies in a 7-card opening hand from a 60-card deck?
What are the odds of matching exactly 3 numbers in a 6-from-49 lottery?
What is the probability of being dealt exactly two aces in five-card poker?
What is the expected number of successes in the sample?
How is the hypergeometric distribution linked to Fisher's exact test?
References& sources.
How this page was produced
- Published by
- Quanta Calculator
- Overseen by
- Daniel, Quanta Calculator Researcher
- Primary sources
- 3 cited below
- Method
- P(X=k)=C(K,k)C(N-K,n-k)/C(N,n)
- Published
- Last verified
Built with AI assistance and verified by automated tests against the cited sources — every worked example on this page is computed by the same code that runs the calculator. How we build and check calculators.
In this category
Embed
Quanta Pro
Paid features are coming later.
- All 1560 calculators remain free
- No billing is enabled