What the one-sample t-test decides
You have one sample and one claim about the population it came from: the true mean is μ₀. The one-sample t-test weighs the sample mean against that claim, in units of the standard error: how far apart they are, relative to how much a sample mean naturally wobbles. It uses the t distribution because the standard deviation is estimated from the same sample, and small samples make that estimate shaky; the fat tails are the honest price.
A bakery believes it sells 40 cakes a day on average; eight days of records say 42, 38, 45, 51, 44, 39, 47, 50. Sample mean 44.5, s = 4.7509, standard error 1.6797. t = (44.5 − 40) ÷ 1.6797 = 2.679 on 7 df, two-tailed p = 0.0316. At α = 0.05 the null is rejected: the bakery's true daily average is plausibly above 40. The effect is not trivial either, Cohen's d = 0.947, a large standardised difference, and the 95% interval for the mean (40.53 to 48.47) clears 40 entirely, telling the same story.
Assumptions, in plain sight
- Independence: observations must not influence each other (eight separate days, fine; eight hours of one day would not be).
- Roughly normal data: matters most for small n. Mild skew is forgiven; a violent outlier is not. Plot the data (the histogram above) and check.
- A random, representative sample: no test repairs a biased one.
One tail or two?
Two tails is the honest default: the mean could be above or below μ₀, and both would interest you. Choose a one-tailed alternative only when the other direction is genuinely meaningless for the decision at hand, and choose it before seeing the data.
Running the z-test instead because it is familiar. With σ estimated from n = 8, the z-test's p would read 0.0074 against the t-test's honest 0.0316, overstating the evidence more than fourfold.
Frequently asked questions
What if my data are clearly not normal?
With n above roughly 30 the central limit theorem carries the mean a long way. For small, badly skewed samples, a Wilcoxon signed-rank test (on this site's nonparametric pages) is the safer instrument: it tests medians rather than means.
What does Cohen's d add?
The p-value says whether the difference is detectable; d says how big it is in standard-deviation units. 0.2 is small, 0.5 medium, 0.8 large, by the usual rough labels.
Can I test a hypothesised median instead?
Not with this test. It is built for means. For medians, use the sign test or Wilcoxon signed-rank test.