T-Test Calculator
Welch's t, df, and p from two means, SDs, and sample sizes, with a decision at alpha.
What it does
A two-sample t-test asks whether two group means differ more than sampling noise explains. The inputs are deliberately frugal: each group's mean, standard deviation, and sample size, the summary statistics every study reports.
This calculator runs Welch's version, which does not assume the two groups share a variance. NIST's handbook recommends it as the default two-sample test precisely because it holds its error rate when spreads differ, the common real-world case.
The machinery is a few lines: the standard error combines both spreads, t is the mean difference over that error, and the degrees of freedom come from the Welch-Satterthwaite formula, which is why df can be fractional (18.85 in the example). The p-value then reads from the t distribution with the tail you choose.
The decision rule is p versus alpha: reject equal means when p is smaller. The p-value itself is the probability of a difference this large or larger if the means were truly equal, under the model's assumptions.
How to use
- Enter group 1's mean, standard deviation, and sample size.
- Enter group 2's the same way.
- Pick two-tailed or a committed one-tailed direction.
- Pick the significance level.
- Read t and the Welch degrees of freedom.
- Read the p-value and the reject or fail-to-reject decision.
Formula
- x̄1, x̄2
- The two group means.
- s1, s2
- Sample standard deviations.
- n1, n2
- Sample sizes.
- SE
- Standard error of the difference in means.
- df
- Welch-Satterthwaite degrees of freedom, often fractional.
Welch keeps its significance level under unequal variances, which is why NIST recommends it broadly. Fractional degrees of freedom are normal; printed t tables round down, software uses the exact value. One-tailed tests should be chosen before seeing the data, and p-values say nothing about effect size: report the mean difference too.
Worked example
Example: OpenStax girls versus boys study hours
Girls: mean 2.0 h, SD 0.866, n 9. Boys: mean 3.2 h, SD 1.0, n 16. Two-tailed, alpha 0.05.
- SE = sqrt(0.750/9 + 1/16) = sqrt(0.14583) = 0.3819.
- t = (2.0 - 3.2) / 0.3819 = -3.14.
- Welch df = 18.85.
- Two-tailed p = 0.0054.
- 0.0054 < 0.05, so reject the null: the means differ.
- Tool shows t -3.14, df 18.85, p 0.0054, reject at 0.05.
Reference table
| Boys' mean | Difference | t | p (two-tailed) |
|---|---|---|---|
| 2.5 | -0.5 | -1.31 | 0.2062 |
| 3.0 | -1.0 | -2.62 | 0.0170 |
| 3.2 | -1.2 | -3.14 | 0.0054 |
| 3.5 | -1.5 | -3.93 | 0.0009 |
| 4.0 | -2.0 | -5.24 | under 0.0001 |
Limits
- Compares two independent groups; paired or repeated measures need a paired t-test.
- Welch's unequal-variance version; a pooled Student t will differ slightly with matched spreads.
- One comparison at a time; many tests or groups need ANOVA or multiplicity corrections.
- Assumes independent observations and roughly continuous, well-behaved data.
Common mistakes
- Running two-tailed, then claiming a direction after seeing the sign.
- Treating p < 0.05 as proof of a large or important effect.
- Pooling variances when the spreads differ several-fold.
- Entering the number of groups where sample size belongs.
- Reporting the p-value without the direction and size of the difference.
Try it yourself
Quick checks. Answers sit tucked under each question.
College hours: group 1 mean 4.0, SD 1.5, n 11; group 2 mean 3.5, SD 1.0, n 9; one-tailed greater?
t 0.89, df 17.4, p 0.1928; fail to reject at 0.01.
Same data, two-tailed?
p 0.3856; still fail to reject.
Reading: 5.0 ± 1.2 (n 15) versus 4.5 ± 0.8 (n 20)?
t 1.40, df 23.01, p 0.1756, fail to reject.
Questions
Welch or Student t?
Welch skips the equal-variance assumption and is NIST's recommended default; Student pools variances. With similar spreads the two agree closely.
What does the p-value mean here?
The chance of a difference at least this large if the group means were truly equal, for the tail or tails chosen. Small p is evidence against equal means, not proof of a big one.
One-tailed or two-tailed?
Two-tailed detects any difference; one-tailed commits to a direction before collecting data. Decide first, or the p-value means little.
Why is df 18.85?
Welch-Satterthwaite computes degrees of freedom from both spreads and sizes, and the result is often fractional. Printed tables round down; calculators use the exact value.
How large a sample do I need?
It depends on the true difference and the spreads: bigger n, tighter SDs, or a larger real gap all raise power. This example works because 1.2 h dwarfs the spreads.
Does significance mean importance?
No. With huge samples, tiny trivial differences turn significant. Always report the difference itself alongside the p-value.
Sources
- NIST Engineering Statistics Handbook: Two-Sample t-Test for Equal Means
- OpenStax Introductory Statistics 2e: Two Population Means with Unknown Standard Deviations