acalculator

Hypergeometric: how likely is k?

Type the population size, how many of them count as successes, how many you draw and the successes you want. The hypergeometric calculator gives the exact probability and every tail.

Your numbers

P(X = k)
0.27428

Drawing 5 from 52 with 13 successes, the chance of exactly 2 successes is 0.27428, and of at least 2 is 0.367047.

P(X < k)
0.632953
P(X ≤ k)
0.907233
P(X > k)
0.092767
P(X ≥ k)
0.367047
Mean (nK ÷ N)
1.25
Variance
0.863971
Standard deviation
0.9295

P(X = k): 0.27428. Drawing 5 from 52 with 13 successes, the chance of exactly 2 successes is 0.27428, and of at least 2 is 0.367047.

How likely is each number of successes?

How to calculate

Computes exact hypergeometric probabilities P(X = k), P(X < k), P(X ≤ k), P(X > k) and P(X ≥ k) for n draws without replacement from N items with K successes, with the mean and standard deviation.

Example with the default inputs (Population size (N) 52, Successes in the population (K) 13, Sample size (n) 5, Successes in the sample (k) 2): Drawing 5 from 52 with 13 successes, the chance of exactly 2 successes is 0.27428, and of at least 2 is 0.367047.

Method: P(X = k) = C(K, k) × C(N − K, n − k) ÷ C(N, n); P(X ≤ k) = Σ P(X = j) for j ≤ k; mean = nK ÷ N; variance = n (K ÷ N)((N − K) ÷ N)((N − n) ÷ (N − 1)).

  • The n items are drawn at random without putting any back, so every set of n items is equally likely.
  • Each item is either a success or not, and the population size N and successes K are known.

Machine-readable copies: Markdown, JSON.

Worked examples

Each example is checked against the calculator on every build.

  1. Population size (N) 52, Successes in the population (K) 13, Sample size (n) 5, Successes in the sample (k) 2 gives P(X = k) 0.27428, Mean (nK ÷ N) 1.25.Source: NIST/SEMATECH e-Handbook of Statistical Methods, glossary: hypergeometric distribution (sampling without replacement; population N, sample n, defectives D), https://www.itl.nist.gov/div898/handbook/glossary.htm
  2. Population size (N) 49, Successes in the population (K) 6, Sample size (n) 6, Successes in the sample (k) 6 gives P(X = k) 0, P(X ≤ k) 1, P(X < k) 1.Source: NIST/SEMATECH e-Handbook of Statistical Methods, glossary: hypergeometric distribution (sampling without replacement; population N, sample n, defectives D), https://www.itl.nist.gov/div898/handbook/glossary.htm
  3. Population size (N) 100, Successes in the population (K) 10, Sample size (n) 10, Successes in the sample (k) 0 gives P(X = k) 0.330476, P(X ≥ k) 1, P(X > k) 0.669524, Mean (nK ÷ N) 1, Variance 0.818182.Source: NIST/SEMATECH e-Handbook of Statistical Methods, glossary: hypergeometric distribution (sampling without replacement; population N, sample n, defectives D), https://www.itl.nist.gov/div898/handbook/glossary.htm
  4. Population size (N) 10, Successes in the population (K) 3, Sample size (n) 4, Successes in the sample (k) 3 gives P(X = k) 0.033333, P(X ≥ k) 0.033333, P(X < k) 0.966667.Source: NIST/SEMATECH e-Handbook of Statistical Methods, glossary: hypergeometric distribution (sampling without replacement; population N, sample n, defectives D), https://www.itl.nist.gov/div898/handbook/glossary.htm

How it works

A population of N items holds K successes. You draw n items at random without putting any back. X is the number of successes in the sample.

  • P(X = k) = C(K, k) × C(N − K, n − k) ÷ C(N, n), where C(a, b) = a! ÷ (b! (a − b)!).
  • X can only be from max(0, n − (N − K)) to min(n, K); outside that range P(X = k) = 0.
  • P(X ≤ k) = the sum of P(X = j) for j ≤ k; P(X < k) = P(X ≤ k) − P(X = k); P(X > k) = 1 − P(X ≤ k); P(X ≥ k) = 1 − P(X < k).
  • Mean = n × K ÷ N. Variance = n × (K ÷ N) × ((N − K) ÷ N) × ((N − n) ÷ (N − 1)), and 0 when N = 1. Standard deviation = √variance.

Rules. N is a whole number from 1 to 1,000; K, n and k are whole numbers with 0 ≤ K ≤ N, 1 ≤ n ≤ N and 0 ≤ k ≤ n. K above N, n above N, or k above n gives no answer with a message. A k above K is allowed and has probability 0.

Exact arithmetic. The page works out every C(K, j) × C(N − K, n − j) as a whole number; they add up to C(N, n). Each probability is one exact fraction of whole numbers, rounded once to the nearest double, so far tails keep their digits. The mean and variance are exact fractions too, rounded once; the standard deviation is the square root of the rounded variance.

Output format. Decimals and significant figures below are the most shown; trailing zeros are dropped (23.0 shows as 23, money keeps its cents). Probabilities and moments show at most 6 decimals; a value below 0.0001 shows 6 significant figures instead. Each is rounded half up from its decimal value.

The chart draws P(X = j) for every possible count j, joined by straight lines, with k marked.

Worked examples by hand

Two hearts in a poker hand. C(13, 2) = 78, C(39, 3) = 9,139, C(52, 5) = 2,598,960. P(X = 2) = 712,842 ÷ 2,598,960 = 9,139 ÷ 33,320 = 0.274280. Mean 5 × 13 ÷ 52 = 1.25.

A 6-from-49 jackpot. C(49, 6) = 13,983,816, so P(X = 6) = 1 ÷ 13,983,816 = 0.0000000715112; P(X ≤ 6) = 1.

An inspection lot. N = 100 with K = 10 defective; sample n = 10. P(X = 0) = C(90, 10) ÷ C(100, 10) = 0.330476; mean 1; variance 10 × 0.1 × 0.9 × 90 ÷ 99 = 0.818182.

An urn. 10 balls, 3 red, draw 4. P(all 3 reds) = C(3, 3) × C(7, 1) ÷ C(10, 4) = 7 ÷ 210 = 0.033333.

Other questions people ask

What is the hypergeometric distribution?

It counts successes when you draw without putting items back, so each draw changes the odds of the next. NIST’s e-Handbook describes it as the model for the count of defectives when sampling without replacement, with population N, sample n and D defectives.

What is the hypergeometric formula?

P(X = k) = C(K, k) × C(N − K, n − k) ÷ C(N, n): the ways to pick k of the K successes, times the ways to fill the rest of the sample from the N − K others, over all the ways to pick n items.

What is the chance of 2 hearts in a 5-card poker hand?

With N = 52, K = 13, n = 5 and k = 2: C(13, 2) × C(39, 3) ÷ C(52, 5) = 78 × 9,139 ÷ 2,598,960 = 0.2743, about 27.4%.

When should I use the hypergeometric instead of the binomial?

Use the hypergeometric when you sample without replacement from a small population, such as cards, a lottery or an inspection lot. The binomial assumes each trial has the same chance, which is true with replacement, and close enough when the sample is a small part of a large population.

What are the odds of winning a 6-from-49 lottery?

Matching all six numbers is P(X = 6) with N = 49, K = 6 and n = 6: 1 ÷ C(49, 6) = 1 in 13,983,816.

What are the mean and variance?

The mean is n × K ÷ N. The variance is n × (K ÷ N) × ((N − K) ÷ N) × ((N − n) ÷ (N − 1)); the last factor, the finite population correction, makes it smaller than the binomial variance.