One Sample t Test: Steps, Formula and Examples
A one sample t test determines whether the mean of one sample differs statistically from a known or hypothesized population value. Use it for a continuous outcome when observations are independent and the population…
One Sample t Test: Steps, Formula and Examples

A one sample t test checks whether the mean of one numeric sample is different from a fixed or hypothesized population value.
It is useful when the population standard deviation is unknown, which is the usual real-world situation. The test uses the sample standard deviation, sample size, and observed mean difference to calculate a t statistic and p value.
| Quick question | Answer |
|---|---|
| How many samples? | One |
| What is compared? | Sample mean vs. a fixed value |
| Main formula | t = (x̄ - μ₀) / (s / √n) |
| Degrees of freedom | n - 1 |
| Typical data | One numeric variable |
What Is a One Sample t Test?
A one sample t test is a hypothesis test used to compare the mean of one numeric sample with a fixed value. That fixed value may come from a standard, a theory, a target, a previous study, or a population value that researchers want to check.
For example, a quality team might test whether the average fill weight of a product differs from 500 grams. A teacher might test whether the average exam score differs from 70. A nutrition researcher might test whether the mean protein content of energy bars differs from the 20 grams printed on the label.
The test is sometimes called a single sample t test. It does not compare two groups. It compares one sample mean with one specified value.
When Do We Use a One-Sample t-Test?
Use a one sample t test when you have one sample of a continuous or approximately continuous numeric variable and one meaningful reference value for the population mean.
The question should be about a mean. If you are comparing two independent groups, use an independent samples t test. If the same people are measured twice or values are naturally paired, use a paired t test instead.
How Does the One-Sample t-Test Work?
The test starts with the difference between the observed sample mean and the hypothesized mean. A raw difference alone is not enough because a difference of two units may be large in a very stable dataset but small in a highly variable dataset.
The one sample t test therefore divides the mean difference by the standard error. The result is the t statistic. A large absolute t value means the observed mean is far from the null value relative to the amount of sampling variation.
That t statistic is then compared with a Student's t distribution using n minus 1 degrees of freedom. The comparison produces the p value.
The sample mean is compared with a fixed test value after accounting for sampling error.
One Sample t-Test Formula
The standard formula is t = (x̄ - μ₀) / (s / √n). The numerator is the difference between the sample mean and the value stated by the null hypothesis. The denominator is the estimated standard error of the sample mean.
LibreTexts emphasizes that the formula combines the observed difference, sample size, and sample variability. These are the same ingredients that affect how much evidence the sample contains.
The core formula and its four inputs.
Formula Components
In the formula, x̄ is the sample mean, μ₀ is the hypothesized population mean, s is the sample standard deviation, and n is the sample size.
The standard error is s / √n. It gets smaller when the sample becomes larger or when the sample values are less variable. A smaller standard error makes a fixed mean difference produce a larger absolute t statistic.
| Symbol | Meaning |
|---|---|
| x̄ | Sample mean |
| μ₀ | Hypothesized population mean |
| s | Sample standard deviation |
| n | Sample size |
| SE | s / √n |
Null and Alternative Hypotheses
The null hypothesis normally states that the population mean equals the test value: H₀: μ = μ₀.
The alternative hypothesis depends on the research question. A two-sided test uses H₁: μ ≠ μ₀. A right-tailed test uses H₁: μ > μ₀. A left-tailed test uses H₁: μ < μ₀.
Choose the direction before looking at the result. Do not switch from two-sided to one-sided after seeing the data just to obtain a smaller p value.
One-Tailed vs. Two-Tailed One Sample t Tests
A two-tailed test asks whether the population mean differs from the test value in either direction. This is the usual choice when both higher and lower values would matter.
A one-tailed test asks whether the population mean is specifically greater than or specifically less than the test value. One-tailed tests can be appropriate when the direction is defined by the research question before the data are analyzed.
One Sample t Test Assumptions
The observations should be independent. One value should not be a repeated or linked measurement of another value in the same analysis.
The outcome should be numeric and measured on a scale where a mean is meaningful. JMP describes continuous data as the standard setting for this test.
The sample should represent the population you want to make statements about. Random sampling or a sound study design is important for generalization.
The population is assumed to be approximately normal, especially for small samples. The t test is fairly robust to moderate non-normality as sample size grows, but strong skewness and extreme outliers can still cause problems.
| Assumption | Why it matters |
|---|---|
| Independent observations | Dependence can make the standard error and p value misleading |
| Numeric outcome | The test compares a mean |
| Representative sample / sound design | Needed for population-level conclusions |
| Approximate normality for small n | Strong skewness or outliers can distort a small-sample test |
Evaluating the Assumptions
Independence comes from the way the data were collected, not from a statistical test. Ask whether one observation could influence or duplicate another.
To examine the distribution, look at a histogram, box plot, or Q-Q plot. Pay special attention to strong skewness and outliers when the sample is small.
A formal normality test can be reported, but graphical checks and subject knowledge are often more useful because normality tests can be too sensitive in large samples and underpowered in small samples.
How to Perform a One Sample t Test: Step by Step
Step 1: Define the population mean you want to test and state H₀ and H₁.
Step 2: Check the study design, independence, measurement scale, and the shape of the data.
Step 3: Calculate the sample mean, sample standard deviation, sample size, and standard error.
Step 4: Calculate t = (x̄ - μ₀) / (s / √n).
Step 5: Use df = n - 1 and the t distribution to obtain the p value.
Step 6: Compare the p value with your chosen significance level and interpret the result in the context of the question.
Step 7: Report the sample mean, t statistic, degrees of freedom, p value, confidence interval, and preferably an effect size.
One Sample t Test Example: Worked by Hand
Suppose a teacher wants to know whether the population mean exam score differs from 50. A sample of 15 students has a mean score of 52.3 and a sample standard deviation of 5.8.
The null hypothesis is H₀: μ = 50 and the two-sided alternative is H₁: μ ≠ 50.
The standard error is 5.8 / √15 = 1.498. The test statistic is (52.3 - 50) / 1.498 = 1.54. The degrees of freedom are 15 - 1 = 14.
The two-sided p value is 0.147. Because this is greater than 0.05, the sample does not provide enough evidence to conclude that the population mean differs from 50.
| Statistic | Value |
|---|---|
| Sample size, n | 15 |
| Sample mean, x̄ | 52.3 |
| Sample SD, s | 5.8 |
| Test value, μ₀ | 50.0 |
| Standard error | 1.498 |
| t | 1.536 |
| df | 14 |
| Two-sided p | 0.147 |
| 95% CI for mean | 49.09 to 55.51 |
| Cohen's d | 0.40 |
Worked example from summary statistics to interpretation.
How to Interpret the t Statistic
The sign of t shows the direction of the observed difference. A positive t means the sample mean is above the test value. A negative t means the sample mean is below it.
The size of |t| tells you how many estimated standard errors the sample mean is from the hypothesized mean. In the worked example, t is about 1.54, so the sample mean is around 1.54 standard errors above 50.
Degrees of Freedom
For a one sample t test, degrees of freedom are df = n - 1.
Degrees of freedom determine the exact shape of the t distribution. With small samples, the t distribution has heavier tails than the normal distribution. As sample size becomes large, the t distribution becomes very similar to the standard normal distribution.
P Value and Statistical Significance
The p value measures how unusual a t statistic at least as extreme as the observed one would be if the null hypothesis were true.
If p is below the preselected significance level, such as 0.05, the result is called statistically significant and H₀ is rejected. If p is above the threshold, you do not reject H₀.
Do not say that p > 0.05 proves the null hypothesis. It only means the sample does not provide enough evidence against it at that threshold.
For a two-sided test, the p value combines both tails beyond the observed absolute t statistic.
Confidence Interval
A confidence interval gives a range of plausible values for the population mean under the statistical model.
In the worked example, the 95% confidence interval for the mean is approximately 49.09 to 55.51. The test value of 50 lies inside that interval, which agrees with the non-significant two-sided test.
A confidence interval is valuable because it shows both direction and uncertainty. It should usually be reported with the p value rather than treating significance as the whole result.
Effect Size for a One Sample t Test
Statistical significance does not tell you whether a difference is large or important. A simple standardized effect size is one-sample Cohen's d: d = (x̄ - μ₀) / s.
For the worked example, d = (52.3 - 50) / 5.8 = 0.40. This is a modest standardized difference, but effect size should be interpreted in the context of the field rather than by rigid labels alone.
Kent State notes that recent SPSS versions can estimate Cohen's d directly from the One-Sample T Test dialog.
One Sample t Test in SPSS
SPSS can run the test from Analyze > Compare Means > One-Sample T Test.
Move the numeric outcome into Test Variable(s), enter the hypothesized mean in Test Value, choose the confidence interval in Options if needed, and click OK.
In SPSS 27 and later, the dialog can also print effect size statistics such as Cohen's d.
The standard SPSS workflow.
Data Set-Up in SPSS
Your data should contain one continuous numeric variable in a column. In Variable View, the measurement level should normally be set to Scale.
Each row should represent one independent observation. You do not need a separate grouping variable because a one sample t test uses only one sample.
How to Read One Sample t Test Output in SPSS
The One-Sample Statistics table gives the sample size, mean, standard deviation, and standard error.
The One-Sample Test table gives the test value, t statistic, degrees of freedom, significance value, mean difference, and confidence interval for the difference.
The mean difference in SPSS is x̄ - μ₀. If a 95% confidence interval for that difference includes zero, the corresponding two-sided test at α = 0.05 will not be statistically significant.
How to Perform a One-Sample t-Test in R
In R, the standard function is t.test(). For a two-sided test against 50, you can use t.test(x, mu = 50).
For a directional test, set alternative = 'greater' or alternative = 'less'. R reports the t statistic, degrees of freedom, p value, confidence interval, and the sample mean.
Stats and R also recommends visualizing the data before running the test so you can check the shape of the sample and spot unusual observations.
# two-sided one sample t test against 50
t.test(x, mu = 50)
# right-tailed test
t.test(x, mu = 50, alternative = "greater")
One Sample t Test vs. z Test
A one sample t test is normally used when the population standard deviation is unknown and must be estimated from the sample. This is the usual real-world situation.
If the true population standard deviation is known, a one-sample z test may be used instead. Stats and R explains this as the distinction between the normal distribution when population variance is known and the t distribution when it is unknown.
As sample size grows, the t and normal distributions become very similar.
One Sample t Test vs. Independent and Paired t Tests
Use a one sample t test when one sample is compared with one fixed mean.
Use an independent samples t test when two unrelated groups are compared, such as treatment and control groups made up of different people.
Use a paired t test when observations come in natural pairs or when the same participants are measured twice. Choosing the wrong t test can produce an invalid standard error and p value.
| Test | Use it when |
|---|---|
| One sample t test | One sample mean is compared with one fixed value |
| Independent samples t test | Two unrelated groups are compared |
| Paired t test | The same units are measured twice or observations are paired |
What If the Data Are Not Approximately Normal?
When the sample is large, the one sample t test is often reasonably robust to moderate departures from normality. Small samples need more care.
If the data are strongly skewed, contain influential outliers, or the mean is not a useful summary, consider a transformation or a nonparametric alternative such as the Wilcoxon signed-rank test.
Remember that the Wilcoxon test answers a somewhat different question and should not be described as simply a t test without normality.
Common One Sample t Test Mistakes
Do not use a one sample t test to compare two groups. That requires an independent or paired analysis depending on the design.
Do not treat a reference value estimated from the same sample as though it were an external fixed value.
Do not ignore dependence between observations, because repeated or clustered measurements can make the standard error too small.
Do not report only p < 0.05. Include the mean, standard deviation, t, df, exact p value when practical, confidence interval, and an effect size.
Do not change a two-tailed test into a one-tailed test after looking at the result.
How to Report a One Sample t Test
An APA-style sentence should explain the practical comparison and then report the statistical evidence.
For the worked example, a concise report is: The sample mean score (M = 52.30, SD = 5.80) was not significantly different from 50, t(14) = 1.54, p = 0.147, 95% CI for the mean [49.09, 55.51], d = 0.40.
Use wording that fits the study. If the result is not significant, say that the data did not provide sufficient evidence of a difference rather than claiming that the two values are proven equal.
Practical Examples of One Sample t Tests
A manufacturer can test whether the average fill weight differs from a 500-gram target.
A hospital can test whether mean cholesterol in a patient population differs from a clinical reference value.
A food company can test whether average protein content differs from the value printed on a label.
An education researcher can test whether average exam performance differs from an established benchmark.
An environmental scientist can test whether average pollutant concentration is above a regulatory limit, using a one-sided test when that direction is defined in advance.
Animated View: How the Sample Mean Changes the Test Result
The animation moves the sample mean away from the null value while keeping the sample size and standard deviation fixed.
As the mean moves farther from μ₀, |t| increases and the p value generally falls.
Frequently Asked Questions
What is a one sample t test in simple terms?
It tests whether the mean of one numeric sample is different from a fixed or hypothesized population mean.
What is the one sample t test formula?
t = (x̄ - μ₀) / (s / √n), where x̄ is the sample mean, μ₀ is the test value, s is the sample standard deviation, and n is the sample size.
What are the assumptions of a one sample t test?
The observations should be independent, the variable should be numeric, the sample should represent the target population, and the population should be approximately normal when the sample is small.
What are the degrees of freedom for a one sample t test?
df = n - 1.
When should I use a one sample t test?
Use it when one sample mean is being compared with one fixed value and the population standard deviation is unknown.
What is the difference between a one sample t test and an independent t test?
A one sample test compares one sample with a fixed value. An independent t test compares the means of two unrelated groups.
What is the difference between a one sample t test and a paired t test?
A paired t test analyzes paired or repeated measurements. A one sample t test analyzes one set of values against a fixed reference mean.
How do I run a one sample t test in SPSS?
Go to Analyze > Compare Means > One-Sample T Test, move the numeric outcome into Test Variable(s), enter the Test Value, and click OK.
What does a negative t statistic mean?
It means the sample mean is below the hypothesized mean. The sign shows direction, while the magnitude helps determine the p value.
What does p > 0.05 mean in a one sample t test?
It means the data do not provide enough evidence to reject the null hypothesis at the 5% significance level. It does not prove the null hypothesis is true.
Should I report a confidence interval?
Yes. A confidence interval shows the uncertainty around the estimated population mean and gives more information than the p value alone.
Can I use a one sample t test with non-normal data?
Often yes for larger samples and mild non-normality. Small samples with strong skewness or outliers need more caution and may call for another method.
Final Thoughts
A one sample t test is a focused way to answer one question: is the population mean compatible with a fixed reference value?
The calculation is simple, but good analysis also requires a sound study design, a sensible test value, checks for strong non-normality or outliers, and careful interpretation of uncertainty.
Report the sample mean and standard deviation together with t, df, p, a confidence interval, and an effect size.
Sources
- Stats and R: How to perform a one-sample t-test by hand and in R
- Medium: One-Sample t-test, Visually Explained
- Stats for Bio: One sample t-tests
- GraphPad: One sample t test
- Numiqo: One-Sample t-Test
- Kent State SPSS: One Sample t Test
- LibreTexts: The One Sample t-Test Formula
- JMP: The One-Sample t-Test
Try it in DataClue
Ready to run One-Sample t-Test?
Test whether the mean of a single sample differs significantly from a known or hypothesized population mean.
Run One-Sample t-Test