Hypergeometric Distribution Calculator

Sampling without replacement.

Examples:
P(X = 2)
0.27428
Expected Value E[X]
1.25
Std Deviation Οƒ
0.9295
Valid k range
[0, 5]
0123450.0e+00.150.300.450.60

Interpretation

Drawing {5} items from a population of {52} (containing {13} successes), the probability of getting {exactly} {2} success(es) is {27.428}%.

Hypergeometric PMF
P(X=k)=(Kk)(Nβˆ’Knβˆ’k)(Nn)P(X = k) = \frac{\binom{K}{k}\binom{N-K}{n-k}}{\binom{N}{n}}

What Is the Hypergeometric Distribution?

The hypergeometric distribution models the probability of drawing a specific number of successes when sampling without replacement from a finite population. Unlike the binomial distribution, which assumes independent trials with constant probability, the hypergeometric distribution accounts for how each draw changes the composition of the remaining population.

Classic example: Drawing cards from a deck. Once you draw an ace, there are fewer aces (and fewer total cards) remaining, affecting subsequent draw probabilities.

The Setup

Consider a population of NN items:

  • KK items are "successes" (the type you're counting)
  • Nβˆ’KN - K items are "failures"

You draw nn items without replacement. The hypergeometric distribution gives the probability of getting exactly kk successes.

The Formula

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

Where:

  • (Kk)\binom{K}{k} = ways to choose kk successes from KK available
  • (Nβˆ’Knβˆ’k)\binom{N-K}{n-k} = ways to choose remaining items from non-successes
  • (Nn)\binom{N}{n} = total ways to choose nn items from NN

Valid Range for k

The number of successes kk must satisfy:

max⁑(0,nβˆ’(Nβˆ’K))≀k≀min⁑(n,K)\max(0, n - (N - K)) \leq k \leq \min(n, K)

You can't draw more successes than exist (k≀Kk \leq K), more than you draw (k≀nk \leq n), or fewer than forced by having too few failures (kβ‰₯nβˆ’(Nβˆ’K)k \geq n - (N - K)).

Key Statistics

  • Mean: E[X]=nβ‹…KNE[X] = n \cdot \frac{K}{N}
  • Variance: Var(X)=nβ‹…KNβ‹…Nβˆ’KNβ‹…Nβˆ’nNβˆ’1Var(X) = n \cdot \frac{K}{N} \cdot \frac{N-K}{N} \cdot \frac{N-n}{N-1}

The variance formula includes the finite population correction factor Nβˆ’nNβˆ’1\frac{N-n}{N-1}, which reduces variance compared to binomial sampling.

Practical Applications

Quality Control

A shipment contains 100 parts, 10 of which are defective. If an inspector samples 20 parts without replacement, what's the probability of finding exactly 3 defective?

P(X=3)=(103)(9017)(10020)β‰ˆ0.211P(X = 3) = \frac{\binom{10}{3} \binom{90}{17}}{\binom{100}{20}} \approx 0.211

This is more accurate than binomial approximation for small populations.

Card Games

Probability of being dealt exactly 2 hearts in a 5-card poker hand:

P(X=2)=(132)(393)(525)=78Γ—91392598960β‰ˆ0.274P(X = 2) = \frac{\binom{13}{2} \binom{39}{3}}{\binom{52}{5}} = \frac{78 \times 9139}{2598960} \approx 0.274

Ecological Studies

Capture-recapture methods estimate population sizes using hypergeometric reasoning. If researchers tagged 50 fish, then later caught 30 fish (of which 10 were tagged), they can estimate total population.

Lottery Analysis

Lottery probability calculations often involve hypergeometric distributions, especially for games where you select numbers from a fixed pool without replacement.

Auditing

When auditing a sample of transactions for errors, the hypergeometric distribution properly models finding errors in the sample given a finite population of transactions.

Hypergeometric vs. Binomial

AspectHypergeometricBinomial
SamplingWithout replacementWith replacement
ProbabilityChanges each drawConstant
PopulationFinite, mattersInfinite/large
IndependenceDraws dependentDraws independent

When to use binomial approximation: When n<0.05Nn < 0.05N (sample is less than 5% of population), binomial closely approximates hypergeometric and is computationally simpler.

Fisher's Exact Test Connection

Fisher's exact test for 2Γ—2 contingency tables is based on the hypergeometric distribution. It tests whether two categorical variables are independent by computing hypergeometric probabilities.

Multivariate Hypergeometric

The distribution extends to multiple categories. If a population has items of types 1, 2, ..., mm with counts K1,K2,...,KmK_1, K_2, ..., K_m:

P(X1=k1,...,Xm=km)=∏i=1m(Kiki)(Nn)P(X_1 = k_1, ..., X_m = k_m) = \frac{\prod_{i=1}^{m} \binom{K_i}{k_i}}{\binom{N}{n}}

This models scenarios like drawing cards of multiple suits or sampling items of multiple types.

Computational Considerations

For large populations, direct calculation of factorials leads to overflow. Use:

  • Log-factorial calculations: log⁑(n!)=βˆ‘i=1nlog⁑(i)\log(n!) = \sum_{i=1}^{n} \log(i)
  • Recursive relationships
  • Stirling's approximation for very large values

Related Calculations

Summary

The hypergeometric distribution is essential when sampling without replacement from a finite populationβ€”situations where each selection genuinely affects subsequent probabilities. From quality control inspections to card game odds to ecological population estimates, it provides exact probabilities that binomial approximations miss. While computationally more intensive, modern tools handle the calculations easily, making hypergeometric analysis accessible for practical applications.