One-Sample T-Test Explained (With a Worked Example)
TL;DR: A one-sample t-test compares one group’s average with a known value. The formula is t = (x̄ − μ) / (s / √n): take how far your sample mean sits from the target, and divide by the standard error. Example: 16 waiting times averaging 5.8 minutes against a claimed 5 minutes, with a standard deviation of 1.2, give t = 2.67 with 15 degrees of freedom. Check your own numbers with our free T-Test Calculator.
A coffee shop claims its average waiting time is 5 minutes. You time 16 customers and find they waited 5.8 minutes on average. Is the shop’s claim wrong, or did you just happen to pick a slow afternoon? You need to know how much sample averages normally jump around — and that is exactly what the one-sample t-test measures.
The one-sample t-test is the simplest of the three t-tests, and the best place to learn how they all work. It compares a single group’s average against a known or target value: a stated weight on a packet, a national average, a target time, a passing mark. This guide explains the formula piece by piece, works through a real example with every step shown, and then explains how to read the answer. If you are new to t-tests, start with our guide on what a t-test is first.
What is a one-sample t-test?
A one-sample t-test tests whether the mean of one sample is different from a specific value, called μ (the Greek letter mu) or μ₀. That value comes from outside your data: a manufacturer’s claim, a legal standard, a previous year’s average, or a theoretical value. The test starts with the null hypothesis that the true population mean equals that value, and asks whether your sample is far enough away to doubt it.
Suppose a factory fills bags of rice labelled 1 kg. You weigh 25 bags and find an average of 990 g. The one-sample t-test asks: if the factory really were filling bags to 1,000 g on average, how surprising would a sample average of 990 g be? If samples of 25 bags usually average within a few grams of 1,000, then 990 g is surprising and the machine probably is under-filling.
The one-sample t-test formula
The formula looks harder than it is. Written out, it is:
t = (x̄ − μ) / (s / √n)
Each symbol stands for one number you either already have or can calculate from your sample:
| Symbol | Meaning | Where it comes from |
|---|---|---|
| x̄ | Sample mean — the average of your data | Add up your values and divide by n |
| μ | The value you are testing against | A claim, a standard, or a known average |
| s | Sample standard deviation — how spread out the data are | Calculated from your sample |
| n | Sample size — how many observations you have | Count your values |
The top of the fraction, x̄ − μ, is the gap you observed: how far your sample mean sits from the target. The bottom, s / √n, is the standard error: how much sample means typically bounce around from one sample to the next. It is the standard deviation divided by the square root of the sample size, so a bigger sample gives a smaller standard error, and more spread-out data give a larger one.
Dividing the gap by the standard error answers the key question in a standardised way: how many “wobbles” away from the target is your sample mean? A t-value of 0 means the sample mean equals the target exactly. A t-value of 1 means the gap is about the size of the usual wobble. A t-value of 2.67 means the gap is more than two and a half times the usual wobble — the kind of result that makes you doubt the null hypothesis. The degrees of freedom are n − 1: with 15 degrees of freedom, the two-tailed critical value at the 5% level is 2.131, so you need a t-value beyond that to call a result significant.
Worked example: is the coffee shop slower than it claims?
Let us work through the coffee shop example in full, with every step shown. A coffee shop claims its average waiting time is 5 minutes. You time a random sample of 16 customers and find:
- Sample mean, x̄ = 5.8 minutes
- Claimed mean, μ = 5 minutes
- Sample standard deviation, s = 1.2 minutes
- Sample size, n = 16
Step 1: Find the observed gap. Subtract the claimed value from the sample mean: 5.8 − 5 = 0.8 minutes. Customers in your sample waited 0.8 minutes longer than the claim, on average.
Step 2: Find the standard error. First take the square root of the sample size: √16 = 4. Then divide the standard deviation by that number: 1.2 / 4 = 0.3 minutes. So if the shop’s claim were true, sample means of 16 customers would typically bounce around by about 0.3 minutes from one sample to the next.
Step 3: Divide the gap by the standard error. t = 0.8 / 0.3 = 2.67 (rounded to two decimal places; the unrounded value is 2.666…). The sample mean sits 2.67 standard errors above the claimed value.
Step 4: Note the degrees of freedom. df = n − 1 = 16 − 1 = 15.
Step 5: Interpret the result. A t-value of 2.67 with 15 degrees of freedom gives a two-tailed p-value of about 0.018 — if the shop’s claim of 5 minutes were true, only about 1.8% of such samples would average 5.8 minutes or further from 5. That is below the usual 0.05 cut-off, so the result is statistically significant: the data give real evidence that the true average waiting time is longer than 5 minutes.
A second example: a quick check with round numbers
A second, simpler example shows the same steps with numbers you can check in your head. A teacher claims the average score on a test is 100 points. A sample of 25 students averages 102 points, with a standard deviation of 10 points.
- Gap: 102 − 100 = 2 points.
- Standard error: √25 = 5, so 10 / 5 = 2 points.
- t-value: 2 / 2 = 1.00.
- Degrees of freedom: 25 − 1 = 24.
A t-value of 1.00 with 24 degrees of freedom gives a two-tailed p-value of about 0.33 — far above 0.05. The result is not statistically significant, and it does not prove the teacher’s claim is right; it only means this sample is not strong enough evidence against it.
What does a one-sample t-test assume?
Like every statistical test, the one-sample t-test rests on assumptions. If they are badly broken, the p-value cannot be trusted. There are three main ones.
The observations are independent. One customer’s waiting time should not affect another’s, and one student’s score should not affect another’s. If the data come in clusters — for example, several measurements from the same machine on the same day — the effective sample size is smaller than it looks, and the test will be overconfident.
The sample is random. The customers you timed, or the bags you weighed, should be a fair cross-section of the whole group, not a hand-picked set. Timing only the morning rush, or weighing only the bags on top of the pile, biases the sample, and no test can correct for that.
The data are roughly bell-shaped, or the sample is large. With 30 or more observations this matters little; with a small, badly skewed sample, look at the data first.
One-tailed or two-tailed?
Every t-test needs one more decision: one-tailed or two-tailed. A two-tailed test asks whether the mean is different from the target in either direction, and it is the default. A one-tailed test asks whether it is different in one specific direction only, and you should use it only when you decided the direction before seeing the data — for example, testing whether a safety device reduces accidents, where an increase would be treated the same as no change. Never switch to a one-tailed test after seeing that the two-tailed result just missed significance: that is choosing the test to fit the answer. If in doubt, report the two-tailed result.
Common mistakes with the one-sample t-test
Two mistakes come up again and again. The first is testing the sample against the wrong value — using last year’s sample mean as if it were a known population value, for example. The one-sample test needs a fixed target, not another sample’s average; comparing two samples is a job for the independent t-test.
The second is treating a non-significant result as proof that the null hypothesis is true. “Not significant” means “not enough evidence to reject”, not “proven equal”. A small sample can fail to detect a real difference simply because it has too little power, which is why planning your sample size before you collect data matters. Our Slovin’s Formula Calculator helps with that planning step.
Frequently Asked Questions
What is a one-sample t-test used for?
A one-sample t-test compares the average of one group with a known or target value. Use it to ask questions like whether a machine fills bottles to its stated 500 ml, or whether a class average differs from the national average of 60 marks.
What is the formula for a one-sample t-test?
The formula is t = (x-bar - mu) / (s / square root of n), where x-bar is the sample mean, mu is the value you are testing against, s is the sample standard deviation, and n is the sample size. The denominator, s / square root of n, is the standard error.
What are the degrees of freedom for a one-sample t-test?
The degrees of freedom are n - 1, where n is the sample size. A sample of 16 observations has 15 degrees of freedom, because one degree of freedom is used up in calculating the sample mean.
What does a one-sample t-test assume?
It assumes the observations are independent, the sample is random, and the data are roughly normally distributed — or the sample is large enough (usually 30 or more) for that last point to matter less. It also assumes the outcome is a measurement, such as a weight or a test score, not a category.
When should I use a one-sample t-test instead of a z-test?
Use a one-sample t-test when the population standard deviation is unknown, which is the usual case, or when the sample is small. Use a z-test only when the population standard deviation is genuinely known and the sample is large. In practice, the t-test is the default choice.