One-Sample T-Test: Formula, Example and How to Do It by Hand

A one-sample t-test checks whether the mean of one group is different from a fixed number you already have in mind. That number might be a claim on a label, a target, a legal limit or a long-run average.

A worked example

A battery maker claims its batteries last 10 hours. You test 10 of them and get these run times in hours:

9.6, 9.8, 10.1, 9.4, 9.7, 9.9, 9.5, 10.0, 9.3, 9.6

Only one battery beat 10 hours. Is that enough to say the claim is wrong, or could a fair batch of batteries produce this by luck?

  1. State the hypotheses. H₀: μ = 10. H₁: μ ≠ 10.
  2. Summarise the sample. x̄ = 9.69 hours, s = 0.260 hours, n = 10.
  3. Find the standard error. SE = s ÷ √n = 0.260 ÷ 3.162 = 0.0823.
  4. Calculate t. t = (x̄ − μ₀) ÷ SE = (9.69 − 10) ÷ 0.0823 = −3.77.
  5. Get the p-value. With df = n − 1 = 9, p = 0.0044.
  6. Decide. p is well below 0.05, so reject H₀. The batteries last less than 10 hours on average.

Run the battery example in the one-sample t-test calculator

The 95% confidence interval for the true mean is 9.50 to 9.88 hours. It doesn’t include 10, which agrees with the test. The interval is more useful than the p-value here: it says the shortfall is somewhere between about 7 and 30 minutes.

Writing it up

“Battery life (M = 9.69 h, SD = 0.26) was significantly below the claimed 10 hours, t(9) = −3.77, p = .004, d = −1.19, 95% CI [9.50, 9.88].”

What the test assumes

  • The observations are independent. Ten batteries from ten different packs is better than ten from one pack.
  • The data come from a roughly normal distribution. This matters most with small samples. With 30 or more values, the test copes well with moderate skew. With 10 values, look at a dot plot. If there is a clear outlier or strong skew, use the Wilcoxon signed-rank test on the differences from μ₀ instead.

One-tailed or two-tailed?

If you only care whether the batteries fall short, and you decided that before looking at the data, a one-tailed test (H₁: μ < 10) is fair. It halves the p-value to 0.0022. What you can’t do is look at the data, see the mean is below 10, and then switch to a one-tailed test to get a smaller p. That doubles your real false-positive rate.

t-test or z-test?

Use a z-test only if you know the population standard deviation from outside your sample, which is rare. If you calculated s from your data, use t. With large samples the two give almost the same answer anyway.

Check yourself

A sample of 16 has x̄ = 52 and s = 8. Test H₀: μ = 50. What is t?

SE = 8 ÷ 4 = 2, so t = (52 − 50) ÷ 2 = 1.00, with df = 15. The p-value is 0.33, nowhere near significant.

Your t-test gives p = 0.0044. Does that mean there is a 0.44% chance the claim is true?

No. It means that if the claim were true, data this far from 10 hours would turn up 0.44% of the time. See what a p-value really means.