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.
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 | Formula | Result |
|---|---|---|
| Difference in means | 12.45 − 11.4625 | 0.9875 |
| t statistic | 0.9875 ÷ √(s₁²/N₁ + s₂²/N₂) = 0.9875 ÷ 0.2859 | 3.45349 |
| Degrees of freedom | Welch–Satterthwaite formula | 13.778 |
| Two-tailed p-value | 2 × P(T > |3.4535|) with 13.778 degrees of freedom | 0.00396 |
How it works
Choose the test, paste your data into the sample boxes, and set your significance level.
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:
- Pooled standard deviation: 6.34260
- t statistic: −12.62059
- Degrees of freedom: 249 + 79 − 2 = 326
- 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.