Audited 31 Jul 2026·Last updated 28 Oct 2026·3 citations·Tier 3·0 uses

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

Exact probability
0.2098
The probability, from 0 to 1, of drawing exactly k successes in n draws without replacement; multiply by 100 for a percentage.
Model scope
One-category sampling without replacement from a finite population; it does not model replacement, unequal selection probabilities, dependence beyond depletion, or estimate population composition.

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.

  1. Enter the total number of items in Population size N: the whole deck, lot or lottery drum, up to 10,000.
  2. 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.
  3. 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.
  4. 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)

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.

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.

observed Successes2
population Successes10
draw Count5
population Size50

Frequently asked questions.

When should I use the hypergeometric distribution instead of the binomial?
Whenever you sample without replacement and the sample is a noticeable share of the population. A common rule of thumb is that the binomial is close enough once the sample is below roughly 5 to 10% of the population; above that, the hypergeometric gives the correct answer and the binomial overstates the spread.
What is the chance of drawing at least one of four copies in a 7-card opening hand from a 60-card deck?
Work out the chance of drawing none and subtract it from 1. With N = 60, K = 4, n = 7 and k = 0 the page gives 0.60050, so the chance of at least one copy is 1 − 0.60050 = 0.39950, a little under 40%.
What are the odds of matching exactly 3 numbers in a 6-from-49 lottery?
Treat the six winning numbers as the successes: N = 49, K = 6, and your ticket is a draw of n = 6. For k = 3 the probability is 0.017650, about 1 in 57. The total number of possible tickets, C(49, 6), is 13,983,816.
What is the probability of being dealt exactly two aces in five-card poker?
Use N = 52, K = 4, n = 5 and k = 2. There are 6 ways to choose the two aces and 17,296 ways to choose the other three cards from the 48 non-aces, out of 2,598,960 possible hands, giving 0.03993, about 1 in 25.
What is the expected number of successes in the sample?
The mean is n × K ÷ N, the same as for the binomial. In the 50-part lot that is 5 × 10 ÷ 50 = 1 defective. The variance is lower, though: 0.7347 instead of the binomial 0.8, because the finite-population factor (50 − 5) ÷ (50 − 1) shrinks it.
How is the hypergeometric distribution linked to Fisher's exact test?
In a 2 × 2 table with fixed row and column totals, the count in any one cell follows a hypergeometric distribution. Fisher's exact test adds up the probabilities of the observed table and every table at least as extreme to obtain its p-value.

How this page was produced

Published by
Quanta Calculator
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
Coming soon