One-sample vs two-sample t-test
By Jude Wallis · Published
A one-sample t-test compares the mean of one group with a fixed claimed value. A two-sample t-test compares the means of two independent groups with each other. Count the sets of quantitative data: one sample against a stated number is one-sample, and two separate groups is two-sample.
AP Statistics: Unit 4 (topics 4.4 Setting Up a Test for a Population Mean or Population Mean Difference, 4.5 Carrying Out a Test for a Population Mean or Population Mean Difference, 4.9 Setting Up a Test for the Difference Between Two Population Means, 4.10 Carrying Out a Test for the Difference Between Two Population Means). Both tests are in Unit 4 of the Fall 2026 AP Statistics course. The one-sample t-test for a population mean, and for a population mean difference with matched pairs, is topics 4.4 and 4.5. The two-sample t-test for a difference between two population means is topics 4.9 and 4.10.
One-sample vs two-sample t-test: the short answer
Both tests are about means of a quantitative variable, and both read their p-value from a curve. They differ in what the sample mean is compared with.
A one-sample t-test has one set of data and one claimed value. The null hypothesis is , where ("mu") is the population mean and is a number given by the problem, such as a label weight or a historical average.
A two-sample t-test has two independent sets of data and no claimed value for either mean. The null hypothesis is , which is the same as . The comparison is between the groups.
The quick check is to ask where the comparison number comes from. If the problem hands it to you as a fixed value, the test is one-sample. If it has to be estimated from a second group of individuals, the test is two-sample.
The one-sample t-test
Use it when one random sample gives a mean ("x-bar") and a standard deviation , and you want to test a claim about the population mean. The test statistic is
with degrees of freedom. The denominator is the standard error of the sample mean.
Conditions: the data come from a random sample or a randomized experiment; when sampling without replacement, the sample is at most 10% of the population; and either the population is stated to be approximately normal, or , or for a smaller sample the data show no strong skew or outliers.
The same procedure handles matched pairs. Two measurements on each individual, or on each matched pair, are reduced to one column of differences, and the test is run on that column with . The full walk-through is in one-sample t-test step by step.
The two-sample t-test
Use it when two independent groups each give a mean and a standard deviation: two independent random samples, or the two treatment groups of a randomized experiment. The test statistic is
The denominator is the standard error of the difference between the sample means. Each group contributes its own variance divided by its own sample size, because both sample means vary.
The degrees of freedom come from technology. The value lies between the smaller of and and the total , and it is usually a decimal, as why is df a decimal in a two-sample t-test explains.
Conditions: two independent random samples or a randomized experiment; the 10% condition for each sample when sampling without replacement; and the normality check applied to both groups, so both sample sizes are at least 30, or both populations are stated to be approximately normal, or neither smaller sample shows strong skew or outliers. You can run the numbers with the two-sample t-test calculator.
The differences side by side
| Feature | One-sample t-test | Two-sample t-test |
|---|---|---|
| Sets of data | One | Two independent groups |
| Parameter | , or for matched pairs | |
| Null hypothesis | ||
| Comparison value | A fixed number from the problem | The other group's mean |
| Numerator of | ||
| Standard error | ||
| Degrees of freedom | From technology | |
| Normality check | On the one sample | On both samples |
Both tests share the same skeleton: a difference in the numerator, a standard error in the denominator, and a curve for the p-value. The two-sample version has two sources of sampling variability, so its standard error has two terms.
When to use which
Work through three checks.
- Confirm the response variable is quantitative, so that means make sense. If it is categorical, neither test applies and you need a proportion or chi-square procedure.
- Count the groups. One group measured once, compared with a number stated in the problem, is a one-sample t-test.
- If there are two sets of numbers, decide whether they are independent or paired. Two separate groups of individuals call for a two-sample t-test. Two measurements linked one-to-one, such as before and after on the same people, call for a one-sample t-test on the differences.
A second set of numbers is not always a second sample. If a problem says "the national average is 8 hours," that 8 is a fixed value with no sampling variability, so the test is one-sample. If the national figure came from its own sample with its own standard deviation, the comparison is two-sample. The which test interactive walks through these choices.
The classic mix-up and how to avoid it
The most costly error is running a two-sample t-test on paired data. Before-and-after scores on the same 12 students look like two samples of 12, and the two-sample standard error treats them as independent. It ignores the link within each pair, and when the paired values rise and fall together the test can miss a consistent change that the differences show clearly. Paired data are one sample of differences. The details are in paired vs two-sample t-test.
The reverse error is running a one-sample test when the comparison value was itself estimated from a sample. Plugging a second group's sample mean in as treats it as exact and leaves its variability out of the standard error, which makes the standard error too small and pushes the test statistic too far from 0.
A third slip is using degrees of freedom, or , for a two-sample test. Take the degrees of freedom from technology.
To avoid all three, describe the data in one sentence before choosing: how many groups of individuals there are, how many measurements each individual gave, and whether any comparison number was given or estimated.
One sample against a claimed value
A health teacher believes students at a large high school average less than the recommended 8 hours of sleep. A random sample of 20 students has mean hours and hours, and a dotplot of the data shows no strong skew or outliers. Test at .
Identify the test. There is one sample and a fixed claimed value of 8 hours, so this is a one-sample t-test for a population mean.
State the hypotheses: and , where is the mean sleep time of all students at the school.
Check conditions: random sample; 20 students is under 10% of a large school; , and the dotplot shows no strong skew or outliers.
Standard error: .
Test statistic: , with degrees of freedom.
p-value: the area to the left of on 19 degrees of freedom is 0.0188.
Decide: , so reject .
with 19 degrees of freedom and a p-value of 0.0188. Reject : there is convincing evidence that the mean sleep time of students at this school is less than 8 hours. The 8 was a fixed value, so only one standard error term, , was needed.
Two independent samples against each other
A district compares exam scores at two large schools using independent random samples. School 1: , , . School 2: , , . Test whether the mean scores differ at .
Identify the test. There are two independent groups and no claimed value for either mean, so this is a two-sample t-test for a difference between two population means.
State the hypotheses: and , where and are the mean exam scores of all students at School 1 and School 2.
Check conditions: independent random samples; each sample is under 10% of a large school; both sample sizes are at least 30.
Compute each variance term: and .
Standard error: .
Test statistic: .
Degrees of freedom from technology: 62.91, which lies between and . The two-sided p-value is 0.0625.
Decide: , so fail to reject .
with 62.91 degrees of freedom and a two-sided p-value of 0.0625. Fail to reject : the samples do not give convincing evidence that the mean exam scores at the two schools differ. Both sample means vary, so the standard error combined a variance term from each school.
Frequently asked questions
Is a paired t-test a one-sample or a two-sample test?
One-sample. Each pair is reduced to a single difference, and the test is a one-sample t-test on those differences with and degrees of freedom, where is the number of pairs. A two-sample t-test requires the two groups to be independent.
Why does the two-sample standard error have two terms?
Because two sample means vary from sample to sample. For independent samples, the variance of is the sum of the two variances, estimated by . A one-sample test compares with a fixed number, which has no variability to add.
Can the two samples have different sizes in a two-sample t-test?
Yes. The standard error divides each group's variance by its own sample size, so and do not need to match. Unequal sizes are a sign the data are not paired, since paired data always have the same number of values in each column.