T-Test Calculator

Enter the summary statistics of your sample or samples and choose the test. The calculator gives t, the degrees of freedom and the p-value.

Welch is the safe default for two samples; use pooled only when the two population variances are known to be equal.
The sample standard deviation (n − 1 denominator).
One-sample test only: the value the mean is compared against.
Two-sample tests only.
Two-sample tests only.
Two-sample tests only.

t statistic

1.75

Degrees of freedom

24

p-value

0.092895

Difference in means

2.1

Standard error of the difference

1.2

At the 5% level

p ≥ 0.05: not statistically significant at the 5% level

How it works

A t-test asks whether a difference in means is larger than the random variation you would expect from samples of this size. The t statistic is the observed difference divided by its standard error: how many standard errors the difference is from zero. The p-value is the probability of a t at least this extreme if the true difference were zero, read from Student's t distribution with the appropriate degrees of freedom.

The one-sample test compares one sample mean with a fixed hypothesized value. The two-sample tests compare two independent samples. Welch's version uses each sample's own variance and adjusts the degrees of freedom with the Welch–Satterthwaite formula, so it stays valid when the two spreads differ; the pooled version assumes equal variances and combines them, gaining a little power when that assumption is true.

A two-tailed p-value counts extreme results in either direction and answers "are the means different?". A one-tailed p-value counts only the direction you observed and is half as large; use it only if you decided the direction before seeing the data. The p-value is computed from the regularized incomplete beta function, the same route as statistical tables and software.

Formula

one-sample:   t = (x̄ − μ0) / (s / √n)                    df = n − 1
Welch:        t = (x̄1 − x̄2) / √(s1²/n1 + s2²/n2)
              df = (s1²/n1 + s2²/n2)² / [ (s1²/n1)²/(n1 − 1) + (s2²/n2)²/(n2 − 1) ]
pooled:       sp² = [ (n1 − 1) s1² + (n2 − 1) s2² ] / (n1 + n2 − 2)
              t = (x̄1 − x̄2) / √(sp² (1/n1 + 1/n2))         df = n1 + n2 − 2
two-tailed p  = I_x(df/2, 1/2)   with x = df / (df + t²)   (regularized incomplete beta)
one-tailed p  = two-tailed p / 2

Example

A sample of 25 has mean 52.1 and standard deviation 6, and you want to know whether the population mean differs from 50. The standard error is 6/√25 = 1.2, so t = 2.1/1.2 = 1.75 with 24 degrees of freedom. The two-tailed p-value is 0.0929: not significant at the 5% level, though a one-tailed test in the observed direction would give 0.0464.

Two groups: 25 scores with mean 85 and SD 10 against 30 scores with mean 80 and SD 12. Welch's test gives a standard error of √(100/25 + 144/30) = 2.9665, t = 1.6855, 53.00 degrees of freedom and a two-tailed p of 0.0978. The pooled test on the same figures gives t = 1.6576, 53 degrees of freedom and p = 0.1033.

Assumptions and limitations

  • Inputs are summary statistics: the sample mean, the sample standard deviation (with an n − 1 denominator) and the sample size. Raw data lists are not accepted; compute the summaries first.
  • Samples are independent random samples from populations that are roughly normal, or large enough for the sample means to be. For two-sample tests the two samples are independent of each other; paired data needs a paired t-test on the differences, which can be run here as a one-sample test of the differences against 0.
  • The pooled test assumes the two populations have the same variance. When in doubt use Welch.
  • The p-value is a statement about the data under the null hypothesis, not the probability that the null hypothesis is true. The 5% threshold in the verdict is a convention, not a law.
  • The p-value is computed numerically to about 1e-12 and agrees with published t-tables to the precision they print.

Frequently asked questions

Should I use the Welch or the pooled test?

Welch. It is valid whether or not the two variances are equal and loses almost nothing when they are. The pooled test is the one taught first in many courses, which is why it is offered, but it can give misleading p-values when the sample sizes and spreads both differ.

What do I enter for the standard deviation?

The sample standard deviation, the one that divides by n − 1 (STDEV.S in a spreadsheet, not STDEV.P). If you have the variance instead, enter its square root.