WordGPT

Hypergeometric distribution

Hypergeometric distribution: successes in a sample drawn without replacement. With the default parameters (population size N = 50, successes in the population K = 20, sample size n = 10) its mean is 4 and its standard deviation 1.3997. Use the simulator below to draw samples and see it take shape.

Simulate it

Change the parameters, then draw random samples. The bars are the samples; the dots are the exact probabilities. With more samples the bars settle onto it.

Samples to draw

00.10.20.30246810x
Mean
sample - ยท exact 4
Standard deviation
sample - ยท exact 1.4

What is the hypergeometric distribution?

The hypergeometric distribution counts the successes in a sample of n items drawn without replacement from a finite population of N items, K of which are successes. How many hearts in a five-card hand? How many defective parts in a sample of 10 taken from a lot of 50 that contains 20?

Because each draw changes what is left, the draws are not independent, and that is exactly what distinguishes it from the binomial. When the population is much larger than the sample the difference is tiny and the binomial is a good approximation.

Where it is used

  • Hearts (or aces) in a poker hand.
  • Defective items in a sample drawn from a small lot without replacement.
  • Matching numbers in a lottery draw.
  • Tagged animals recaptured in a second sample (capture and recapture).
  • Women on a committee chosen at random from a group.

Shape and parameters

The distribution is centred on nK/N. Its variance is the binomial variance multiplied by the finite population correction (N โˆ’ n)/(N โˆ’ 1), which is smaller than 1: sampling without replacement is less variable than sampling with replacement.

What it assumes

  • A finite population of N items with exactly K successes.
  • n items drawn at random without replacement.

How it relates to other distributions

  • Binomial distribution: Sampling with replacement (or from a very large population) gives the binomial.
  • Poisson distribution: Further limits lead to the Poisson.

Common mistakes

  • Using the binomial when the sample is a large share of the population.
  • Mixing up the order of the parameters: software packages list N, K and n in different orders.

How to work it out

  1. 1

    The probability mass function (the formula that gives the shape):

    P(X=k)=(Kk)(Nโˆ’Knโˆ’k)(Nn)P(X=k)=\frac{\binom{K}{k}\binom{N-K}{n-k}}{\binom{N}{n}}
  2. 2

    Its mean (the long-run average) and variance (the spread):

    ฮผ=nKN,ฯƒ2=nKN(1โˆ’KN)Nโˆ’nNโˆ’1\mu = \frac{nK}{N},\qquad \sigma^2 = n\frac{K}{N}\left(1-\frac{K}{N}\right)\frac{N-n}{N-1}
  3. 3

    Worked example with the default parameters (population size N = 50, successes in the population K = 20, sample size n = 10): A lot of 50 items has 20 defective ones. A sample of 10 is drawn. What is the probability of exactly 5 defective items in the sample?

    answer=0.2151\text{answer} = 0.2151
LaTeX source of the formulas on this page
\[ P(X=k)=\frac{\binom{K}{k}\binom{N-K}{n-k}}{\binom{N}{n}} \]
\[ \mu = \frac{nK}{N},\qquad \sigma^2 = n\frac{K}{N}\left(1-\frac{K}{N}\right)\frac{N-n}{N-1} \]
\[ \text{answer} = 0.2151 \]

At a glance

PropertyValue
TypeDiscrete (counts)
Parameterspopulation size N; successes in the population K; sample size n
Possible valuesmax(0, n โˆ’ (N โˆ’ K)) to min(n, K)
Mean4
Variance1.9592
Standard deviation1.3997
Example (population size N = 50, successes in the population K = 20, sample size n = 10)A lot of 50 items has 20 defective ones. A sample of 10 is drawn. What is the probability of exactly 5 defective items in the sample? Answer: 0.2151.

How to compute it in Excel, Python and R

ToolFunction
Excel / Google Sheets=HYPGEOM.DIST(k, n, K, N, FALSE)
Python (SciPy)scipy.stats.hypergeom.pmf(k, N, K, n)
Rdhyper(k, K, N - K, n)

Questions

What is the hypergeometric distribution used for?

Successes in a sample drawn without replacement. Typical uses: Hearts (or aces) in a poker hand. Defective items in a sample drawn from a small lot without replacement. Matching numbers in a lottery draw.

What are the mean and variance of the hypergeometric distribution?

Mean: ฮผ = (nK)/(N). Variance: ฯƒยฒ = n(K)/(N)(1-(K)/(N))(N-n)/(N-1).

What does the hypergeometric distribution assume?

A finite population of N items with exactly K successes. n items drawn at random without replacement.

How do I calculate it in Excel?

=HYPGEOM.DIST(k, n, K, N, FALSE)

How is the hypergeometric distribution related to other distributions?

Binomial distribution: Sampling with replacement (or from a very large population) gives the binomial. Poisson distribution: Further limits lead to the Poisson.

Related distributions

Choosing a distribution

    Hypergeometric distribution: what it is, when to use it, formulas and simulator | WordGPT