Hypergeometric Distribution Calculator

Enter N, K, n and k for the hypergeometric distribution.

How it is calculated

Draws are made without replacement from a population of N items, of which K are successes. The probability of getting exactly k successes in n draws is P(X = k) = C(K, k) × C(N − K, n − k) ÷ C(N, n), where C(a, b) is the number of ways to choose b items from a. The numerator counts the samples with k successes and n − k failures, the denominator counts all possible samples. The second result is the mean, n × K ÷ N. Only the probability of exactly k is given, not 'k or more' or 'k or fewer'; add up the exact probabilities yourself for those. All four inputs must be whole numbers, with K ≤ N, n ≤ N, k ≤ n and k ≤ K, and the population must hold at least n − k failures, otherwise no result is shown. Population sizes in the thousands or millions work (up to 1 billion); the probability is shown to four decimals.

Worked example

A 52-card deck has 13 hearts. Draw 5 cards: what is the chance of exactly 2 hearts? N = 52, K = 13, n = 5, k = 2. Ways to choose 2 hearts: C(13, 2) = 78. Ways to choose the other 3 cards from the 39 non-hearts: C(39, 3) = 9,139. Total 5-card hands: C(52, 5) = 2,598,960. So P = 78 × 9,139 ÷ 2,598,960 = 712,842 ÷ 2,598,960 = 0.2743. The mean number of hearts is 5 × 13 ÷ 52 = 1.25.

Try this example →

Common mistakes

  • Using it when items are put back after each draw: with replacement the draws are independent and the binomial distribution applies, not this one.
  • Entering K as a percentage or a probability instead of a count of success items in the population; all four inputs must be whole numbers, so a k of 2.5 gives no result.
  • Reading the result as 'at least k': the tool gives exactly k, so for 2 or more hearts you must add the probabilities for 2, 3, 4 and 5.
  • Swapping n and k, so that the sample size is the number of successes wanted; n is how many you draw, k how many of those should be successes.
  • Entering a sample the population cannot supply, such as k larger than n or K, or more failures than the population contains (N = 52, K = 13, n = 45, k = 2); such combinations give no result.

About this calculator

The hypergeometric distribution gives the probability of drawing exactly k successes in n draws taken without replacement from a finite population of size N that contains K successes overall. It differs from the more familiar binomial distribution precisely because each draw changes the population left behind — once you have pulled a winning ticket out of a jar, it is gone, and the odds for the next draw shift accordingly.

This makes it the right model for situations like drawing cards from a single deck without putting them back, quality-control auditors pulling a sample of items from a finished production batch to check for defects, lottery and raffle odds, and ecologists estimating a wild population's size using capture-recapture methods, where the same “sampling without replacement” logic applies to marked versus unmarked animals.

Was this helpful?

You can pick up to 3 reactions.

Be the first to comment.

Popular calculators

All Calculators