Two-sample t-test calculator (Welch)
By Jude Wallis · Published
A two-sample (independent) t-test checks whether two population means differ. Enter each group's mean, standard deviation, and sample size to get the standard error, the t statistic, the Welch degrees of freedom, and a p-value.
two-sample t-test (Welch df = 59.91)
t = 2.1576, p = 0.035
At alpha = 0.05: reject the null hypothesis. Assumes two independent samples (for paired data, use the one-sample test on differences).
Steps
- 1.difference = 78.2 - 74.5 = 3.7
- 2.SE = sqrt(s1²/n1 + s2²/n2) = sqrt(1.3653 + 1.5753) = 1.71483
- 3.t = 3.7 / 1.71483 = 2.1576
- 4.df (Welch-Satterthwaite, the software formula) = 59.91
- 5.p-value = 0.035
AP Statistics: Unit 4 (topics 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). This is the hypothesis-test half of Unit 4, topics 4.9 and 4.10, in the Fall 2026 AP Statistics course, where the exam expects you to find the degrees of freedom and p-value with technology.
What a two-sample t-test compares
A two-sample t-test compares the means of two independent groups to decide whether the underlying population means differ. Independent means the two samples come from separate groups, with no pairing between an observation in one group and an observation in the other.
You work with six numbers: the two sample means and (the average of each group), the two sample standard deviations and (how spread out each group is), and the two sample sizes and . The test asks about the population means and , which you cannot observe directly.
This two sample t test calculator (also called an independent t test calculator) takes those six numbers and returns the standard error, the t statistic, the degrees of freedom, and a p-value. If your two measurements come from the same subjects, such as before and after, you want a paired t-test instead of this one.
The standard error and test statistic
The standard error (SE) measures how much the difference in sample means, , would bounce around from sample to sample. The AP formula sheet gives it as
Each group contributes its own variance divided by its own sample size, and the two pieces add under the square root. The sheet lists only this unpooled version for means, so there is no pooled two-sample formula for means to memorize.
The standardized test statistic follows the same template as every AP test, (statistic - parameter) divided by (standard error):
Under the null hypothesis the difference equals 0, so the top reduces to . A t value far from 0 is evidence that the population means are not equal.
Degrees of freedom for a two-sample t-test
Degrees of freedom (df) set the shape of the t-distribution you compare your t value against. For a two-sample t-test the df is usually not a whole number and is not simply .
Software computes it with the Welch-Satterthwaite formula:
You are not asked to compute this by hand on the AP exam. The College Board states only that the df falls between the smaller of and at the low end and at the high end, and that you find the exact value with technology. The Welch df is smaller than , which makes the test a little more cautious.
By hand, without a calculator, you can use the conservative choice: df = the smaller of and . That gives a larger p-value than the Welch df, so it never overstates your evidence.
Hypotheses and conditions
State the hypotheses about the population means. The null says the means are equal:
The alternative is two-sided when you only ask whether they differ, or one-sided when you have a direction:
Check three conditions before you trust the result:
- Random: the data come from two independent random samples or a randomized experiment.
- 10%: when sampling without replacement, each sample is at most 10% of its population. This is not needed for a randomized experiment.
- Normal or large: each sample size is at least 30, or each population is stated to be approximately normal. If either sample is under 30, both sets of sample data should be free of strong skewness and outliers.
How to use this calculator
Enter the sample mean, sample standard deviation, and sample size for each group, then pick a one-sided or two-sided alternative. The calculator returns:
- the standard error from the formula above,
- the t statistic,
- the Welch degrees of freedom,
- the p-value.
Compare the p-value to your significance level, often 0.05. A p-value below the level is evidence against , so you reject it and conclude the population means differ. A p-value above the level means you fail to reject , so the data are consistent with equal means. The worked example below runs every number by hand so you can check the tool digit by digit.
Comparing two fertilizers on plant height
A gardener grows tomato plants under two fertilizers. The 10 plants on fertilizer A have a mean height of 85 cm with a sample standard deviation of 8 cm. The 20 plants on fertilizer B have a mean height of 82 cm with a sample standard deviation of 3 cm. Plants were randomly assigned to the fertilizers. Test at the 0.05 level whether the mean heights differ. Let group 1 be fertilizer A (, , ) and group 2 be fertilizer B (, , ).
State the hypotheses. and , where and are the mean heights under fertilizers A and B.
Check conditions. The plants were randomly assigned, so this is a randomized experiment: the random condition holds and the 10% condition is not needed. Both samples are under 30, so assume both height distributions are approximately normal.
Compute each variance term. and .
Find the standard error. cm.
Compute the t statistic. The difference in sample means is cm, so .
Find the degrees of freedom. Welch-Satterthwaite gives . This is well below .
Find the p-value. For a two-sided test with and , software reports .
Decide. Since , you fail to reject .
cm, , Welch , and two-sided . Because , there is not enough evidence to conclude the mean tomato-plant heights differ between the two fertilizers.
Frequently asked questions
Should I use a pooled or Welch two-sample t-test?
Use the Welch (unpooled) version, which is what this calculator and the AP formula sheet use. It does not assume the two populations have equal variances, so it stays valid when the group spreads differ. Most statistical software defaults to Welch for the same reason.
Why is the degrees of freedom a decimal like 10.29?
The Welch-Satterthwaite formula that software uses produces a non-integer df, and the software applies it directly to find the p-value. The AP course only asks you to know that the df falls between the smaller of and and , with technology giving the exact value.
Is a two-sample t-test the same as a paired t-test?
No. A two-sample t-test compares two independent groups. A paired t-test is for dependent data, such as before-and-after measurements on the same subjects, and it analyzes the single set of differences with a one-sample t procedure.