Hypergeometric Distribution

The hypergeometric distribution gives the probability of k successes when you draw n items without replacement from a population of N items that contains K successes: P(X = k) = C(K, k)C(N − K, n − k)/C(N, n). Its mean is nK/N, the same as a binomial mean with p = K/N.

Before this lesson: Probability with Combinations, Binomial Distribution and Poisson Distribution

Sampling without replacement

A shipment of 20 phones has 5 defective ones. An inspector tests 4 phones, chosen at random. Once a phone is tested, it isn’t put back, so each draw changes what is left. The draws aren’t independent, and the chance of a defective phone isn’t the same on every draw. That rules out the binomial distribution.

Counting still works. Every set of 4 phones is equally likely, so the chance of exactly k defective phones is the number of samples with k defective and 4 − k good phones, divided by the number of all samples. This is the two-group count from probability with combinations, written as a distribution.

Hypergeometric distribution formula

Draw n items without replacement from N items, of which K are successes. The number of successes X has a hypergeometric distribution:

P(X = k) = \dfrac{\binom{K}{k}\binom{N-K}{n-k}}{\binom{N}{n}}

The possible values run from max(0, n − (N − K)) to min(n, K): you can’t draw more successes than there are, or more failures than there are. The mean and variance are

E(X) = n\,\dfrac{K}{N}, \qquad \operatorname{Var}(X) = n\,\dfrac{K}{N}\left(1 - \dfrac{K}{N}\right)\dfrac{N-n}{N-1}

The factor (N − n)/(N − 1) is the finite population correction. It is less than 1 whenever n ≥ 2, so sampling without replacement gives a smaller variance than the binomial with p = K/N. Surveys of small populations use the same factor (see sampling distribution of a sample proportion).

Steps

  1. Identify N (population size), K (successes in the population) and n (sample size).
  2. Check that the sample is drawn without replacement and that every sample is equally likely.
  3. Choose k successes from the K successes and n − k failures from the N − K failures, and multiply.
  4. Divide by C(N, n).

Hypergeometric distribution examples

Example 1: Defective phones (word problem)

A shipment of 20 phones contains 5 defective phones. An inspector tests 4 at random. Find the probability that exactly 1 is defective.

N = 20,\quad K = 5,\quad n = 4,\quad k = 1

Identify the values.

\binom{5}{1} = 5

Choose the 1 defective phone.

\binom{15}{3} = \dfrac{15 \cdot 14 \cdot 13}{6} = 455

Choose the 3 good phones from the 15 good ones.

\binom{20}{4} = \dfrac{20 \cdot 19 \cdot 18 \cdot 17}{24} = 4845

Count all samples of 4.

P(X = 1) = \dfrac{5 \cdot 455}{4845} = \dfrac{2275}{4845}

Multiply, then divide.

P(X = 1) = \dfrac{455}{969} \approx 0.4696

Divide the numerator and denominator by 5.

Answer: about 0.4696. The graph shows the whole distribution next to the binomial distribution with n = 4 and p = 5/20 = 0.25, which would apply if each phone were put back before the next draw.

Grouped bar graph for k = 0 to 4 defective items in a sample of 4. Hypergeometric probabilities, sampling without replacement from 20 items with 5 defective: 0.282, 0.470, 0.217, 0.031, 0.001. Binomial probabilities with n = 4 and p = 0.25, sampling with replacement: 0.316, 0.422, 0.211, 0.047, 0.004. The hypergeometric bars are taller in the middle and shorter at the ends.
Without replacement (orange), extreme results like 0 or 3 defective phones are less likely than with replacement (blue), so the hypergeometric spread is smaller.

Example 2: Hearts in a poker hand

Five cards are dealt from a standard 52-card deck. Let X be the number of hearts. Find P(X = 2).

N = 52,\quad K = 13,\quad n = 5,\quad k = 2

The 13 hearts are the successes.

\binom{13}{2} = 78,\quad \binom{39}{3} = 9139

Choose 2 hearts and 3 non-hearts.

P(X = 2) = \dfrac{78 \cdot 9139}{2{,}598{,}960} = \dfrac{712{,}842}{2{,}598{,}960}

Multiply, and divide by C(52, 5).

P(X = 2) \approx 0.2743

Divide.

Answer: about 0.2743. The mean number of hearts is 5 · 13/52 = 1.25.

Example 3: Mean and variance

Find the mean and variance of the number of defective phones in Example 1, and compare the variance with the binomial variance.

E(X) = 4 \cdot \dfrac{5}{20} = 1

Mean formula with n = 4 and K/N = 1/4.

\dfrac{N - n}{N - 1} = \dfrac{20 - 4}{20 - 1} = \dfrac{16}{19}

Finite population correction.

