Hypergeometric Calculator

Drawing without replacement, from cards to audit samples, is a hypergeometric question. Enter your population, how many of it are the thing you want, and how many you are drawing, and this gives the exact probability of every outcome plus the full distribution.

Put this calculator on your website for free

Copy one snippet and give your visitors a working Hypergeometric Calculator.

What makes a question hypergeometric

You have a pool of things. Some of them are what you want. You take a handful, and you do not put any of them back. That is the whole shape of it.

The not-putting-back is the important part. Once you have drawn a heart, there are fewer hearts left and fewer cards left, so the odds for the next draw are different from the first. The hypergeometric distribution is what you get when you account for that shift exactly rather than pretending it does not happen.

The formula

P(X = k) = C(K, k) × C(N − K, n − k) ÷ C(N, n)

Read it as counting rather than as probability. The bottom is every way to choose your draw from the population. The top is every way to choose k of your successes and fill the rest of your hand from the failures. Divide the favourable arrangements by all arrangements and you have the answer.

Worked example

Exactly two hearts in a five card hand.

N = 52 cards, K = 13 hearts, n = 5 drawn, k = 2 wanted.

P = C(13, 2) × C(39, 3) ÷ C(52, 5)
P = 78 × 9,139 ÷ 2,598,960
P = 0.274280, or about 27.4%

For comparison, a binomial calculation with p = 13/52 gives 0.263672. Close, but not the same number, and the gap has a direction worth understanding.

Hypergeometric against binomial

The binomial distribution answers the same shape of question with replacement: put the card back and shuffle before each draw. That keeps every trial identical, which makes the maths simpler and the answer wrong for a deck.

Two facts describe the relationship completely:

That second multiplier should look familiar if you have used the sample size calculator: it is the finite population correction, the same factor that lets a survey of a small town need fewer responses than a survey of a continent. It is the same idea seen from the other end.

Which way a binomial answer goes wrong

Because hypergeometric is more tightly concentrated, a binomial substitute does not simply run high or low. It understates the middle and overstates the tails.

Five card handTrue (hypergeometric)Binomial saysOff by
At least 1 heart0.77850.76272% low
At least 3 hearts0.09280.103512% high
At least 4 hearts0.01120.015639% high

The tails are where people actually ask questions. Nobody wonders about an average hand; they wonder about a great one. So the binomial shortcut fails hardest at exactly the question you most wanted answered, and it fails in the flattering direction.

The practical rule: if your draw is under about 5 percent of the population, removing a few items barely changes what is left and the two distributions converge. Above that, use the exact one. It is not harder, and this page does it for you.

Where this comes up outside card games

If your trials really are independent, with a fixed probability that does not move as you go, the binomial calculator is the right page instead.

Frequently asked questions

What is the hypergeometric distribution?

It gives the probability of drawing a certain number of successes from a finite population when you do not put anything back. Each draw changes what is left, so the odds shift as you go, which is exactly what the formula accounts for.

When do I use it instead of the binomial?

Use hypergeometric when you are drawing without replacement from a population you could in principle count: cards from a deck, items from a shipment, names from a list. Use binomial when every trial has the same fixed probability, like coin flips or dice.

How different are the two answers?

They share the same mean exactly, so on average they agree. The difference is spread: hypergeometric is more tightly concentrated, so a binomial answer understates the middle of the distribution and overstates the far tails. On a 5 card hand, binomial puts the odds of 4 or more hearts about 39 percent higher than they really are.

When is a binomial answer close enough?

When your sample is a small slice of the population, conventionally under 5 percent. At that point taking a card out barely changes what is left, so with or without replacement stop meaning very different things. Above it, the gap grows quickly.

What are the mean and variance?

The mean is n times K over N, exactly the same as a binomial with p set to K over N. The variance is that binomial variance multiplied by (N − n) divided by (N − 1), and that multiplier is the finite population correction: the same factor that shrinks a required survey sample.

Can I use it for lottery odds?

Yes, and it is the correct tool. A lottery draws balls without replacement, so the chance of matching a given number of them is hypergeometric. Matching all of them is just the case where your successes equal the draw size.

What does at least mean here?

It is the cumulative upper tail: the probability of your number or anything above it. This calculator reports all five readings at once, since which one you want depends on the question, and picking the wrong tail is a more common mistake than getting the formula wrong.

Related calculators