A sample drawn from a fixed batch does not consist of independent repeated opportunities when selected items are kept out of the batch. Each draw changes what remains. The hypergeometric distribution tracks the resulting count of marked items across the whole sample.
For a robot inspection example, this is a probability model for a specified finite population. It is not an acceptance plan or a claim that an uninspected production batch contains a known defect count. Fixing the population composition is an assumption that makes the original calculation below possible.
Define one small population
Invent twelve distinct items, exactly four marked and eight unmarked. Draw three different items uniformly without replacement, and let X be the number of marked items selected.
Use N = twelve for population size, K = four for total marked items, and n = three for sample size. These symbols are defined here because official software manuals use different letters for the same roles.
Every unordered three-item subset is equally likely under the model. There are choose(12, 3) = 220 such subsets. The outcomes being counted are subsets of distinct items, not merely sequences of marked and unmarked labels.
SciPy and R give the combinatorial probability formula. In this notation, P(X = k) = choose(K, k) choose(N - K, n - k) divided by choose(N, n). The numerator counts the ways to select k marked items and the remaining n - k from the unmarked group.
Build the complete count table
For X = zero, choose none of the four marked items and three of the eight unmarked items. There are 56 subsets, so probability is 56/220, approximately 0.254545.
For X = one, choose one of four and two of eight. The count is 4 times 28 = 112 subsets, giving probability 112/220, approximately 0.509091.
For X = two, choose two of four and one of eight. There are 6 times 8 = 48 subsets, giving probability 48/220, approximately 0.218182.
For X = three, choose three of four and no unmarked items. There are four subsets, giving probability 4/220, approximately 0.018182.
The counts sum to 56 + 112 + 48 + 4 = 220, checking normalization. The distribution is more informative than one tail probability: it states how all four possible marked counts divide the sample space.
Calculate the first two moments from the table
The weighted count total is zero times 56 plus one times 112 plus two times 48 plus three times four. Dividing the result, 220, by 220 gives E[X] = one marked item.
The weighted squared-count total is 112 + 4 times 48 + 9 times four = 340. Thus E[X squared] = 340/220 = 17/11.
Variance is E[X squared] minus E[X] squared, giving 17/11 - 1 = 6/11, approximately 0.545455. This is a variance in squared-count units, not a probability of observing a defect or the fraction of the batch that is marked.
Compare an independent-draw model
If each of three draws instead had an independent marked probability p = four/twelve = one third, the count would be binomial. Its mean would still be np = one, but its variance would be np(1 - p) = two thirds, approximately 0.666667.
Its probability of exactly one marked result would be choose(3, 1) times one third times two thirds squared, or four ninths, approximately 0.444444. That differs from the finite-batch value of approximately 0.509091 despite the identical expected count.
Matching means therefore does not establish matching count distributions. The replacement rule changes dependence between draws, which changes the spread and individual probabilities.
See the dependence directly
Before any item is drawn, marked probability is four/twelve. If the first selected item is marked, the next draw sees three marked among eleven remaining items, so its marked probability is three elevenths.
If the first is unmarked, the next sees four marked among eleven, giving four elevenths. Neither conditional probability is the original one third. After selecting a marked item, fewer marked opportunities remain.
Conditional expected marked count in the two draws still to come is therefore 2 times three/eleven = six elevenths after a marked first draw. After an unmarked first draw, it is eight elevenths. These are expectations over future samples with the stated remaining composition, not fractional physical items.
Derive the finite-population correction
Let Ij indicate whether draw j is marked. Each has marginal mean p, even though draws are dependent. For two different positions, the probability both are marked is K(K - 1)/[N(N - 1)].
Subtract p squared to obtain covariance -p(1 - p)/(N - 1). In the twelve-item example, that is -2/99. The negative sign expresses the without-replacement competition visible in the conditional probabilities.
Since X is the sum of n indicators, its variance is n p(1 - p) plus n(n - 1) copies of that covariance. Simplifying gives n p(1 - p)(N - n)/(N - 1).
Here the correction factor is nine elevenths. Multiplying the binomial variance two thirds by nine elevenths returns six elevenths, matching the full table.
Check what happens at the sampling limits
For one draw, the correction factor equals one and the marked indicator has variance p(1 - p). If every item is selected, n = N and the correction factor is zero. The final marked count must equal the fixed K, so it has no random variation.
An independent binomial approximation is closest when the sample consumes a small share of a sufficiently large population. It does not become exact merely because the marked proportion is known. The sample fraction and the question being asked still matter.
All subsets, moments, and conditional calculations here were independently checked as arithmetic. No parts were inspected and no statistical library was executed. Inferring an unknown K from data or selecting a production sampling policy would be a separate task.
Sources checked October 24, 2026: SciPy1.18.0, hypergeom: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.hypergeom.html
R stats4.6.0 online manual, Hypergeometric: https://stat.ethz.ch/R-manual/R-devel/library/stats/html/Hypergeometric.html
Illustration note: A generic inspection or bin-of-parts robot image is a concept illustration. It does not show the invented batch, measured defects, or a validated sampling result.