Maths

t-Test Calculator

Compare two sample means with Welch’s t-test from summary statistics: t, degrees of freedom and p-value.

By Nitin Raturi · Last reviewed

Your worksheet

How to use the t-Test Calculator

Compare two sample means with Welch’s t-test from their summary statistics.

  1. Enter the mean, standard deviation and size of each sample.
  2. Choose two-tailed, left or right.
  3. Set the significance level.
  4. Read t, the degrees of freedom and the p-value.

Good to know

  • Welch’s test does not assume the two groups have the same spread.

t = (x̄₁ − x̄₂) ÷ √(s₁²/n₁ + s₂²/n₂), with Welch’s degrees of freedom.

Sample 1 mean

The average of the first sample.

How to fill it in

  • Enter any number.

Sample 1 standard deviation

The sample standard deviation of the first group.

How to fill it in

  • Enter a number above 0.

Sample 1 size

How many observations in the first group.

How to fill it in

  • Enter a whole number from 2.

Sample 2 mean

The average of the second sample.

How to fill it in

  • Enter any number.

Sample 2 standard deviation

The sample standard deviation of the second group.

How to fill it in

  • Enter a number above 0.

Sample 2 size

How many observations in the second group.

How to fill it in

  • Enter a whole number from 2.

Example

Girls (mean 2, SD 0.866, n 9) vs boys (3.2, 1, 16): t = -3.14, df 18.85, p = 0.0054.

Alternative hypothesis

The direction of difference you are testing.

How to fill it in

  • Two-tailed: the means differ.
  • Left: mean 1 is smaller.
  • Right: mean 1 is larger.

Example

OpenStax’s right-tailed college example gives p = 0.1928.

Significance level (%)

The p-value below which you reject equal means, chosen in advance.

How to fill it in

  • 5% is common.

Example

Identical means give t = 0 and p = 1.0000.

Welch t-test, alternative μ₁ ≠ μ₂

p = 0.0054

t = -3.1424 with 18.85 degrees of freedom gives p = 0.0054, which is below α = 5%: reject the hypothesis of equal means.

Difference of means
-1.2000
Standard error
0.3819
t statistic
-3.1424
Degrees of freedom
18.8466
p-value
0.0054

Two independent random samples from roughly normal populations, with variances not assumed equal (Welch’s test).

How this calculator works

  1. Step 1Differencex̄₁ − x̄₂How far apart the means are.
  2. Step 2Standard error√(s₁²/n₁ + s₂²/n₂)How much that difference wobbles.
  3. Step 3p-valuet with Welch dfHow surprising the difference is.

The t statistic is the difference between the sample means divided by its standard error. A large t, in either direction, is evidence that the population means differ.

Welch’s version does not assume equal variances, and works out the degrees of freedom from both samples.

Worked example: OpenStax Example 10.1

Hours of sport: girls (n 9) vs boys (n 16)
t
(2 − 3.2) ÷ √(0.866²/9 + 1²/16)
  1. Difference−1.2
  2. Standard error0.3819
  3. t-3.14
  4. Degrees of freedom18.85
  5. Two-tailed p0.0054

OpenStax gives t = −3.14, df ≈ 18.8462 and p = 0.0054.

Read the result

  • Example 10.1p = 0.0054Below 5%: the means differ.
  • Example 10.2p = 0.1928Right-tailed; not enough evidence at 5%.

Identical sample means give t = 0 and p = 1.0000: no evidence of a difference.

Assumptions and limits

  • Independent groupsNot paired or repeated measures.
  • Roughly normalOr reasonably large samples.
  • Sample SDsUse n − 1 standard deviations.
  • Not pairedPaired data needs a one-sample t-test on differences.

A t-test compares two means. Spread, intervals and other tests sit around it.

To turn any test statistic into a p-value, use the p-value calculator. The confidence interval calculator gives a margin of error, and the chi-square calculator tests counts in categories.

Common mistakes

  • Mistake: Using population SDs as sample SDs.

    Instead: Use the sample standard deviations.

  • Mistake: Running a two-sample test on paired data.

    Instead: Test the differences instead.

Checking the method

A separate script integrates the t curve numerically and reproduces OpenStax Examples 10.1 and 10.2.

Read how we test our calculators, or browse more maths calculators.

Frequently asked questions

What is the p-value for OpenStax Example 10.1?

t = -3.14 with 18.85 df gives p = 0.0054, as OpenStax finds.

What is Welch’s t-test?

A two-sample t-test that does not assume the groups have equal variances, with Satterthwaite degrees of freedom.

What about a one-tailed test?

Choose left or right. OpenStax’s right-tailed college example gives p = 0.1928.

What if the means are equal?

t = 0 and the two-tailed p-value is 1.0000.

Can I use it for paired data?

No. For paired data, test the differences with a one-sample t-test.

Sources and methodology

The formulas are standard time-value-of-money results. We check every figure against golden values worked out independently, by closed form and by month-by-month simulation; see the methodology.

Written and maintained by Nitin Raturi, a software engineer (about the author). Last reviewed 4 Nov 2026; next review due by . Found an error? Tell us.

Changelog

  • : Initial release.