12 / Distributions
Hypergeometric distribution: sampling a finite lot
The hypergeometric distribution models successes in a sample from a finite population with a stated composition. It accounts for the fact that each sampled item changes what remains in the lot.
The business question
What is the chance a sample finds a defect when items are drawn without replacement?
- Evaluate how likely a lot-inspection sample is to detect at least one defective item at a proposed lot composition.
- Design operating-characteristic comparisons for acceptance-sampling plans.
- Analyse finite audit samples when objects are not returned to the population between draws.
How the method works
Identify the finite population size N, the number K of items with the counted property, and the sample size n. A random sample without replacement has dependent draws: after taking one defective item, there are fewer defective items left. The hypergeometric model counts the number of possible samples with a given composition and compares that count with all possible samples of size n.
The numerator chooses k counted items from the K available and n − k other items from the N − K remaining class. The denominator chooses any n items from the full lot. The feasible count range depends on all three totals. Its mean is nK/N, while its variance includes a finite-population correction relative to an independent-binomial approximation.
In real acceptance sampling the exact number of defects in a lot is usually unknown. Evaluate detection or acceptance probabilities under several proposed K values to understand a plan, instead of pretending that the scenario composition is observed truth. Finding no defects in a small sample does not establish that the lot is defect-free, and a sample acceptance rule should reflect the consequences of both accepting a bad lot and rejecting an acceptable one.
The calculation
| Symbol | Meaning |
|---|---|
| N | Total number of items in the finite lot. |
| K | Number with the counted property under the specified lot scenario. |
| n | Sample size drawn randomly without replacement. |
| X | Counted-property items found in the sample. |
A worked business example
ILLUSTRATIVE SCENARIO
Illustrative warehouse compares a ten-item inspection with a lot of one hundred items. For this scenario calculation, suppose exactly eight items are defective. The aim is to understand detection probability, not to claim that eight is known in a live lot.
Inputs
- Lot size N = 100; scenario defects K = 8.
- Random sample n = 10 without replacement.
- Detection means observing at least one defective item.
Work through the numbers
- The expected number of defects in the sample is 10 × 8/100 = 0.8.
- The probability of no defects is C(8,0) × C(92,10)/C(100,10) = 0.4165533.
- Detection probability is P(X ≥ 1) = 1 − 0.4165533 = 0.5834467.
- Therefore, even a lot with eight defects can pass a zero-defects-observed sample with probability about 41.66% under this plan.
This sample is a limited detector for the stated lot composition. Increasing the sample, changing the acceptance threshold or adding process evidence may be needed if the consequence of accepting such a lot is unacceptable.
Explore the decision
Sample a finite lot without replacement. The live explorer has its own example inputs; it is separate from the worked calculation above.
Enable JavaScript to use this calculator. The worked example and executable Python remain available.
Apply it at work
- Specify the lot, counted property, sampling method and acceptance or detection rule.
- Choose several plausible lot compositions rather than treating an unknown defect count as certain.
- Calculate detection or acceptance probabilities for each proposed plan and composition.
- Compare inspection cost and error consequences, then implement random selection and preserve the inspection records.
Check these assumptions
- The lot is finite, with a fixed composition during sampling.
- Sampling is genuinely random without replacement, not a convenient selection of accessible items.
- Classification is accurate or inspection errors are modelled separately.
- The example’s K = 8 is a scenario input; it is not inferred from a ten-item sample.
Common mistakes and how to avoid them
- Sampling only from the top of a pallet can invalidate the random-lot interpretation.
- Using a binomial model ignores depletion when the sample is a substantial fraction of the lot.
- No detected defects does not mean no defects exist in the uninspected items.
How this can help the business
- Sampling effort can be related to the risk of missing an unacceptable lot rather than an arbitrary inspection percentage.
- A warehouse can compare the cost of additional inspection with the operating consequences of false acceptance and false rejection.
Choose an acceptance-sampling plan using its performance across relevant lot compositions and the business consequences of each decision error.
When to use another approach
Use a binomial approximation only when sampling depletion is negligible, or a full inspection when feasible and justified by the consequences.
Reproduce the worked example in Python
The code is self-contained for this example. Dependencies and run instructions are included with the downloadable notebook.
Show executable code and recorded output
from scipy.stats import hypergeom
lot_size, defects, sample_size = 100, 8, 10
no_defects_found = hypergeom.pmf(0,lot_size,defects,sample_size)
detected = hypergeom.sf(0,lot_size,defects,sample_size)
print(f'Expected sample defects: {sample_size*defects/lot_size:.2f}')
print(f'No defects observed: {no_defects_found:.2%}')
print(f'At least one defect observed: {detected:.2%}')Recorded output
Expected sample defects: 0.80 No defects observed: 41.66% At least one defect observed: 58.34%
Sources and further reading
Concepts are linked to primary teaching or technical sources. The business examples are illustrative applications, not reported client results.