Hypergeometric Distribution Calculator
- There are C(52, 5) = 2,598,960 equally likely draws.
- Exactly 2 successes: C(4, 2) × C(48, 3) ÷ 2,598,960 = 3.99%.
- At most 2 successes comes to 99.82%, and at least 2 to 4.17%; the expected count is 0.38.
Our hypergeometric distribution calculator computes the probability of drawing exactly k successes when n items are drawn without replacement from a population of N items containing K successes. Using the formula P(X = k) = C(K, k) × C(N − K, n − k) / C(N, n), it returns the exact probability along with related cumulative results, such as the probability of getting at most or at least that many successes, and the expected number of successes, calculated as n × K / N. For example, drawing a 5-card hand from a standard 52-card deck yields a 3.99% chance of exactly 2 aces, a 99.82% chance of at most 2 aces, and a 4.17% chance of at least 2 aces, with an expected count of 0.38 aces.
The hypergeometric distribution is the accepted standard for this type of calculation because, unlike the binomial distribution, the draws are not independent. Each draw changes the composition of what remains, which is exactly why sampling inspection and quality control rely on this distribution. For instance, exactly 2 defectives in a sample of 4 from a batch of 20 containing 5 defectives has a probability of 21.67%, and drawing 10 items from a batch of 100 containing 10 successes and getting none has a probability of 33.05%. This page presents the formula, step-by-step workings, worked examples, and sources so you can verify every result.
Worked examples
Two aces
Primary result: 3.99% — exactly 2 of the 4 aces land in a 5-card hand just under once in 25 deals. (52 · 4 · 5 · 2)
| P(X = 2) | 3.99% |
| P(X ≤ 2) | 99.82% |
| P(X ≥ 2) | 4.17% |
| Expected successes | 0.38 |
A quality sample
Primary result: 21.67% — finding exactly 2 of 5 defectives in a sample of 4 from a batch of 20. (20 · 5 · 4 · 2)
| P(X = 2) | 21.67% |
| P(X ≤ 2) | 96.80% |
| P(X ≥ 2) | 24.87% |
| Expected successes | 1.00 |
Dodging every success
Primary result: 33.05% — even with 10 successes among 100, a draw of 10 misses them all a third of the time. (100 · 10 · 10 · 0)
| P(X = 0) | 33.05% |
| P(X ≤ 0) | 33.05% |
| P(X ≥ 0) | 100.00% |
| Expected successes | 1.00 |
Sampling without replacement
When you draw cards from a deck, pull lots for a raffle, or pull items off a production line for inspection, each item you remove changes what is left. The binomial distribution assumes every draw is independent, but sampling without replacement breaks that assumption. Each draw changes the composition of what remains, which is exactly why sampling inspection uses this distribution instead. The hypergeometric distribution accounts for that changing population and gives you accurate probabilities for real-world situations where items are not put back.
The math is straightforward. The hypergeometric distribution gives the probability of exactly k successes when n items are drawn without replacement from a population of N containing K successes. The formula is P(X = k) = C(K, k) x C(N - K, n - k) / C(N, n). The expected number of successes is n x K / N. Rather than working through the combinatorics by hand, a hypergeometric distribution calculator handles the arithmetic instantly and reduces the chance of an error.
A standard example is drawing cards. If you deal a 5-card hand from a standard 52-card deck, the deck contains 4 aces, so K = 4. The probability of drawing exactly 2 aces is 3.99%. The probability of drawing at most 2 aces is 99.82%, and the probability of drawing at least 2 aces is 4.17%. The expected count of aces in that hand is 0.38. Because the cards are not replaced, the odds shift slightly with every card dealt, which is what separates this model from the binomial.
The same logic applies to quality inspection. If a batch of 20 items contains 5 defectives and inspectors pull a sample of 4, the probability of finding exactly 2 defectives is 21.67%. In a larger run, drawing 10 items from a batch of 100 that contains 10 successes has a 33.05% probability of yielding zero successes. Those numbers matter for acceptance sampling, lot inspection, and audit testing, where the goal is to judge an entire batch from a small sample and the population is not replenished between draws.
The formula in combinations
The hypergeometric distribution gives the probability of exactly k successes when n items are drawn without replacement from a population of N containing K successes. The formula is P(X = k) = C(K, k) x C(N - K, n - k) / C(N, n). Here, C(a, b) represents the number of combinations in which b items can be chosen from a group of a items, calculated as a! divided by the product of b! and (a - b)!. The numerator multiplies two separate combination counts: the ways to choose your k successes from the K available successes, and the ways to choose the remaining (n - k) failures from the (N - K) available failures. The denominator divides by the total number of ways to choose any n items from the full population of N.
To see how the pieces fit together, consider the verified example of drawing a 5-card hand from a standard 52-card deck. The total number of possible 5-card hands is exactly 2,598,960, which is the value of C(52, 5) and serves as the denominator. If you want to find the probability of getting exactly 2 aces, you set K = 4 (the four aces in the deck), n = 5 (the hand size), and k = 2. The numerator becomes C(4, 2) x C(48, 3), which counts the ways to choose 2 aces from 4 and 3 non-aces from the remaining 48 cards. Dividing by 2,598,960 gives a probability of 3.99%. The same formula extends to related questions: the probability of drawing at most 2 aces is 99.82%, and the probability of drawing at least 2 aces is 4.17%.
The formula also applies directly to quality control and inspection scenarios. In a batch of 20 items containing 5 defectives, drawing a sample of 4 and finding exactly 2 defectives has a probability of 21.67%. Another verified case involves drawing 10 items from a population of 100 that contains 10 successes; the probability of getting none of those successes is 33.05%. In each situation, the population shrinks after every draw, so the probability changes with each selection.
Unlike the binomial distribution, the draws here are not independent. Each draw changes the composition of what remains, which is exactly why sampling inspection uses this distribution rather than treating each selection as a separate, identical event. The expected number of successes across n draws is n x K / N, which for the ace example gives 5 x 4 / 52 = 0.38. A hypergeometric distribution calculator uses this formula to compute exact probabilities and cumulative values without requiring manual combination math.
Worked examples
The table below collects three verified cases that show what a hypergeometric distribution calculator produces in practice. Each case follows the same formula, P(X = k) = C(K, k) x C(N - K, n - k) / C(N, n), which gives the probability of exactly k successes when n items are drawn without replacement from a population of N containing K successes. The expected number of successes, shown for the card example, is n x K / N.
The first case is a familiar one: drawing a 5-card hand from a standard 52-card deck and asking for exactly 2 aces. Here N = 52, K = 4, n = 5, and k = 2. The calculator returns 3.99% for exactly 2 aces. It also gives related figures that are often needed alongside the core result: at most 2 aces is 99.82%, at least 2 aces is 4.17%, and the expected count is 0.38. The expected value is small because aces are rare and the hand is small, so getting two is already on the high side of what the distribution centers on.
The second case comes from sampling inspection, one of the main settings where this distribution matters. A batch of 20 items contains 5 defectives, and a sample of 4 is drawn without replacement. The probability of finding exactly 2 defectives is 21.67%. Unlike the binomial distribution, the draws are not independent, since each draw changes the composition of what remains, which is exactly why sampling inspection uses this distribution rather than assuming each item has the same independent chance of being defective.
The third case is a clean draw: 10 items are drawn from a lot of 100 that contains 10 successes, and the question is the chance of getting zero successes. The calculator returns 33.05%. This is not negligible, because 90% of the lot is non-successes, and drawing 10 without replacement leaves a real chance of missing all the successes. Together, the three cases show how the same formula handles card problems and quality inspection with the same mechanics, just with different numbers plugged in.
| Case | N (population) | K (successes) | n (drawn) | k (target) | Probability | Related results |
|---|---|---|---|---|---|---|
| Two aces in a 5-card hand | 52 | 4 | 5 | 2 | 3.99% | At most 2: 99.82%; at least 2: 4.17%; expected count: 0.38 |
| Two defectives in a sample of 4 | 20 | 5 | 4 | 2 | 21.67% | — |
| No successes in a draw of 10 | 100 | 10 | 10 | 0 | 33.05% | — |
Exact, at-most and at-least
A hypergeometric distribution calculator can report three related but distinct probabilities for the same scenario: the chance of getting exactly k successes, at most k successes, and at least k successes. The exact probability comes straight from the core formula: P(X = k) = C(K, k) x C(N - K, n - k) / C(N, n), where N is the total population, K is the number of successes in that population, and n is the number of items drawn. The at-most probability is the sum of every exact probability from zero up to k, while the at-least probability is the sum of every exact probability from k upward to the smaller of n and K.
Consider a 5-card hand drawn from a standard 52-card deck, where K = 4 aces. The chance of getting exactly 2 aces is 3.99%. When you ask for at most 2 aces, the calculator adds together the probabilities of getting 0 aces, 1 ace, and 2 aces, yielding 99.82%. When you ask for at least 2 aces, it adds the probabilities of getting 2, 3, or 4 aces, giving 4.17%. Notice that the exact value of 3.99% appears in both the at-most and at-least sums, because both ranges include the outcome of exactly 2. This overlap is what connects the three figures.
The same pattern holds in quality-control settings. Drawing a sample of 4 items from a batch of 20 that contains 5 defectives gives a 21.67% probability of finding exactly 2 defectives. The at-most-2 figure would add the probabilities for 0, 1, and 2 defectives, while the at-least-2 figure would add the probabilities for 2, 3, and 4 defectives. Again, the exact probability is the shared building block. Because the draws are without replacement, each item removed changes the composition of what remains, so the probability shifts with every draw. This is exactly why sampling inspection relies on the hypergeometric distribution rather than the binomial, where every draw is assumed to be independent.
The expected number of successes, calculated as n x K / N, gives a central reference point for interpreting these three probabilities. In the card example, the expected count is 0.38 aces, which is well below 2 and helps explain why the at-least-2 probability of 4.17% is so small while the at-most-2 probability of 99.82% is so large. Similarly, drawing 10 items from a population of 100 containing 10 successes has a 33.05% chance of yielding zero successes, a result that sits below the expected count of 1 and shapes the cumulative sums for any at-most or at-least threshold.
Hypergeometric versus binomial
The binomial distribution assumes every draw is independent, so the chance of success stays constant. The hypergeometric distribution does not make that assumption. Instead, it accounts for the fact that each draw changes the composition of what remains. When you draw without replacement, removing a success lowers the number of successes left, and removing a failure lowers the number of failures left. That is exactly why sampling inspection uses this distribution rather than the binomial.
When the population is large relative to the sample, the binomial approximates the hypergeometric well. Drawing 10 items from a population of 100 containing 10 successes and getting zero has probability 33.05% under the hypergeometric formula. The binomial, treating the success probability as fixed at 10%, gives a close but not exact answer. The difference is small here because 10 items out of 100 barely shift the composition. As the population grows larger relative to the sample, the approximation tightens, and the binomial becomes a practical shortcut.
When the population is not large relative to the sample, the binomial misleads. Consider a batch of 20 items containing 5 defectives, from which you inspect 4. The hypergeometric distribution gives the probability of exactly 2 defectives as 21.67%. A binomial model with a fixed 25% defect rate would give a meaningfully different answer, because after each defective is found, the remaining defect rate drops. The smaller the batch, the more each draw shifts the odds, and the wider the gap between the two distributions becomes.
A standard deck of cards shows the same effect. The probability of exactly 2 aces in a 5-card hand from a 52-card deck is 3.99%. The expected number of aces is n times K divided by N, which is 5 times 4 divided by 52, or about 0.38. The chance of at most 2 aces is 99.82%, and the chance of at least 2 is 4.17%. A binomial model treating the ace probability as constant at 4 out of 52 would land near these figures but not on them, because each card dealt changes what is left in the deck.
A hypergeometric distribution calculator applies the exact formula P(X = k) = C(K, k) times C(N minus K, n minus k) divided by C(N, n), where N is the population, K is the number of successes in it, n is the sample size, and k is the target count. Use it whenever the sample is a noticeable fraction of the population. Use the binomial only when the population is so large that drawing without replacement barely changes the odds.
Acceptance sampling
Acceptance sampling is a core quality-control technique used to decide whether a batch, or lot, of finished goods should be accepted or rejected without inspecting every single item. Because inspecting each item is often too costly or time-consuming, engineers draw a sample and use the results to make a decision about the entire batch. The key challenge is choosing a sample size large enough that a bad lot is unlikely to pass, yet small enough to keep inspection costs practical. This is where the hypergeometric distribution calculator becomes an essential tool for quality engineers.
The hypergeometric distribution gives the probability of exactly k successes when n items are drawn without replacement from a population of N containing K successes. The formula is P(X = k) = C(K, k) × C(N − K, n − k) / C(N, n). Unlike the binomial distribution, the draws are not independent — each draw changes the composition of what remains, which is exactly why sampling inspection uses this distribution. When an inspector pulls items from a batch and does not put them back, the probability of finding a defect changes with each draw. The binomial distribution assumes a constant probability, which does not match real-world acceptance sampling from a finite lot.
Consider a concrete example. If a batch of 20 items contains 5 defectives, and an inspector draws a sample of 4 items, the probability of finding exactly 2 defectives is 21.67%. The expected number of defectives in the sample is calculated as n × K / N, which in this case is 4 × 5 / 20 = 1. By adjusting the sample size and the acceptance threshold — the maximum number of defectives allowed before rejecting the lot — engineers can calculate the probability that a bad lot slips through. For instance, drawing 10 items from a lot of 100 containing 10 defective items and getting zero defectives has a probability of 33.05%. This tells the engineer that even a lot with a 10% defect rate has a one-in-three chance of passing if the acceptance threshold is set at zero.
Quality engineers use these probabilities to balance two competing risks. Producer's risk is the chance of rejecting a good lot, while consumer's risk is the chance of accepting a bad lot. By testing different sample sizes and acceptance thresholds, engineers can find a sampling plan that keeps both risks within agreed limits. The hypergeometric distribution provides the exact probabilities needed for this analysis, making it the correct choice for sampling from finite batches where the population size, the number of defectives in the lot, and the sample size are all known quantities.
FAQs
What is the hypergeometric distribution?
It is the probability distribution for successes in a sample drawn without replacement from a finite population. Each draw changes the composition of the remaining population, so the probability of success shifts from one draw to the next. This makes it the right tool for situations where you pull items from a fixed group and do not put them back.
What is the probability of exactly 2 aces in 5 cards?
The probability is 3.99%, calculated as C(4, 2) x C(48, 3) / C(52, 5). Here, 4 is the number of aces in the deck, 48 is the number of non-ace cards, and 52 is the total deck size. You are choosing 2 aces from 4 and 3 other cards from 48, divided by all possible 5-card hands.
How is it different from the binomial distribution?
The binomial assumes independent draws, meaning with replacement or an infinite population, so the success probability stays constant. The hypergeometric accounts for the population changing as you draw, since each item removed alters the odds for the next draw. Use the binomial when items go back in; use the hypergeometric when they do not.
What is the expected number of successes?
The expected number of successes is n x K / N, where n is the sample size, K is the number of success states in the population, and N is the total population. For the verified 5-card hand, this gives 0.38 aces on average. This mean tells you what to expect over many repeated draws without replacement.
When should I use the hypergeometric distribution?
Use it for card hands, lottery draws, inspection sampling and capture-recapture problems — any draw without replacement from a known population. If each selection removes an item and changes the odds for the next selection, the hypergeometric distribution applies. It is the correct model whenever the sample comes from a fixed, finite group and items are not returned before the next draw.
Can the wanted successes exceed the draw?
No. The number of wanted successes, k, can be at most the smaller of K and n, where K is the total successes available in the population and n is the number you draw. The probability is zero outside the possible range. You cannot draw more successes than exist in the population or more successes than the number of cards you actually draw.