T-Test Calculator
Paste the numbers for two groups, or type each group’s mean, standard deviation and size, to see whether the difference between them is statistically significant. Advanced adds paired and one-sample tests, one-tailed tests, other significance levels, the confidence interval and the effect size.
How your t-test is worked out
Your numbers, step by step: the gap between the means, its standard error, the t value, then the p-value.
- 1
The difference
26 − 22 = 4
- 2
Standard error
√(6.8/6 + 4.8/6) = 1.3904
- 3
The t value
4 ÷ 1.3904 = 2.8768
- 4
The p-value
df 9.71 → p = 0.0170
Read more: the formula, a worked example, which test to pick, and what the p-value does and doesn’t mean
A t-test asks whether a difference between averages is bigger than you would expect from chance alone. It compares the gap between the means with how much those means could wobble from sample to sample (the standard error). The ratio is the t value: the bigger it is, the less likely the gap is just luck. The t value and the degrees of freedom give the p-value.
The formula
Welch (two groups): t = (x̄₁ − x̄₂ − δ) ÷ √(s₁²/n₁ + s₂²/n₂)
Welch–Satterthwaite df = (s₁²/n₁ + s₂²/n₂)² ÷ [(s₁²/n₁)²/(n₁ − 1) + (s₂²/n₂)²/(n₂ − 1)]
Student’s pooled: sₚ = √[((n₁ − 1)s₁² + (n₂ − 1)s₂²) ÷ (n₁ + n₂ − 2)], t = (x̄₁ − x̄₂ − δ) ÷ (sₚ √(1/n₁ + 1/n₂)), df = n₁ + n₂ − 2
One sample: t = (x̄ − μ₀) ÷ (s ÷ √n), df = n − 1
Paired: work out each difference d = A − B, then t = (d̄ − δ) ÷ (s_d ÷ √n), df = n − 1
Two-tailed p = 2 × P(T ≥ |t|); one-tailed p = P(T ≥ t) or P(T ≤ t)
Confidence interval = difference ± t* × standard error
Cohen’s d = (x̄₁ − x̄₂) ÷ sₚ; Hedges’ g = d × (1 − 3 ÷ (4(n₁ + n₂ − 2) − 1))
In words: subtract one mean from the other, divide by the standard error of that difference, and you have t. The p-value is the share of the t distribution (with your degrees of freedom) that lies as far out as your t or further, on both sides for a two-tailed test. If p is below α, the result is called statistically significant. δ is the difference you test against, usually 0.
Worked example
Group A: 23, 25, 28, 30, 26, 24. Group B: 20, 22, 25, 19, 23, 23. Welch’s test, two-tailed, α = 0.05.
- Means: A = 156 ÷ 6 = 26 and B = 132 ÷ 6 = 22, so the difference is 4.
- Variances: A’s squared deviations are 9, 1, 4, 16, 0, 4 = 34, so s₁² = 34 ÷ 5 = 6.8 (s₁ = 2.607681). B’s are 4, 0, 9, 9, 1, 1 = 24, so s₂² = 24 ÷ 5 = 4.8 (s₂ = 2.190890).
- Standard error = √(6.8 ÷ 6 + 4.8 ÷ 6) = √(1.133333 + 0.8) = √1.933333 = 1.390444.
- t = 4 ÷ 1.390444 = 2.876780.
- df = 1.933333² ÷ (1.133333² ÷ 5 + 0.8² ÷ 5) = 3.737778 ÷ (0.256889 + 0.128) = 3.737778 ÷ 0.384889 = 9.7113.
- Two-tailed p = 2 × P(T ≥ 2.876780 with 9.7113 df) = 0.016950. That is below 0.05, so the difference is statistically significant at the 5% level.
- 95% confidence interval: t* = 2.237150, margin = 2.237150 × 1.390444 = 3.110630, so 4 ± 3.110630 = 0.889 to 7.111.
- Effect size: sₚ = √((34 + 24) ÷ 10) = √5.8 = 2.408319, Cohen’s d = 4 ÷ 2.408319 = 1.6609 (very large), Hedges’ g = 1.6609 × (1 − 3 ÷ 39) = 1.5331.
- Student’s pooled test on the same data gives the same t (the groups are the same size) with df = 10 and p = 0.016476.
One sample: 5, 6, 7, 8, 9 against μ₀ = 5. Mean 7, s = √(10 ÷ 4) = 1.581139, SE = 1.581139 ÷ √5 = 0.707107, t = 2 ÷ 0.707107 = 2.828427, df 4, two-tailed p = 0.047421.
Paired: the same two lists as before-and-after pairs. Differences 3, 3, 3, 11, 3, 1: mean 24 ÷ 6 = 4, squared deviations 1, 1, 1, 49, 1, 9 = 62, so s_d = √(62 ÷ 5) = 3.521363, SE = 3.521363 ÷ √6 = 1.437591, t = 4 ÷ 1.437591 = 2.782433, df 5, two-tailed p = 0.038790.
What the result does and doesn’t tell you
- Significant means “unlikely to be chance alone”, if the test’s assumptions hold. It does not mean the difference is large or important. Look at the confidence interval and Cohen’s d for that.
- Not significant is not proof of no difference. A small sample can easily miss a real difference. The confidence interval shows the range of differences your data can’t rule out.
- The p-value is not the chance that the null hypothesis is true, and 1 − p is not the chance your result is real.
- It says nothing about cause. Only a well-designed experiment (for example random assignment) lets you say one thing caused the difference.
Which test to pick
- Two separate groups (different people in each): Welch’s t-test. Use Student’s pooled test only if you have good reason to think both groups have the same spread.
- The same people measured twice, or matched pairs: the paired t-test. Treating paired data as two groups throws away the pairing and usually loses a lot of power.
- One group against a fixed number (a target, a label claim, a known average): the one-sample t-test.
- Three or more groups: use ANOVA rather than many t-tests, which inflate the chance of a false alarm.
Assumptions
- Independent values: each person or item counts once and doesn’t affect the others (for paired data, the pairs are independent).
- Roughly normal: the data (or the paired differences) should be roughly bell-shaped, with no wild outliers. With 30 or more per group the test copes well with moderate skew. For small, very skewed samples, consider the Mann–Whitney U or Wilcoxon signed-rank test.
- Equal spread (Student’s pooled only): if one SD is more than about twice the other, use Welch.
Critical t values (two-tailed)
| df | α = 0.10 | α = 0.05 | α = 0.01 |
|---|---|---|---|
| 2 | 2.9200 | 4.3027 | 9.9248 |
| 5 | 2.0150 | 2.5706 | 4.0321 |
| 10 | 1.8125 | 2.2281 | 3.1693 |
| 20 | 1.7247 | 2.0860 | 2.8453 |
| 30 | 1.6973 | 2.0423 | 2.7500 |
| 60 | 1.6706 | 2.0003 | 2.6603 |
| 120 | 1.6577 | 1.9799 | 2.6174 |
| ∞ (z) | 1.6449 | 1.9600 | 2.5758 |
For a one-tailed test at α, use the two-tailed column for 2α (for example one-tailed 0.05 uses the 0.10 column). p-values are computed from Student’s t distribution with the regularised incomplete beta function and checked against SciPy: for 5, 6, 7, 8, 9 against 5, t = 2.8284, df 4, p = 0.04742.
Common questions
How do I do a two-sample t-test?
Work out each group’s mean and standard deviation. Divide each variance (SD squared) by its group size, add the two, and take the square root to get the standard error. Divide the difference in means by that standard error to get t. Then look up t with the degrees of freedom to get the p-value. For 23, 25, 28, 30, 26, 24 against 20, 22, 25, 19, 23, 23: means 26 and 22, SE 1.3904, t = 2.8768, df 9.71, p = 0.0170.
Should I use Welch’s t-test or Student’s t-test?
Use Welch’s test unless you have a good reason not to. It doesn’t assume the two groups have the same spread, and when they do it gives almost the same answer as Student’s pooled test. Student’s test can give misleading p-values when the spreads and the group sizes are both different.
What does the p-value mean?
It is the chance of getting a difference at least as big as yours if there were really no difference. A small p-value (below your α, often 0.05) means your result would be unusual under “no difference”, so you call it statistically significant. It is not the chance that there is no difference, and it says nothing about how big or important the difference is.
When should I use a paired t-test?
When each number in one list belongs with one number in the other: the same people before and after, left and right hands, or matched pairs. The paired test works on the differences, which removes the person-to-person variation and is usually much more sensitive than treating the lists as two separate groups.
One-tailed or two-tailed?
Use two-tailed unless you decided before seeing the data that only one direction matters. A one-tailed test halves the p-value in the direction you picked, but it cannot detect a difference the other way. Switching to one-tailed after looking at the data is cheating.
What is a good effect size?
Cohen’s d is the difference in means divided by the pooled standard deviation. Rough guides are 0.2 small, 0.5 medium and 0.8 large. Hedges’ g is the same thing with a small correction for small samples. Always report it with the p-value: a tiny effect can be significant in a huge sample, and a big effect can miss significance in a small one.
Related calculators
Made by Zulu Calculator, part of AlphaZulu LLC. Formulas are shown in full and rule figures are checked against official sources; see how we build calculators.