timerring

How Many Samples Does It Take to Trust a Batch?

October 12, 2026 · 7 min read
Tutorial
Statistics | Math
If you have any questions, feel free to comment below. Click the block can copy the code.
And if you think it's helpful to you, just click on the ads which can support this site. Thanks!

You have 1,000 items, but testing every one of them is expensive. How many should you randomly inspect: 10, 100, or half the batch?

There is no universal answer based on population size alone. As the NIST/SEMATECH e-Handbook explains[1], sample-size planning depends on the statistical objective and precision requirements. The useful question is: How many items do I need to estimate a proportion with a chosen level of precision? Under common assumptions, the answer is 278—not an arbitrary percentage of the batch.

Try the sample-size calculator #

Enter the total number of items available, not the number you have already tested. The default recommendation assumes 95% confidence, a margin of error of ±5 percentage points, and an unknown population proportion.

Assumes an unknown proportion (p = 0.5) and random sampling without replacement.

Enable JavaScript to calculate a recommendation. At the default settings, inspect 278 of 1,000 items.

This is a planning estimate for a binary outcome, such as pass/fail, correct/incorrect, or defective/not defective. It assumes a simple random sample without replacement from a finite population. It is not a guarantee of finding rare defects, a machine-learning train/test split rule, or a batch acceptance plan.

First, decide what you want to learn #

Three questions that sound similar need different methods:

GoalExampleAppropriate approach
Estimate a proportionWhat fraction of these records are incorrect?Confidence level and margin-of-error planning
Detect a rare problemHow many inspections give a good chance of finding at least one defect?Detection-probability calculation
Accept or reject a batchShould we accept this shipment?An acceptance sampling plan with acceptance/rejection rules

The calculator above answers the first question. Calling its output the “optimal test count” would hide the assumptions that make it useful.

Which sampling question are you asking?Three different goals need different methods: proportion estimation, rare-defect detection, and batch acceptance. Only proportion estimation is handled by this calculator.Which sampling question are you asking?Estimate a proportionWhat fraction is defective?Confidence + margin of errorDetect a rare defectWill we find at least one?Detection probability + assumed rateAccept or reject a batchShould we accept this lot?Acceptance plan + decision thresholdsThe calculator answers the first question only.
These are alternative statistical objectives, not steps in one process. Detection calculations depend on an assumed defect rate and sampling model; formal acceptance decisions need a suitable inspection plan.

Where the formula comes from #

For a large population, the usual normal-approximation planning formula is:

$$ n_0 = \frac{z^2 p(1-p)}{e^2} $$

Here:

  • \(z\) is the standard-normal critical value: approximately 1.645 for 90% confidence, 1.96 for 95%, and 2.576 for 99%.
  • \(p\) is the anticipated population proportion.
  • \(e\) is the desired absolute margin of error. For ±5 percentage points, use 0.05.

When the proportion is unknown, use \(p=0.5\). This maximizes \(p(1-p)\), giving the most conservative sample size within this formula. It does not predict that half the items will fail.

For a known finite population of \(N\) items, apply the finite-population correction:

$$ n = \left\lceil \frac{n_0}{1+(n_0-1)/N} \right\rceil $$

The calculator keeps the intermediate value unrounded and rounds the final result up. The recommendation never exceeds the population size.

At 95% confidence and ±5 percentage points:

$$ n_0 = \frac{1.96^2 \times 0.5 \times 0.5}{0.05^2} = 384.16 $$

For 1,000 items, the correction gives about 277.74, so you should randomly inspect 278 items.

A practical reference table #

These counts all use the same defaults as the calculator:

Total populationRecommended inspections
10080
500218
1,000278
10,000370
100,000383
Very large or unknown385
Larger populations, diminishing sample growthAt 95% confidence, plus or minus 5 percentage points, and p equal to 0.5, inspect 80 of 100 items, 278 of 1,000, or 370 of 10,000. The population axis is logarithmic; inspection counts approach the rounded large-population recommendation of 385.Larger populations,diminishing sample growthRecommended inspections01002003004001001,00010,000100,00080278370385: large-population countTotal population N (log scale)95% confidence · ±5 percentage points · p = 0.5
The population axis is logarithmic; inspection counts use a linear scale. Counts are rounded up under the calculator’s default assumptions. The dashed line marks the rounded large-population recommendation, not a batch acceptance threshold.

