1-sample t-test: how to run and interpret one, with example
The 1-sample t-test checks whether the mean of a process differs from a target or reference value, using only the sample itself to estimate the spread. It divides the distance between the sample mean and the target by the estimated standard error s/√n and reads the p-value from the t distribution with n − 1 degrees of freedom. It is the everyday test for "is this process on target?".
When to use it
- A new lot, setup or supplier should hit a nominal value, and you want to know whether its mean is off.
- You need a confidence interval for a process mean to put in a report or a validation.
- You are checking a measurement method against a reference standard with a known value (a bias check).
- You do not have a reliable long-term σ. If you do, the 1-sample Z test applies.
How it works
Hypotheses, with μ the process mean and μ₀ the target:
- H₀: μ = μ₀.
- H₁: μ ≠ μ₀ (two-sided), or μ > μ₀, or μ < μ₀ (one-sided).
The test statistic, with s the sample standard deviation:
t = (x̄ − μ₀) / (s / √n), df = n − 1For a two-sided test the p-value is 2 × (1 − T(|t|)), where T is the CDF of the t distribution with n − 1 degrees of freedom. The confidence interval for the mean is:
x̄ ± t(1 − α/2, n − 1) · s / √nAssumptions:
- The observations are independent, for example batches or parts not influenced by the one before.
- The data come from a roughly normal distribution. The test is fairly robust: with 15 to 20 values, moderate skewness does little harm, and with 30 or more the mean is close to normal for most shapes. With small samples and clear skewness or outliers, use the 1-sample Wilcoxon test or the sign test instead.
Example
A resin plant targets a viscosity of 450 mPa·s at 25 °C, with specification limits of 420 to 480. After switching to a new supplier of a raw material, the plant makes 12 batches:
| Viscosity (mPa·s) | |||||
|---|---|---|---|---|---|
| 476 | 448 | 444 | 452 | 443 | 473 |
| 466 | 463 | 472 | 449 | 442 | 460 |
The question: has the new raw material moved the mean viscosity away from 450? The test is two-sided at α = 0.05.
- x̄ = 457.33, s = 12.53, n = 12.
- Standard error: 12.53/√12 = 3.617.
- t = (457.33 − 450)/3.617 = 2.03, with 11 degrees of freedom.
- p-value = 2 × (1 − T(2.03; 11)) = 0.068.
- t(0.975, 11) = 2.201, so the 95% CI is 457.33 ± 2.201 × 3.617 = 449.37 to 465.29.
| N | Mean | StDev | SE Mean | t | df | p-value | 95% CI |
|---|---|---|---|---|---|---|---|
| 12 | 457.33 | 12.53 | 3.617 | 2.03 | 11 | 0.068 | (449.37, 465.29) |
An Anderson–Darling normality test on the 12 values gives p = 0.26, so the normality assumption is reasonable.
How to read the results
- The p-value of 0.068 is above 0.05. The data do not give strong enough evidence that the mean moved away from 450.
- That is not proof that the mean is 450. The interval says the true mean could be anywhere from about 449 to 465. A mean of 465 would leave only 15 mPa·s to the upper limit, about 1.2 standard deviations, which would produce out-of-spec batches regularly.
- The interval is the more useful answer. It shows both what the data rule out (means below 449) and what they still allow. Here the honest conclusion is "not proven different, but not proven fine either".
- Decide the next step from the interval. More batches will narrow it; with the same spread, about 40 batches in total would cut the half-width roughly in half. If the goal is to show the new material is equivalent within a stated margin, run an equivalence test instead, which puts the burden of proof where it belongs.
Common mistakes
- Reading "fail to reject H₀" as "the mean is on target". A small sample can fail to detect a real and important shift. Always report the interval.
- Ignoring the order of the data. If the batches trend upward over time, the mean of all 12 describes none of them. Plot the data in time order first, for example with a run chart.
- Running many one-sided tests until one is significant. Choose the alternative before looking at the data.
- Using it on data with a strong time dependence. Autocorrelated data make s underestimate the variation of the mean, which inflates t.
Frequently asked questions
What are the degrees of freedom in a 1-sample t-test?
n − 1. One degree of freedom is used up by estimating the mean, which the standard deviation is measured from. With 12 batches there are 11 degrees of freedom.
How large must the sample be?
The test works with any n of 2 or more, but small samples give wide intervals and low power. Choose n from the shift you need to detect with sample size for the 1-sample t.
Is the t-test valid if my data are not normal?
For moderate departures and samples of about 20 or more, yes, because the sample mean is close to normal. For small, clearly skewed samples, or with outliers, use a nonparametric test on the median.
What is the difference between the t-test and a confidence interval?
They use the same numbers. A two-sided test at α = 0.05 rejects H₀ exactly when the 95% interval does not contain μ₀. The interval also shows how large the difference could be.