Skip to main content

Hypergeometric Distribution Calculator

Exact probabilities for sampling without replacement: P(X = k), P(X ≤ k), P(X ≥ k), P(X < k), P(X > k), mean and variance — computed in your browser with overflow-safe math, no server involved.

Inputs

How the math works

P(X = k) = C(K, k) · C(N−K, n−k) / C(N, n)
μ = nK / N   ·   σ² = n · (K/N) · ((N−K)/N) · ((N−n)/(N−1))

The last variance factor, (N−n)/(N−1), is the finite population correction: it shrinks the variance because draws without replacement are negatively correlated. This calculator evaluates P(X = k) as an interleaved product of exact ratios (never naïve factorials), so even N = 1,000,000 cannot overflow.

Worked examples

🂡 5-card poker hand

N = 52, K = 13 hearts, n = 5, k = 2

P(X = 2) = 9139/33320 ≈ 27.427971%

Mean 1.25 hearts · P(X ≤ 2) ≈ 90.723289%

🎰 Lottery 6/49 jackpot

N = 49, K = 6, n = 6, k = 6

P(X = 6) = 1/13983816 ≈ 1 in 13,983,816

Expected matches per ticket ≈ 0.7346938775510204

🏭 QC batch sampling

N = 500, K = 25 defectives, n = 30, k = 1

P(X = 1) ≈ 34.411798%

Mean 1.5 · SD ≈ 1.1585268096757515

Frequently asked questions

What is the hypergeometric distribution?
The hypergeometric distribution gives the probability of drawing exactly k successes in n draws made without replacement from a finite population of size N that contains K successes. Its probability mass function is P(X = k) = C(K,k) × C(N−K,n−k) / C(N,n), where C(a,b) is the binomial coefficient. Use it for card hands, lottery draws, and quality-control sampling — anywhere each draw changes the odds because items are not put back.
What is the probability of getting exactly 2 hearts in a 5-card poker hand?
Treat hearts as successes: N = 52 cards, K = 13 hearts, n = 5 drawn, k = 2 observed. P(X = 2) = C(13,2) × C(39,3) / C(52,5) = 9139/33320 ≈ 0.2742797118847539, about 27.427971%. The mean is nK/N = 1.25 hearts and P(X ≤ 2) = 0.9072328931572629.
What are the odds of winning a 6/49 lottery jackpot?
A 6/49 lottery draws n = 6 balls from N = 49 with K = 6 winning balls. Matching all 6 (k = 6) has probability P(X = 6) = 1 / C(49,6) = 1/13983816 ≈ 7.151123842018516e-08, exactly 1 in 13,983,816. The expected number of matches per ticket is nK/N = 36/49 ≈ 0.7346938775510204.
When can I use the binomial distribution instead of the hypergeometric?
When the sample is a tiny fraction of the population — the usual rule is n/N ≤ 5% — sampling without replacement barely changes the odds, so the binomial with p = K/N is a fine approximation. Example: N = 100000, K = 20000, n = 20, k = 5. Hypergeometric P(X = 5) = 0.17457479735358877, binomial(20, 0.2) gives 0.17455952155688043, a relative difference of only 0.00875%. This calculator shows the comparison automatically when n/N ≤ 0.05.
How is the hypergeometric distribution used in quality control sampling?
QC inspectors sample n items from a batch of N and count defectives. Example: a batch of N = 500 with K = 25 defectives, sample n = 30. The probability of finding exactly k = 1 defective is P(X = 1) ≈ 0.3441179773040583 (34.411798%). The expected count is nK/N = 1.5 with standard deviation ≈ 1.1585268096757515. Acceptance-sampling plans use P(X ≤ c) — computed in the results table above — to decide whether to accept the batch.
What are the mean and variance of the hypergeometric distribution?
Mean μ = nK/N. Variance σ² = n × (K/N) × ((N−K)/N) × ((N−n)/(N−1)), where the last factor (N−n)/(N−1) is the finite population correction. Example: N = 20, K = 8, n = 6 gives μ = 2.4, σ² = 1.0610526315789475, σ ≈ 1.0300740903347425. As N grows large relative to n, the correction approaches 1 and the variance approaches the binomial value np(1−p).
What values can k take?
k must satisfy max(0, n − (N−K)) ≤ k ≤ min(n, K). You cannot draw more successes than exist (k ≤ K) or than you draw (k ≤ n), and if the draw is large relative to the failures you are forced to include successes: with N = 52, K = 13 hearts, n = 5, k ranges from 0 to 5. Values outside this range have probability exactly 0, which the calculator reports instead of erroring.
Why does “without replacement” matter?
Because each draw changes the composition of what remains. After drawing one heart from a 52-card deck, 12 hearts remain out of 51 cards — the probability shifts every draw. Ignoring this and using the binomial anyway overstates the variance: for the 5-card hearts example the true variance is 0.8639705882352942 (finite population correction 47/51), versus 0.9375 under the binomial. For large populations relative to the sample the difference vanishes.

Free tool by NRTechStudio