The flattening is important. To estimate a proportion, you do not generally need to inspect a fixed percentage of every population. Once the population is large, the confidence level and margin of error dominate the calculation.

What confidence and error actually mean #

An estimated defect rate of 12% with a margin of error of ±5 percentage points means roughly 7% to 17%, not 12% ±5% of 12%.

A 95% confidence procedure means that, over repeated random samples, about 95% of the intervals constructed by that procedure would cover the true population proportion. It does not mean that 95% of the items pass, or that every estimate will be within five points of the truth.

This formula is an approximate planning tool, not an exact coverage guarantee. After collecting the data, use an appropriate interval method rather than blindly applying a symmetric normal interval, especially when failures are rare or counts are small.

Precision also has a price. For a very large population at 95% confidence, reducing the margin from ±5 to ±3 percentage points raises the recommendation from 385 to 1,068. Halving the margin roughly quadruples the large-population sample size.

More precision means more testsAt 95% confidence and p equal to 0.5, large-population counts are 97, 385, 1,068 and 9,604 for margins of 10, 5, 3 and 1 percentage points. Bar lengths share a zero baseline.More precision means more testsMargin of errorRequired tests (shared linear scale)±10 points97±5 points385±3 points1,068±1 points9,60402,5005,0007,50010,000Large population · 95% confidence · p = 0.5
Large-population counts at 95% confidence and p = 0.5, rounded up. All bars share a zero baseline. Finite populations may require fewer tests; the orange bar marks the calculator’s default margin.

A large sample cannot fix a biased selection #

The calculation assumes the selection process matches the statistical model. Testing the first 278 records, the easiest products to reach, or only one day’s output is not equivalent to drawing 278 items randomly.

Random is not the same as convenientTwo selections from the same 30 items grouped by supplier. Taking the first six omits suppliers B and C. An illustrative random draw reaches all three, but random sampling does not guarantee balanced groups.Random is not the same as convenientConvenient: first six itemsSupplier ASupplier BSupplier CRandom: one illustrative drawSupplier ASupplier BSupplier CDark rings = selected items · Same 30 items in both panelsRandom selection does not guarantee group balance.
Illustration only: six of the same 30 items are selected in each panel. This particular random draw includes each supplier, but simple random sampling does not guarantee balance. Deliberate group allocations require a stratified design.

A workable process is:

  1. Define the population and the pass/fail criterion before sampling.
  2. Give every item a unique identifier.
  3. Randomly select the required number of distinct identifiers.
  4. Test the selected items consistently and record all outcomes.
  5. Report the estimated proportion with its uncertainty and the sampling method.

If items come from different suppliers, categories, or time periods, consider stratified sampling so important groups are represented. However, subgroup precision, unequal sampling probabilities, and clustered observations require their own design calculations; the simple calculator does not account for them.

Rare-defect detection is a different problem #

Suppose you want a 95% chance of finding at least one defect if the true defect rate is 1%. Under independent trials with defect probability \(r\), the probability of observing no defects in \(n\) tests is \((1-r)^n\). Thus:

$$ n \geq \frac{\ln(1-C)}{\ln(1-r)} $$

With \(C=0.95\) and \(r=0.01\), rounding up gives 299 tests.

This is a detection calculation, not a proportion-estimation calculation. For a fixed finite batch sampled without replacement, an exact calculation uses the hypergeometric distribution and an assumed number of defective items. Neither approach proves a batch has zero defects when none are observed.

Batch acceptance needs more than a sample count #

If the decision is “accept or reject this shipment,” use a suitable acceptance sampling plan[2], such as one based on ISO 2859-1[3], rather than treating the calculator’s result as a quality standard.

Such a plan specifies not just a sample size, but also acceptance and rejection thresholds, inspection conditions, and applicable switching rules. The lot size, inspection level, and acceptance quality limit (AQL) matter. AQL is not a promise that every accepted batch contains at most that percentage of defects.

For safety-critical testing or contractual inspections, follow the applicable standard and domain requirements.

The takeaway #

Choose the question first, then the sample size. If you want a practical starting point for estimating a binary proportion, use 95% confidence, ±5 percentage points, and \(p=0.5\), then apply the finite-population correction. If you need rare-defect detection or a formal acceptance decision, choose a method designed for that goal.

The illustrations in this article were created using the logic2image[4] skill.


Related readings


<< prev | Stop Slop... Continue strolling Options 101:... | next >>

If you want to follow my updates, or have a coffee chat with me, feel free to connect with me: