Sample size for a 1-sample Z test: formula and power curve
Sample size for a 1-sample Z test answers the question: how many measurements do I need so that, if the process mean has really shifted by a given amount, the 1-sample Z test will detect it with high probability? It applies when the standard deviation σ is known from long experience, such as a stable control chart. Because σ is known, the answer comes from a closed formula on the normal distribution, with no approximation.
When to use it
- You plan to test a process mean against a target and already know σ well, for example from months of control chart data.
- You want to know the smallest shift a planned sample can detect, or the power of a sample size someone already chose.
- You need a quick first estimate for a t test. The Z answer is a slight underestimate; the 1-sample t sample size gives the exact figure when σ is estimated from the sample.
How it works
Four quantities are linked; fix three and you get the fourth:
- α, the significance level (the false alarm risk), often 0.05.
- Power, 1 − β, the probability of detecting the shift, often 0.80 or 0.90.
- δ, the smallest shift in the mean that matters in practice.
- n, the sample size, together with the known σ.
For a two-sided test the exact power is:
Power = Φ(δ√n/σ − z₁₋α/₂) + Φ(−δ√n/σ − z₁₋α/₂)The second term is the tiny chance of rejecting on the wrong side; ignoring it and solving for n gives the familiar formula:
n = ( (z₁₋α/₂ + z₁₋β) σ / δ )²Round up to the next whole number. For a one-sided test, replace z₁₋α/₂ with z₁₋α. Solved the other way, the smallest shift a sample of n can detect is δ = (z₁₋α/₂ + z₁₋β) σ / √n.
Example
A filler puts 500 g of sauce in each jar. Months of individuals charts show σ = 1.2 g and a stable process. After a nozzle change, quality wants to check the mean with a two-sided Z test at α = 0.05, and wants 90% power to detect a shift of 1.0 g in either direction.
With z₀.₉₇₅ = 1.960 and z₀.₉₀ = 1.282:
n = ( (1.960 + 1.282) × 1.2 / 1.0 )² = (3.890)² = 15.13 → 16 jarsChecking with the exact power formula: 15 jars give 0.898, just short of the goal; 16 jars give 0.915. If a shift in only one direction matters (an underfill, say), a one-sided test needs ((1.645 + 1.282) × 1.2)² = 12.33, so 13 jars, with power 0.913.
The power curve shows how power grows with the size of the shift for three sample sizes:
How to read the results
- At zero shift every curve starts at α = 0.05. That is the false alarm rate, not a flaw.
- Doubling n does not double power. It shrinks the detectable shift by a factor of √2: with 8 jars, 90% power needs a shift of about 1.4 g; with 32 jars, about 0.7 g.
- Read the planned design at the shift you care about. With 16 jars a 1.0 g shift is detected 91.5% of the time, a 0.5 g shift only 38.5% of the time. If 0.5 g matters, 16 jars is not enough.
- The detectable shift for a fixed budget is often the more useful answer. With 10 jars, the shift detectable with 90% power is 3.242 × 1.2 / √10 = 1.23 g.
Common mistakes
- Using a Z calculation when σ is not really known. If σ comes from the same small sample, the test is a t test and needs a few more units.
- Choosing δ from what the data might show instead of what matters. δ should come from the product: the shift that would cause rejects, cost money or break a specification.
- Underestimating σ. n grows with σ², so an optimistic σ is the fastest way to an underpowered study. Use the long-run (overall) standard deviation, including any variation between shifts or lots that the test will see.
- Forgetting that the samples must be independent. Sixteen jars filled one after another by the same nozzle in one minute may not represent the process.
Frequently asked questions
Why do I round up?
The formula gives the n at which power exactly reaches the target. Any fraction means a smaller sample would fall short, so you take the next whole unit.
What power should I use?
0.80 is a common minimum and 0.90 is common when missing a shift is costly. Going from 0.80 to 0.90 raises n by about a third for α = 0.05.
Is the formula exact?
For the two-sided case it drops the probability of rejecting in the wrong direction, which is negligible for any useful power. The power formula above is exact for a normal process with known σ.
When should I use the t version instead?
Whenever σ will be estimated from the sample itself. See sample size for a 1-sample t test.