Sample size for a 1-sample t test, with a worked example

Updated

Sample size for a 1-sample t test tells you how many units to measure so that a 1-sample t test has a chosen probability (power) of detecting a given difference between the process mean and a target. Unlike the Z case, σ is unknown and will be estimated from the same sample, so the calculation uses the noncentral t distribution and needs a planning value for σ.

When to use it

  • You plan to compare a mean with a target or a specification value and will estimate the standard deviation from the sample.
  • You want the power of a sample size someone already proposed, or the smallest difference it can detect.
  • You are planning a paired study: a paired t test is a 1-sample t test on the differences, so the same method applies.

How it works

Under the alternative, the t statistic follows a noncentral t distribution with n − 1 degrees of freedom and noncentrality

λ = δ √n / σ

where δ is the true difference from the target and σ the planning standard deviation. For a two-sided test at level α, the power is

Power = P(T′ > t₁₋α/₂, n−1) + P(T′ < −t₁₋α/₂, n−1), T′ ~ noncentral t(n − 1, λ)

There is no closed formula for n, so you increase n one at a time until the power reaches the target. Two shortcuts help you start:

  • The normal formula, n ≈ ((z₁₋α/₂ + z₁₋β) σ/δ)², always comes out a little low, because it ignores that σ is estimated.
  • Adding z²₁₋α/₂ / 2 to it (a correction published by W. C. Guenther in 1981) usually lands on the exact answer or one unit away.

Only the ratio δ/σ matters. A difference of 2 µm with σ = 2.5 µm is the same problem as 0.8 mm with σ = 1 mm.

Example

A plating line must hold a mean coating thickness of 25 µm. A capability study last quarter gave σ ≈ 2.5 µm. Before signing off a new bath, the engineer wants a two-sided t test at α = 0.05 with 80% power to detect a mean that is off by 2.0 µm (δ/σ = 0.8).

  • Normal formula: ((1.960 + 0.842) × 2.5 / 2.0)² = 12.26, so 13 parts. The exact power with 13 parts is only 0.754.
  • With Guenther's correction: 12.26 + 1.960²/2 = 14.18, so 15 parts.
  • Exact search with the noncentral t: 14 parts give power 0.790; 15 parts give 0.821. The answer is 15.

A simulation confirms it. Drawing 200,000 samples of 15 from a normal process with mean 27 µm and σ = 2.5 µm (NumPy, seed 2026) and testing each against 25 µm with t₀.₉₇₅,₁₄ = 2.145 rejected the null hypothesis in 82.1% of the samples, against the computed 0.821.

Power of a two-sided 1-sample t test, σ = 2.5 µm, α = 0.050.20.40.60.81.0Powerδ = 2.0 µmδ = 1.5 µmδ = 1.0 µm51015202530Sample size n
Power of a two-sided 1-sample t test, σ = 2.5 µm, α = 0.05

How to read the results

  • The planned design is 15 parts. With them, a 2.0 µm offset is detected about 82% of the time.
  • Smaller differences need far more parts. At δ = 1.5 µm, 15 parts give only 58% power and 24 parts are needed for 80%. At δ = 1.0 µm even 30 parts give 56%.
  • Check the sensitivity to σ. If the real σ is 3.0 µm instead of 2.5, the power of 15 parts falls to 0.671, and 20 parts are needed for 80%. When the planning σ is uncertain, size for a pessimistic value.
  • After the study, do not recompute power from the observed difference. "Observed power" adds nothing to the p-value. Report a confidence interval for the mean instead.

Common mistakes

  • Stopping at the Z formula. It understates n, by two units here.
  • Using a within-subgroup σ for a test on parts from many batches. The test will see the total variation; plan with the overall standard deviation.
  • Picking δ to make n fit the budget. If the budget only supports a large δ, say so openly: the study can detect only large differences.
  • Measuring the same part repeatedly. Fifteen readings of one part estimate gauge noise, not process variation. You need fifteen independent parts.

Frequently asked questions

Why is the t test sample size larger than the Z test sample size?

Estimating σ from the data adds uncertainty, so the critical value t₁₋α/₂,n−1 is larger than z₁₋α/₂ and the test needs a slightly bigger difference, or a slightly bigger sample, to reject. The gap is about two units for α = 0.05.

Where do I get the planning standard deviation?

From historical data on the same characteristic, a pilot sample, a capability study or a control chart. Use a value that reflects the conditions of the test, and lean to the high side if in doubt.

What if my data are not normal?

The t test is fairly robust for moderate skewness once n is above about 15 to 20. For strongly skewed data, consider a transformation or a nonparametric test, and size it with simulation.

How do I size a one-sided test?

Use t₁₋α in place of t₁₋α/₂ and keep only the tail in the direction of interest. In the example, a one-sided test reaches 80% power with 12 parts (power 0.829) instead of 15.

Try it with your own data

StatLab SPC is free, open-source statistics for engineers. It runs in your browser, works offline, and never uploads your data.

Open StatLab