\operatorname{Var}(X) = 4 \cdot \dfrac{1}{4} \cdot \dfrac{3}{4} \cdot \dfrac{16}{19}

Substitute into the variance formula.

\operatorname{Var}(X) = \dfrac{3}{4} \cdot \dfrac{16}{19} = \dfrac{12}{19} \approx 0.632

Multiply.

4 \cdot \dfrac{1}{4} \cdot \dfrac{3}{4} = 0.75

Binomial variance np(1 − p), for comparison.

Answer: E(X) = 1 and Var(X) = 12/19 ≈ 0.632, smaller than the binomial variance 0.75. Each defective phone drawn lowers the chance of another, which pulls the results toward the mean.

Example 4: Tagged fish (capture-recapture)

A pond holds 100 fish, and 20 of them were caught, tagged and released. Later, 10 fish are caught. Find the probability that exactly 2 are tagged, and the probability that at least 1 is tagged.

P(X = 2) = \dfrac{\binom{20}{2}\binom{80}{8}}{\binom{100}{10}}

N = 100, K = 20, n = 10, k = 2.

P(X = 2) = \dfrac{190 \cdot 28{,}987{,}537{,}150}{17{,}310{,}309{,}456{,}440} \approx 0.3182

Use a calculator for the large combinations.

P(X = 0) = \dfrac{\binom{80}{10}}{\binom{100}{10}} \approx 0.0951

No tagged fish: all 10 come from the 80 untagged fish.

P(X \ge 1) = 1 - 0.0951 = 0.9049

Complement rule.

Answer: P(X = 2) ≈ 0.3182 and P(X ≥ 1) ≈ 0.9049. Ecologists turn this around. If 2 of 10 caught fish are tagged, then 20/N ≈ 2/10 suggests about N = 100 fish in the pond.

Example 5: Accepting a lot

A lot of 50 circuit boards contains 3 defective boards. A buyer tests 5 boards and accepts the lot only if none is defective. Find the probability that the lot is accepted, and compare with the binomial estimate.

P(X = 0) = \dfrac{\binom{3}{0}\binom{47}{5}}{\binom{50}{5}}

N = 50, K = 3, n = 5, k = 0.

P(X = 0) = \dfrac{1 \cdot 1{,}533{,}939}{2{,}118{,}760}

Evaluate the combinations.

P(X = 0) \approx 0.7240

Divide.

(0.94)^5 \approx 0.7339

Binomial estimate with p = 3/50 = 0.06.

Answer: the lot is accepted with probability about 0.7240. The binomial estimate 0.7339 is close but too high, because the sample is 10% of the lot. When the sample is under about 5% of the population, the binomial is a good approximation.

Common mistakes

MistakeExample of the errorFix
Using the binomial when items aren’t replacedP(X = 1) = 4(0.25)(0.75)³ ≈ 0.422 in Example 1Without replacement, use the hypergeometric formula: 0.4696.
Choosing the failures from N instead of N − KUsing C(20, 3) for the good phones in Example 1The n − k failures come from the N − K failures: C(15, 3).
Mixing up K and nWriting C(4, 1)C(16, 4) in Example 1K counts successes in the population (5); n is the sample size (4).
Listing impossible valuesSaying X can be 0 when n = 6 is drawn from 8 successes and 4 failuresAt least n − (N − K) = 2 successes must be drawn.
Leaving out the correction factorVar(X) = 4(1/4)(3/4) = 0.75 in Example 3Multiply by (N − n)/(N − 1) = 16/19.

Related methods

The binomial as a limit

If N is large compared with n, removing a few items barely changes the proportion K/N. Then the hypergeometric probabilities are close to the binomial probabilities with p = K/N, and the correction factor (N − n)/(N − 1) is close to 1.

Why the probabilities add to 1

Summing the numerators over all k counts every sample of n items once, sorted by how many successes it has. This gives Vandermonde’s identity, Σ C(K, k)C(N − K, n − k) = C(N, n), so the probabilities add to C(N, n)/C(N, n) = 1.

Estimating a population size

Capture-recapture, as in Example 4, uses the hypergeometric model in reverse. The value of N that makes the observed count most likely is close to Kn/k, the Lincoln-Petersen estimate.

Practice problems

  1. A bag has 10 marbles: 4 red and 6 white. Draw 3 without replacement. Find P(X = 2), where X is the number of red marbles.
  2. In Problem 1, find P(X = 0).
  3. In Problem 1, find the mean and variance of X.
  4. A 13-card bridge hand is dealt from a standard deck. Find the probability that it has exactly 2 aces.
  5. A jury of 6 is chosen at random from a pool of 30 people, 12 of whom are women. Find the probability that the jury has no women.
  6. In a 6/49 lottery, X is the number of your 6 numbers that are drawn. Find E(X).
  7. N = 12, K = 8 and n = 6. List the possible values of X.
  8. For N = 6, K = 2 and n = 3, show that the hypergeometric probabilities add to 1.
  9. A lot of 100 parts has 5 defective parts. Ten parts are tested. Find the probability that at least one is defective.
  10. A survey samples 50 people from a town of 1000 without replacement. Find the finite population correction factor.
