T-Test Calculator

A t-test calculator checks whether a difference between means is larger than chance would explain. Two classes scored a mean of 80.2 (n = 10) and 71.67 (n = 9). Welch’s two-sample t-test gives t = 2.986 with df = 16.43 and a two-tailed p-value of 0.0085. That is below α = 0.05, so the difference is statistically significant.

t-test calculator
Data entry
Alternative hypothesis H₁
Separate values with commas, spaces or new lines, or paste a column from a spreadsheet.
Variances
Try:
Welch two-sample t-test, two-tailed
t = 2.9858

t(16.43) = 2.986, p = 0.0085. p ≤ α = 0.05: the difference is statistically significant, so reject H₀.
p-value (two-tailed)0.0085
Degrees of freedom16.4286
Difference x̄₁ − x̄₂8.5333
Standard error2.8579
95% CI for μ₁ − μ₂[2.4876, 14.5791]
Critical t (α = 0.05)−2.1154 / 2.1154
Cohen’s d1.35 (large)
Hedges’ g1.289
Decision at α = 0.05
Reject H₀: μ₁ − μ₂ differs from 0 (statistically significant)
n Mean SD SE
Group 1 10 80.2 7.1305 2.2549
Group 2 9 71.6667 5.2678 1.7559
Your data

Dot plot of each group with its mean marked by a vertical bar.Group 1Group 2708090

bar = mean
T distribution with df = 16.4286

Curve of the t distribution with df = 16.4286. The shaded area is the p-value for t = 2.9858. Dashed red lines mark the critical values at alpha 0.05.−4−3−2−101234

shaded area = p-valuet = 2.986critical values −2.115 and 2.115 (α = 0.05)
Show steps
  1. Hypotheses. H₀: μ₁ − μ₂ = 0. H₁: μ₁ − μ₂ ≠ 0 (two-tailed, α = 0.05).
  2. Group 1: n₁ = 10, x̄₁ = 802 / 10 = 80.2, s₁ = √(Σ(x − x̄₁)² / (n₁ − 1)) = √(457.6 / 9) = 7.1305.
  3. Group 2: n₂ = 9, x̄₂ = 645 / 9 = 71.6667, s₂ = √(222 / 8) = 5.2678.
  4. Welch standard error: SE = √(s₁²/n₁ + s₂²/n₂) = √(5.0844 + 3.0833) = 2.8579.
  5. Welch–Satterthwaite df = (s₁²/n₁ + s₂²/n₂)² / [ (s₁²/n₁)²/(n₁ − 1) + (s₂²/n₂)²/(n₂ − 1) ] = 16.4286.
  6. t = (x̄₁ − x̄₂ − 0) / SE = (80.2 − 71.6667) / 2.8579 = 2.9858.
  7. Two-tailed p-value = 2 × P(T ≥ |2.9858|) with df = 16.43 = 2 × 0.0043 = 0.0085.
  8. Decision: p = 0.0085 ≤ 0.05, so reject H₀. Check with the critical value: reject when t is beyond ±2.1154; t = 2.9858 is in the rejection region.
  9. 95% confidence interval: μ₁ − μ₂ ± t* × SE, with t* = 2.1154 (the two-sided critical value for df = 16.43). 8.5333 ± 2.1154 × 2.8579 = [2.4876, 14.5791].
  10. Effect size: Cohen’s d = (x̄₁ − x̄₂) / sₚ = 8.5333 / 6.3227 (pooled SD) = 1.35. By Cohen’s rough guide (0.2 small, 0.5 medium, 0.8 large) this is large.
Welch’s test does not assume equal variances and is a safe default. With equal sample sizes and similar SDs it gives almost the same answer as the pooled test.

How to use the t-test calculator

  1. Pick the test: Two-sample for two separate groups, Paired for the same subjects measured twice, One-sample to compare one mean with a known value μ₀.
  2. Choose Raw data and paste your values (commas, spaces or a spreadsheet column all work), or choose Summary and type the mean, standard deviation and n.
  3. Pick the alternative hypothesis: two-tailed (≠) unless you decided on a direction before you collected the data.
  4. For two samples, keep Welch (the default) unless you have a good reason to assume equal variances.

The result shows t, the degrees of freedom, the p-value, a confidence interval for the mean or difference, Cohen’s d, a table of group statistics, a dot plot of your data, the t curve with the p-value area shaded, and every step of the working.

