How this calculation works
All samples of the chosen size are equally likely. Select k success items and n−k other items, then divide by the number of possible samples. The result also shows the feasible success-count range and the expected sample count.
P(X = k) = C(K,k) C(N−K,n−k) ÷ C(N,n)A worked example
From 20 items containing 7 labeled successes, a random sample of 5 has about a 38.738390% chance of containing exactly 2 successes.
Good to know
A mathematical probability model, not a fit test or an empirical guarantee. Inputs must match the model assumptions. Floating-point arithmetic is used; extremely small probabilities may underflow or round to zero.
Reference: Emory University: hypergeometric formula (opens in a new tab) ↗
Removing an item changes the next draw
Suppose a box has twenty components and seven carry a particular label. Taking five without putting them back changes the composition of the remaining box after each draw. Treating all five draws as independent with the original 7/20 probability ignores that change.
The hypergeometric calculation works by counting equally likely samples. The order of the five selected items does not matter for the requested success count. A success is just the label you choose to count; it need not mean that the item is desirable.
Sampling without replacement also creates hard constraints. If there are only two success items in the population, a sample cannot contain three successes. If you sample almost the entire population, you may be forced to include some success items even when asking for zero.
Read the feasible range before interpreting a zero
The minimum possible count is the sample size minus the available non-success items, with zero as a lower limit. The maximum is the smaller of the sample size and the number of success items. A request outside those bounds has probability zero for a structural reason.
The expected count is nK/N, which may be fractional. An expectation of 1.75 is an average over repeated samples, not a claim that one physical sample contains a fraction of an item.
Uniform sampling matters. If some items are more likely to be selected because of placement, size or a selection policy, the combinatorial calculation may not represent the actual sampling process. The calculator cannot infer those selection probabilities from a population total.
A few questions, answered
What if the sample size is zero?
The empty sample has zero successes with probability one. Any positive requested count has probability zero.
What if all population items are successes?
The success count equals the sample size with probability one. Other counts are impossible.
What are the input limits?
Population size and item counts are bounded at 100,000; the sample size is limited to 10,000. The number of success items and the sample must not exceed the population.