Sample size to estimate a mean, proportion or standard deviation
Sample size for estimation answers a different question from a test: not "can I detect a change?" but "how many units do I need so that my estimate is within ±E of the true value, with 95% confidence?" You choose the margin of error E, the confidence level and a planning value for the spread, and the formula gives n. This page covers the three most common cases: a mean, a proportion and a standard deviation.
When to use it
- You need a baseline number with known precision: mean cycle time of a new cell, first-pass yield of a line, standard deviation of a dimension.
- No hypothesis is being tested; you want a confidence interval narrow enough to be useful.
- You want to justify a sample size in a validation or study protocol.
How it works
Mean. A 95% confidence interval for a mean is x̄ ± t s/√n. Setting the half-width equal to E with a planning σ:
n = ( z₁₋α/₂ σ / E )² (σ known)
t₁₋α/₂, n−1 σ / √n ≤ E (σ estimated: search n)The t version gives a slightly larger n. Both give an interval whose half-width is about E on average; because s varies from sample to sample, half of all studies will come out a little wider. If you need assurance that the interval will be no wider than E, a larger n is needed (see the example).
Proportion. With the normal approximation,
n = z²₁₋α/₂ p (1 − p) / E²p(1 − p) is largest at p = 0.5, so use p = 0.5 when you have no idea of the rate. For rates below about 10%, or when n·p is small, the normal interval is poor; use a Wilson or exact (Clopper-Pearson) interval and check its width at the planned n.
Standard deviation. The 95% interval for σ is not symmetric:
s √( (n − 1) / χ²₀.₉₇₅, n−1 ) ≤ σ ≤ s √( (n − 1) / χ²₀.₀₂₅, n−1 )The factors depend only on n, so you can choose n from a table of them. The upper factor is the binding one.
| n | Lower factor | Upper factor |
|---|---|---|
| 10 | 0.688 | 1.826 |
| 20 | 0.760 | 1.461 |
| 30 | 0.796 | 1.344 |
| 50 | 0.835 | 1.246 |
| 70 | 0.857 | 1.200 |
| 100 | 0.878 | 1.162 |
Example
A plant is launching a new assembly cell and wants three baseline figures, each with 95% confidence.
Mean cycle time within ±1.0 s. Trial runs suggest σ ≈ 4.0 s. The z formula gives (1.960 × 4.0 / 1.0)² = 61.5, so 62 cycles. With t, 63 cycles give a margin of 1.007 s and 64 cycles give 0.999 s, so plan 64. That is the margin you can expect, not guarantee: with 64 cycles there is only about a 53% chance the realized interval is within ±1.0 s. For a 90% chance, you need 77 cycles.
Rework rate within ±3 percentage points. With no prior estimate, use p = 0.5: 1.960² × 0.25 / 0.03² = 1,067.1, so 1,068 assemblies. If similar cells run near 10% rework, p = 0.10 gives 384.1, so 385. A prior estimate pays off.
Standard deviation of a torque within ±20%. From the table, the upper factor drops to 1.200 at n = 70, where the lower factor is 0.857. So 70 torque readings give a 95% interval from 0.86s to 1.20s.
How to read the results
- Precision improves with √n. Halving the margin of error takes four times the sample: from n = 25 to 100 cuts the margin of a mean from about 0.41σ to 0.20σ.
- Small samples are expensive in a different way. Below about 10 values the t multiplier grows quickly, which is why the two curves split at the left.
- Standard deviations need large samples. Even 70 values leave a ±15 to 20% band on σ. Keep that in mind when a capability index is computed from 30 parts.
- The planning value matters most. n grows with σ² (or p(1 − p)); a planning σ 20% too low gives a sample about 36% too small.
Common mistakes
- Using a test's sample size formula for an estimate, or the reverse. A test needs α, power and a difference; an estimate needs only a confidence level and a margin.
- Forgetting that units must be independent and representative. Sixty-four consecutive cycles from one operator on one morning estimate that morning, not the cell.
- Reporting the estimate without the interval. The point of planning for ±E is to report ±E.
- Applying the proportion formula to rare events. With p = 1% and n = 400, you expect four events, and the normal interval can even go below zero.
Frequently asked questions
Why does the margin of error for a mean use t and not z?
Because σ is estimated from the same data. With large samples t and z agree; with small samples t is larger and the interval wider.
What confidence level should I use?
95% is the usual default. 90% gives a smaller n for the same margin; 99% a larger one, about 1.7 times the 95% sample size for a mean.
Can I estimate several things from one sample?
Yes. Size the sample for the most demanding quantity, usually the proportion or the standard deviation, and the others will be more precise than required.
How is this different from a tolerance interval?
A confidence interval estimates a parameter such as the mean. A tolerance interval bounds a proportion of individual values. See sample size for tolerance intervals.