Which t-test should you use?

Your data Test Degrees of freedom
One sample compared with a target or claimed mean One-sample t-test n − 1
Two independent groups (different people in each) Welch two-sample t-test Welch–Satterthwaite formula (often a decimal)
Two independent groups with equal variances Pooled (Student) t-test n₁ + n₂ − 2
Same subjects twice, or matched pairs Paired t-test number of pairs − 1

The quick test for pairing: if each value in one column belongs with one specific value in the other column (the same student before and after, the left and right eye of one patient), the data are paired. If you could shuffle one column without losing information, they are independent.

T-test formulas

Every t statistic has the same shape: t = (estimate − value under H₀) / standard error. Here x̄ is a sample mean, s a sample standard deviation and n a sample size.

  • One-sample: t = (x̄ − μ₀) / (s / √n), df = n − 1.
  • Welch two-sample: t = (x̄₁ − x̄₂) / √(s₁²/n₁ + s₂²/n₂), with df = (s₁²/n₁ + s₂²/n₂)² / [(s₁²/n₁)²/(n₁ − 1) + (s₂²/n₂)²/(n₂ − 1)].
  • Pooled two-sample: sₚ² = [(n₁ − 1)s₁² + (n₂ − 1)s₂²] / (n₁ + n₂ − 2), t = (x̄₁ − x̄₂) / (sₚ√(1/n₁ + 1/n₂)), df = n₁ + n₂ − 2.
  • Paired: find each difference d = A − B, then t = d̄ / (s(d) / √n), df = n − 1. It is a one-sample t-test on the differences.

The confidence interval uses the same pieces: estimate ± t* × SE, where t* is the two-sided critical value for your df. Cohen’s d expresses the difference in standard deviations: (x̄₁ − x̄₂) / sₚ for two samples, d̄ / s(d) for pairs and (x̄ − μ₀) / s for one sample.

Worked examples

Two-sample (Welch): test scores in two classes

Class 1: 82, 75, 91, 68, 77, 85, 79, 88, 73, 84. Class 2: 71, 69, 78, 64, 80, 70, 75, 66, 72. The means are 80.2 and 71.67, the SDs 7.131 and 5.268.

  1. s₁²/n₁ = 50.844 / 10 = 5.084 and s₂²/n₂ = 27.75 / 9 = 3.083, so SE = √(5.084 + 3.083) = 2.858.
  2. t = (80.2 − 71.67) / 2.858 = 8.533 / 2.858 = 2.986.
  3. Welch df = 8.168² / (5.084²/9 + 3.083²/8) = 16.43.
  4. Two-tailed p = 0.0085, the 95% confidence interval for μ₁ − μ₂ is 2.49 to 14.58 points, and Cohen’s d = 1.35 (large).

The pooled test on the same data gives t = 2.937 with df = 17 and p = 0.0092. The answers are close because the two SDs are similar.

Paired: a skill score before and after practice

Eight students scored 68, 74, 71, 80, 77, 65, 72, 79 after practice and 64, 70, 72, 74, 73, 62, 69, 75 before. The differences are 4, 4, −1, 6, 4, 3, 3, 4, with mean d̄ = 3.375 and s(d) = 1.996.

SE = 1.996 / √8 = 0.7055, so t = 3.375 / 0.7055 = 4.784 with df = 7. The two-tailed p-value is 0.0020, the 95% confidence interval for the mean gain is 1.71 to 5.04 points, and d = 3.375 / 1.996 = 1.69.

One-sample: do the bags hold 12 ounces?

Ten bags weigh 12.1, 11.4, 13.0, 12.6, 11.9, 12.8, 12.2, 11.7, 12.5 and 13.1 oz. The mean is 12.33 and s = 0.5658, so SE = 0.5658 / √10 = 0.1789 and t = (12.33 − 12) / 0.1789 = 1.844 with df = 9.

The two-tailed p-value is 0.098, which is above 0.05, so the data do not show that the mean differs from 12 oz. The 95% confidence interval, 11.93 to 12.73, contains 12, which tells the same story.

Critical values of t

Reject H₀ when |t| is at least the critical value. The two-tailed α = 0.05 column is the t* used for 95% confidence intervals.