Show answers

1.

\binom{4}{2}\binom{6}{1} = 6 \cdot 6 = 36

Choose 2 red and 1 white.

\binom{10}{3} = 120

Count all samples.

P(X = 2) = \dfrac{36}{120} = \dfrac{3}{10}

Divide, then simplify.

Answer: 3/10

2.

P(X = 0) = \dfrac{\binom{4}{0}\binom{6}{3}}{\binom{10}{3}} = \dfrac{1 \cdot 20}{120}

All 3 marbles are white.

P(X = 0) = \dfrac{1}{6}

Simplify.

Answer: 1/6

3.

E(X) = 3 \cdot \dfrac{4}{10} = 1.2

Mean formula.

\operatorname{Var}(X) = 3(0.4)(0.6)\dfrac{10 - 3}{10 - 1} = 0.72 \cdot \dfrac{7}{9}

Variance formula; 3(0.4)(0.6) = 0.72.

\operatorname{Var}(X) = 0.56

Multiply.

Answer: mean 1.2, variance 0.56

4.

P(X = 2) = \dfrac{\binom{4}{2}\binom{48}{11}}{\binom{52}{13}}

N = 52, K = 4 aces, n = 13, k = 2.

P(X = 2) = \dfrac{6 \cdot 22{,}595{,}200{,}368}{635{,}013{,}559{,}600} \approx 0.2135

Use a calculator for the large combinations.

Answer: about 0.2135

5.

\binom{18}{6} = 18{,}564,\quad \binom{30}{6} = 593{,}775

All 6 jurors come from the 18 men.

P(X = 0) = \dfrac{18{,}564}{593{,}775} \approx 0.0313

Divide.

Answer: about 0.0313

6.

E(X) = 6 \cdot \dfrac{6}{49} = \dfrac{36}{49} \approx 0.735

N = 49, K = 6 drawn numbers, n = 6 numbers on your ticket.

Answer: 36/49 ≈ 0.735

7.

\max(0,\ 6 - 4) = 2,\quad \min(6,\ 8) = 6

N − K = 4 failures, so at least 2 successes must be drawn.

Answer: X = 2, 3, 4, 5 or 6

8.

\binom{2}{0}\binom{4}{3} + \binom{2}{1}\binom{4}{2} + \binom{2}{2}\binom{4}{1} = 4 + 12 + 4 = 20

Numerators for k = 0, 1, 2.

\binom{6}{3} = 20

Denominator.

Answer: the probabilities are 4/20, 12/20 and 4/20, which add to 20/20 = 1

9.

P(X = 0) = \dfrac{\binom{95}{10}}{\binom{100}{10}} \approx 0.5838

All 10 parts come from the 95 good parts; use a calculator.

P(X \ge 1) = 1 - 0.5838 = 0.4162

Complement rule.

Answer: about 0.4162

10.

\dfrac{N - n}{N - 1} = \dfrac{1000 - 50}{1000 - 1} = \dfrac{950}{999} \approx 0.951

Substitute N = 1000 and n = 50.

Answer: about 0.951, so the variance is about 5% smaller than the binomial variance

Hypergeometric distribution FAQ

When do you use the hypergeometric distribution?

Use it when you draw a fixed number of items without replacement from a finite population with two kinds of items, and you count how many of one kind you get. Card hands, lottery draws and quality inspections are common examples.

What is the difference between the binomial and hypergeometric distributions?

The binomial assumes independent trials with a constant success probability, as when sampling with replacement. The hypergeometric is for sampling without replacement, where each draw changes the chances for the next one.

What is the mean of a hypergeometric distribution?

The mean is nK/N, the sample size times the fraction of successes in the population. It matches the binomial mean with p = K/N, but the variance is smaller by the factor (N − n)/(N − 1).

When can you use the binomial to approximate the hypergeometric distribution?

When the sample is small compared with the population, usually less than 5% of it. Then removing items hardly changes the proportion of successes.

Summary

  • The hypergeometric distribution counts successes in n draws without replacement from N items with K successes.
  • P(X = k) = C(K, k)C(N − K, n − k)/C(N, n).
  • E(X) = nK/N, and Var(X) = n(K/N)(1 − K/N)(N − n)/(N − 1).
  • The finite population correction makes the variance smaller than the binomial variance.
  • When n is a small fraction of N, the binomial with p = K/N is a good approximation.

Previous lesson: Poisson Distribution

Next lesson: Negative Binomial Distribution

Back to the Probability Theory Index