T-Test Calculator

Welch's t, df, and p from two means, SDs, and sample sizes, with a decision at alpha.

Math and PercentUpdated 2026-10-172 min read
T-Test Calculator
t statistic
...
Welch degrees of freedom...
p-value...
Decision...

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

  1. Enter group 1's mean, standard deviation, and sample size.
  2. Enter group 2's the same way.
  3. Pick two-tailed or a committed one-tailed direction.
  4. Pick the significance level.
  5. Read t and the Welch degrees of freedom.
  6. Read the p-value and the reject or fail-to-reject decision.

Formula

SE = sqrt(s1²/n1 + s2²/n2). t = (x̄1 - x̄2) / SE. df = (s1²/n1 + s2²/n2)² / [ (s1²/n1)²/(n1-1) + (s2²/n2)²/(n2-1) ]. p from the t distribution by tail.
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.

  1. SE = sqrt(0.750/9 + 1/16) = sqrt(0.14583) = 0.3819.
  2. t = (2.0 - 3.2) / 0.3819 = -3.14.
  3. Welch df = 18.85.
  4. Two-tailed p = 0.0054.
  5. 0.0054 < 0.05, so reject the null: the means differ.
  6. Tool shows t -3.14, df 18.85, p 0.0054, reject at 0.05.

Reference table

Same groups, different boys' mean (n 9 vs 16; SD 0.866 and 1)
Boys' meanDifferencetp (two-tailed)
2.5-0.5-1.310.2062
3.0-1.0-2.620.0170
3.2-1.2-3.140.0054
3.5-1.5-3.930.0009
4.0-2.0-5.24under 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

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.