df One-tailed 0.05 Two-tailed 0.05 Two-tailed 0.01
1 6.314 12.706 63.657
5 2.015 2.571 4.032
10 1.812 2.228 3.169
15 1.753 2.131 2.947
20 1.725 2.086 2.845
30 1.697 2.042 2.750
60 1.671 2.000 2.660
120 1.658 1.980 2.617

Assumptions and common mistakes

  • Independence. Each observation must be independent of the others. Measuring the same person twice in a “two-sample” test breaks this; use the paired test.
  • Roughly normal data. With small samples, check the dot plot for strong skew or outliers. With about 30 or more per group the t-test is fairly robust. For badly skewed small samples, a rank test such as Mann–Whitney or Wilcoxon is safer.
  • Using the population SD formula. Use s with n − 1 in the denominator. Many spreadsheets offer both; STDEV.S is the right one.
  • Entering the standard error as the SD. If a paper reports mean ± SE, convert with SD = SE × √n before using the Summary mode.
  • Choosing the tail after seeing the data. Halving a two-tailed p-value after the fact inflates false positives.
  • Reading p as the effect size. A tiny p-value can come from a trivial difference in a huge sample. Report the confidence interval and Cohen’s d as well.

The two-sample formulas above follow the NIST/SEMATECH e-Handbook of Statistical Methods, section 1.3.5.3, Two-Sample t-Test for Equal Means. Every number on this page was re-checked with SciPy’s t-test functions.

T-test practice quiz: 10 questions

Test yourself with 10 multiple-choice questions. Choose an answer and press Submit to see if you are right and why. Your score appears at the end.

Question 1 of 10
1. A one-sample t-test uses 15 observations. How many degrees of freedom does it have?

Found a mistake? Let us know!

2. A sample of n = 16 has mean 52 and SD 8. What is t for H₀: μ = 50?

Found a mistake? Let us know!

3. A pooled two-sample t-test has n₁ = 12 and n₂ = 10. What is df?

Found a mistake? Let us know!

4. The same 20 patients have their blood pressure measured before and after a drug. Which test fits?

Found a mistake? Let us know!

5. For paired data the differences have mean 2.5, SD 5 and n = 25. What is t?

Found a mistake? Let us know!

6. A two-tailed t-test with df = 10 gives t = 2.228. What is the p-value (to 2 decimals)?

Found a mistake? Let us know!

7. Group means differ by 6 and the pooled SD is 12. What is Cohen’s d?

Found a mistake? Let us know!

8. Group 1 has s₁²/n₁ = 4 and group 2 has s₂²/n₂ = 5. What is the Welch standard error?

Found a mistake? Let us know!

9. Why is Welch’s t-test often the default for two independent groups?

Found a mistake? Let us know!

10. A 95% confidence interval for μ₁ − μ₂ is [−1.2, 3.8]. What does a two-tailed test of H₀: μ₁ − μ₂ = 0 at α = 0.05 conclude?

Found a mistake? Let us know!

Frequently asked questions

What does a t-test tell you?

It tells you whether the difference between a sample mean and a value, or between two means, is large compared with the random variation you would expect. A small p-value (usually 0.05 or less) means the difference would be unusual if there were no real difference.

Should I use Welch’s or Student’s t-test?

Welch’s test is the safer default for two independent groups because it does not assume equal variances. When the variances really are equal it loses almost nothing; when they are not, the pooled test can give misleading p-values, especially with unequal group sizes.

What is a good t-value?

There is no single cutoff, because it depends on the degrees of freedom. With large samples, |t| above about 2 is significant at 0.05 (two-tailed). With df = 5 you need |t| of at least 2.571.

How do I calculate a t-test in Excel?

Use =T.TEST(range1, range2, tails, type), where tails is 1 or 2 and type is 1 for paired, 2 for equal variances or 3 for Welch. It returns only the p-value; this calculator also gives t, df, the confidence interval and the effect size.

What is the difference between a t-test and a z-test?

A z-test uses a known population standard deviation; a t-test estimates it from the sample, which adds uncertainty, so it uses the t distribution with heavier tails. As the sample grows, the two give nearly the same answer.

Related calculators

Related to This Article

What people say about "T-Test Calculator: One-Sample, Two-Sample & Paired"?

No one replied yet.

Leave a Reply