Hypergeometric Distribution Calculator

The hypergeometric distribution gives the probability of k successes in a sample of n drawn without replacement from a population of N containing K successes. For N = 50, K = 10, n = 5 and k = 2, P(X = 2) = 0.2098.

Last updated · By · Runs in your browser, nothing is uploaded

Result

Step-by-Step Solution

Enter your values above to see the full working.

What Is the Hypergeometric Distribution?

The hypergeometric distribution is the correct model when you draw a sample without replacement from a small, finite population that contains two kinds of items, such as defective and good parts, or aces and non-aces. Because each draw removes an item, the probability changes from draw to draw, which is exactly what the binomial distribution cannot handle.

Think of drawing five cards from a deck and counting the aces, or inspecting five items from a lot of 50 in which 10 are faulty. In both cases you want to know how many “successes” (aces, faulty items) are in your sample.

Hypergeometric vs Binomial

HypergeometricBinomial
SamplingWithout replacementWith replacement, or from a very large population
Trials independent?NoYes
ParametersN, K, nn, p
Use whenThe sample is a sizeable fraction of the populationThe population is huge compared with the sample

When the population is much larger than the sample, the two give nearly the same answer, and the binomial is easier to use.

Hypergeometric Formulas

P(X = k) = C(K, k) × C(N − K, n − k) ÷ C(N, n) Mean = n × K ÷ N Variance = n × (K ÷ N) × (1 − K ÷ N) × (N − n) ÷ (N − 1)
  • N is the total population size.
  • K is the number of “success” items in the population.
  • n is the sample size.
  • k is the number of successes you want in the sample.
  • C(a, b) is a combination: the number of ways to choose b items from a.

The numerator counts the samples with exactly k successes, and the denominator counts all possible samples. The factor (N − n) ÷ (N − 1) in the variance is the finite population correction, which reduces the spread relative to the binomial.

Worked Example: Defective Items in a Lot

A lot has N = 50 items, of which K = 10 are defective. You inspect n = 5 without replacement. What is the chance of finding exactly k = 2 defective?

  1. Ways to choose 2 defective from 10: C(10, 2) = 45.
  2. Ways to choose 3 good from 40: C(40, 3) = 9,880.
  3. Ways to choose any 5 from 50: C(50, 5) = 2,118,760.
  4. P(X = 2) = 45 × 9,880 ÷ 2,118,760 = 0.2098.
  5. Mean = 5 × 10 ÷ 50 = 1; variance = 5 × 0.2 × 0.8 × 45 ÷ 49 = 0.7347.
  6. P(X ≤ 2) = 0.9517 and P(X ≥ 2) = 0.2581.

How This Compares with the Binomial

If you ignored the removal of items and used a binomial with n = 5 and p = 0.2, you would get P(X = 2) = 0.2048, close but not the same. The difference grows as the sample becomes a larger share of the population.

Example: Aces in a Poker Hand

Drawing 5 cards from 52 with 4 aces, the probability of exactly 2 aces is C(4, 2) × C(48, 3) ÷ C(52, 5) = 6 × 17,296 ÷ 2,598,960 = 0.0399, about 4%.

Example: Catching a Faulty Item

The probability that the sample from the lot above contains no defective item is 0.3106, so the chance of catching at least one faulty item is 1 − 0.3106 = 0.6894.

How to Use This Hypergeometric Distribution Calculator

  1. Enter the population size N.
  2. Enter the number of successes K in the population.
  3. Enter the sample size n.
  4. Enter the number of successes k you want in the sample.
  5. Read P(X = k), the cumulative probabilities, the mean and the variance.

Remember that K cannot exceed N, n cannot exceed N, and k must be possible given K and n.

Real-World Uses of the Hypergeometric Distribution

  • Quality inspection: acceptance sampling of a batch, where tested items are not returned.
  • Card games: the odds of drawing particular cards in a hand.
  • Lotteries: the probability of matching k of the drawn numbers.
  • Biology and ecology: capture–recapture estimates of animal populations.
  • Genetics and bioinformatics: Fisher’s exact test and gene-set enrichment use the hypergeometric distribution.
  • Auditing: sampling from a finite set of records for errors.

What Are the Most Common Mistakes With the Hypergeometric Distribution Calculator?

  • Using the binomial for a small population. If the sample is more than about 5% of the population, the hypergeometric is more accurate.
  • Mixing up K and k. K is successes in the population, and k is successes in the sample.
  • Impossible inputs. k cannot exceed K or n, and n − k cannot exceed N − K.
  • Sampling with replacement. If items are returned, the binomial applies.
  • Forgetting the finite population correction. The variance is smaller than the binomial’s.
  • Huge combinations. Very large N can overflow naive calculations, so rely on a tool that works with logarithms.

Where Can You Verify These Formulas?

The definitions and formulas on this page follow standard references. Check them against these sources:

Built and maintained by S. Dilshan. Found a mistake? Email [email protected] with the page address.

Frequently Asked Questions

What is the hypergeometric distribution used for?

It models the number of successes in a sample drawn without replacement from a finite population, such as defective items in a batch or aces in a poker hand.

What is the hypergeometric probability formula?

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

What is the difference between hypergeometric and binomial?

Binomial assumes independent trials with a constant probability, such as sampling with replacement. Hypergeometric accounts for items being removed, so the probability changes with each draw.

When can I use the binomial approximation?

When the population is large compared with the sample, usually when n is less than about 5% of N. The two distributions then give very similar answers.

What are the mean and variance?

The mean is n × K ÷ N. The variance is n × (K ÷ N) × (1 − K ÷ N) × (N − n) ÷ (N − 1).

Can I use it for more than two categories?

The basic form has two categories, success and failure. For more categories, the multivariate hypergeometric distribution extends the idea.