Understanding the one-sample t-test — concept and principle
A one-sample t-test checks whether the mean of a sample differs from a fixed reference value μ₀, such as a target fill weight, a historical average or a claimed specification. It is used when the population standard deviation is unknown and has to be estimated from the same data, which is the usual situation.
How it is calculated
- Compute the sample mean x̄ and the sample standard deviation s (with divisor n − 1).
- Standard error: SE = s ÷ √n.
- Test statistic: t = (x̄ − μ₀) ÷ SE.
- Degrees of freedom: df = n − 1.
- Two-tailed p-value = 2 × P(T > |t|) for Student's t distribution with df degrees of freedom.
- Decision at α = 0.05: reject H₀ (the true mean equals μ₀) if p < 0.05.
The principle
If the true mean really is μ₀, the sample mean will still wander around it by about one standard error. The t statistic counts how many standard errors the observed mean lies from μ₀. Because s is itself estimated, t follows Student's t distribution rather than the normal; its heavier tails demand stronger evidence when n is small. The p-value is the probability of seeing a t at least this extreme if H₀ were true.
Worked example
- Data: 12, 15, 11, 19, 22, 15, 18, 25, 14, 16 (n = 10); μ₀ = 15.
- x̄ = 167 ÷ 10 = 16.7; s = 4.372896.
- SE = 4.372896 ÷ √10 = 1.382831.
- t = (16.7 − 15) ÷ 1.382831 = 1.229361876, with df = 9.
- Two-tailed p = 0.250106155.
- Since 0.25 > 0.05, the decision is fail to reject H₀.
| Hypothesised mean μ₀ | t |
|---|---|
| 3.75 | 9.364844878 |
| 7.5 | 6.65301721 |
| 11.2 | 3.941189543 |
| 15 | 1.229361876 |
| 18.8 | -1.482465791 |
| 22.5 | -4.194293459 |
| 30 | -9.617948793 |
How to read the result
The sample mean is 1.7 above 15, but that gap is only about 1.23 standard errors; for 9 df, |t| would need to exceed 2.262 to be significant at the 5% level. A p of 0.25 means a difference this large would arise by chance about one time in four even if the true mean were 15. "Fail to reject" does not prove the mean is 15; it only says the data are not strong enough to rule it out. Report the mean difference and a confidence interval alongside p.
Common mistakes
- Reading a non-significant result as proof that H₀ is true.
- Using a one-tailed test after seeing the direction of the data.
- Applying the test to strongly skewed small samples or to non-independent observations.
Frequently asked questions
When should I use a z-test instead?
Only when the population standard deviation σ is known in advance, which is rare outside textbook problems.
How do I get a one-tailed p-value?
If the effect is in the predicted direction, halve the two-tailed p (here 0.125), but decide on one-tailed testing before looking at the data.
What if my data are not normal?
For moderate to large n the t-test is fairly robust. For small, skewed samples consider the Wilcoxon signed-rank test.
Sources: Student (1908). The probable error of a mean. Biometrika, 6(1), 1–25. · NIST/SEMATECH e-Handbook of Statistical Methods.