t-Test Calculator

T-Test Calculator

Paste your data and run a paired, two-sample (Welch or pooled) or one-sample t-test, with the t statistic, p-value, 95% confidence interval and effect size.

t = difference ÷ standard error

In the same order, so each pair belongs to one person.

Enter both sets of values

What is a T-Test?

A t-test checks whether a difference in averages is bigger than you'd expect from random variation alone. It compares the size of the difference with its standard error; the ratio is the t statistic.

There are three versions. A paired test compares two measurements on the same people, such as before and after. A two-sample test compares two separate groups. A one-sample test compares one group's mean with a fixed value.

The t-test assumes the data (or the differences, for paired data) are roughly normal. With more than about 30 per group it holds up well even when they aren't, thanks to the central limit theorem.

T-Test Formulas

As given in the NIST/SEMATECH e-Handbook, section 1.3.5.3; Welch's degrees of freedom from Welch (1947). See Sources.

1. One sample and paired

t = (x̄ − μ₀) ÷ (s ÷ √n), df = n − 1
Paired: the same, on the differences d, with μ₀ = 0

2. Two independent groups (Welch)

t = (x̄₁ − x̄₂) ÷ √(s₁²/n₁ + s₂²/n₂)
df = (s₁²/n₁ + s₂²/n₂)² ÷ [(s₁²/n₁)²/(n₁ − 1) + (s₂²/n₂)²/(n₂ − 1)]

The pooled version uses one combined variance and df = n₁ + n₂ − 2. Welch is the safer default.

3. Interval and effect size

95% CI = difference ± t₀.₉₇₅, df × SE
Cohen's d = difference ÷ SD

Worked Example: Blood Pressure Before and After

Given:
Six patients' systolic pressure before 140, 135, 150, 145, 138, 142 and after 132, 130, 144, 140, 136, 135 a new routine.
Step 1:
Differences:
8, 5, 6, 5, 2, 7 → mean 5.5, s = 2.074
Step 2:
Standard error and t:
SE = 2.074 ÷ √6 = 0.847 · t = 5.5 ÷ 0.847 = 6.50, df = 5
Step 3:
p-value and interval:
p = 0.0013 · 95% CI 3.32 to 7.68 mmHg
Result:
An average drop of 5.5 mmHg, p = 0.0013

Every patient improved a little, so the paired test is very sensitive. Treated as two separate groups, the same numbers give p ≈ 0.10, because the large differences between patients swamp the small change within each.

Which T-Test to Use

Match the test to how the data were collected.

Choosing between t-tests
Your dataTestExcel
Same people measured twicePairedT.TEST(…, 1)
Two separate groupsWelch two-sampleT.TEST(…, 3)
Two groups, equal spread knownPooled two-sampleT.TEST(…, 2)
One group against a targetOne-samplePaired with a column of the target
Three or more groupsNot a t-test: use ANOVA—

Common T-Test Mistakes

  • Using a two-sample test on paired data. As the example shows, it throws away the pairing and can miss a real effect.
  • Assuming equal variances by default. The pooled test can mislead when spreads and group sizes differ. Welch's test works either way.
  • Running many t-tests across several groups. Comparing four groups pairwise is six tests and inflates false positives. Use ANOVA first.
  • Ignoring outliers in small samples. One extreme value can dominate both the mean and the SD. Look at the data before testing.

T-Test FAQs

Why is it called a t-test?

It uses Student’s t distribution, published in 1908 by William Gosset under the pen name “Student” while he worked at the Guinness brewery.

How big a sample do I need?

There’s no strict minimum, but small samples only detect large effects. The power analysis calculator works out the size you need.

Why are the degrees of freedom not whole numbers?

Welch’s test estimates them from the two variances, so they’re usually fractional. That’s expected.

What if my data aren’t normal?

With 30 or more per group, the t-test is usually fine. For small, skewed samples, use the Mann–Whitney U test (independent) or the Wilcoxon signed-rank test (paired).

What does the confidence interval add?

It shows how big the difference plausibly is, not just whether it’s zero. An interval that excludes zero matches a significant two-tailed test.

What is a good Cohen’s d?

Rough guides: 0.2 small, 0.5 medium, 0.8 large. In the blood pressure example d is 2.65, but effects within the same people often are.

Can I use a t-test for proportions?

Use a z-test for proportions instead. The A/B test calculator compares two conversion rates.

Should I choose one-tailed?

Only if you decided before collecting data that a difference in the other direction would be of no interest.

Sources

  • NIST/SEMATECH e-Handbook of Statistical Methods, section 1.3.5.3: two-sample t-test for equal means.
  • B. L. Welch, "The generalization of Student's problem when several different population variances are involved", Biometrika 34 (1947) 28–35.
  • Student (W. S. Gosset), "The probable error of a mean", Biometrika 6 (1908) 1–25.

Related Tools