T-Test Calculator

Run a one-sample, two-sample (Welch or pooled) or paired t-test from your data and get t, degrees of freedom and the p-value.

Formula explained below

Numbers separated by commas, spaces or new lines

Numbers separated by commas, spaces or new lines

Usually 0.05

Two-tailed p-value

0.00396

t statistic
3.4535
Degrees of freedom
13.78
Difference in means
0.9875
At your significance level
Reject the null hypothesis (p < 0.05)

t = 3.453 with 13.78 degrees of freedom gives a two-tailed p-value of 0.004, which is below 0.05. The difference is statistically significant at that level.

Calculation breakdown

Step-by-step calculation
StepFormulaResult
Difference in means12.45 − 11.46250.9875
t statistic0.9875 ÷ √(s₁²/N₁ + s₂²/N₂) = 0.9875 ÷ 0.28593.45349
Degrees of freedomWelch–Satterthwaite formula13.778
Two-tailed p-value2 × P(T > |3.4535|) with 13.778 degrees of freedom0.00396

How it works

Choose the test, paste your data into the sample boxes, and set your significance level.

Welch: T = (Mean₁ − Mean₂) ÷ √(s₁²/N₁ + s₂²/N₂)Welch–Satterthwaite: df = (s₁²/N₁ + s₂²/N₂)² ÷ [(s₁²/N₁)²/(N₁ − 1) + (s₂²/N₂)²/(N₂ − 1)]Pooled: s_p = √(((N₁ − 1)s₁² + (N₂ − 1)s₂²) ÷ (N₁ + N₂ − 2)); T = (Mean₁ − Mean₂) ÷ (s_p × √(1/N₁ + 1/N₂)); df = N₁ + N₂ − 2One-sample and paired: T = (Mean − Hypothesized mean) ÷ (s ÷ √n); df = n − 1

Worked example

The NIST example compares miles per gallon for 249 U.S. cars (mean 20.14458, standard deviation 6.41470) and 79 Japanese cars (mean 30.48101, standard deviation 6.10771), assuming equal variances:

  1. Pooled standard deviation: 6.34260
  2. t statistic: −12.62059
  3. Degrees of freedom: 249 + 79 − 2 = 326
  4. Critical value at the 0.05 level (two-tailed): 1.9673. Since |T| is far larger, the means differ.

Rounding

Results are shown to four to six decimal places. Calculations use the unrounded values.

Sources

Frequently asked questions

What is a t-test?

A t-test checks whether a sample mean differs from a value, or whether two means differ from each other, taking into account the spread in the data and the sample sizes. It gives a t statistic and a p-value. A small p-value means the difference is unlikely to be due to chance alone.

Which t-test should I use?

Use the one-sample test to compare one group to a known mean, the paired test for before-and-after measurements on the same subjects, and a two-sample test for two separate groups. For two groups, NIST describes the Welch test as robust for unequal sample sizes or variances, so it is the safer default.

How are the degrees of freedom calculated?

For a one-sample test they are n − 1. For a pooled two-sample test they are N₁ + N₂ − 2. For the Welch test the calculator uses the Welch–Satterthwaite formula, which usually gives a smaller, non-integer value.

What does the p-value mean?

The two-tailed p-value is the probability of a t statistic at least as extreme as yours, in either direction, if the null hypothesis were true. If it is below your significance level, usually 0.05, you reject the null hypothesis. It is not the probability that the null hypothesis is true.

Does the calculator match published examples?

Yes. It reproduces the NIST e-Handbook example comparing miles per gallon for U.S. and Japanese cars, where T = −12.62059 with 326 degrees of freedom and the critical value is 1.9673 at the 0.05 level.

Results are for information only. A t-test assumes roughly normal data and independent observations. Check that these hold for your data.