Skip to content

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.

Paired, one-sample, one-tailed, α, interval, effect size
Which test?
What do you have?
Group A
Group B
Method
What are you testing?
Significance level (α)
ResultUpdates as you type—p-value—t—Degrees of freedom—Difference in means

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. 1

    The difference

    26 − 22 = 4

  2. 2

    Standard error

    √(6.8/6 + 4.8/6) = 1.3904

  3. 3

    The t value

    4 ÷ 1.3904 = 2.8768

  4. 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
22.92004.30279.9248
52.01502.57064.0321
101.81252.22813.1693
201.72472.08602.8453
301.69732.04232.7500
601.67062.00032.6603
1201.65771.97992.6174
∞ (z)1.64491.96002.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

Confidence interval calculatorConfidence intervals for a mean (t or z), from a summary or raw data, proportions (Wald, Wilson, exact), two means (Welch) and two proportions, with one-sided bounds and a plain-English reading.Standard deviation calculatorStandard deviation, variance, mean, median, mode, quartiles, outliers and confidence intervals from a list or a frequency table.Z-score calculatorZ-score from a value, value from a z-score, percentiles, the area under the bell curve (left, right, between, outside), p-values and a z-table.Sample size calculatorHow many people to survey for your confidence level and margin of error, the margin for a sample you have, means, response rates, design effect and A/B test sample sizes with power.

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.

Embed this calculator on your site

Free to use on your website or blog. Paste this code where you want the calculator to appear. Please keep the credit link.

T-test calculator by Zulu Calculator ↗