Skip to content
Calcapedia
Statistics & Data

T-Test Calculator

Check whether a difference between averages is real or just chance. Runs one-sample, paired and two-sample (Welch or pooled) t-tests, with the t statistic, degrees of freedom, p-value and confidence interval.

Level: Grade 12 to college

Printable worksheet

T-Test Calculator

Know the answer you need? Pick an input to work backward.

Inputs
Test
Enter

Separate with commas, spaces or new lines.

The difference in means under the null hypothesis: μ₁ − μ₂, or the mean of before − after for paired data.

Alternative hypothesis

The false-positive rate you accept. 0.05 is the common choice; 0.01 is stricter.

Result

p-value

0.00135

The Welch two-sample t-test gives t = 4.0249 with 13.4615 df and p = 0.00135, which is significant at α = 0.05.

At α = 0.05
Significant: reject H₀ (p ≤ 0.05)
t statistic
4.0249
Degrees of freedom
13.4615
Difference in means (x̄₁ − x̄₂)
4.5
Standard error
1.118
95% confidence interval for the difference
2.093 to 6.907
Two-sided critical t at α = 0.05
2.1529
Cohen's d (pooled SD)
2.0125
Sample 1 mean
26.5
Sample 2 mean
22

See the step-by-step solution ↓

Step-by-step solution

  1. Find each sample's mean, spread (standard deviation, dividing by n − 1) and size

    x̄₁ = 26.5, s₁ = 2.4495, n₁ = 8; x̄₂ = 22, s₂ = 2, n₂ = 8
  2. Find the standard error of the difference, using each sample's own spread

    SE=2.4494928+228=1.118034
  3. Find the degrees of freedom with the Welch–Satterthwaite formula. It is usually not a whole number

    df=(0.75+0.5)20.7527+0.527=13.461538
  4. Find t: how many standard errors your result is from the value you are testing against

    t=4.5−01.118034=4.024922
  5. Find the p-value, the chance of a result this far out in either direction: double the area beyond |t| on the t curve with 13.4615 df

    p=2×0.0006749137=0.0013498273
  6. The p-value is at or below α, so the result is statistically significant

    Significant: reject H₀ (p ≤ 0.05)

Test yourself

20 quick questions built from this calculator's formula: work out results, predict what happens when an input changes, and work backward from an answer. Every answer comes with the working.

What this calculator does

Find out whether a difference between averages is real, or could easily be down to chance. A t-test checks whether that difference is bigger than random sampling alone would give. You might compare one group's average (its mean) with a target value. You might compare two separate groups. Or you might compare the same people before and after.

The test turns the difference into a t statistic. That's how many standard errors it sits from the value you're testing against. (The standard error is the typical amount a sample average wobbles by chance.) The t distribution then gives a p-value. That's the chance of seeing a difference at least this large if there were really no effect.

This t-test calculator runs all four common versions. Paste raw data, or type the mean, standard deviation and size of each group. Then choose the alternative hypothesis (the direction you're testing) and the significance level. You get the p-value, the t statistic, the degrees of freedom and a decision. You also get a confidence interval for the mean or difference, and Cohen's d to show the effect size. Every step of the working is shown.

Where it's used

Why this math matters outside the classroom:

  • Clinical trials. Researchers compare blood pressure in a drug group and a placebo group with Welch's t-test before claiming the drug lowers it.
  • Teaching methods. A school tests whether students' scores rose after a tutoring program with a paired t-test on each student's before and after marks.
  • Quality checks. A bottler tests whether the mean fill of a sample of bottles differs from the labelled 500 mL with a one-sample t-test.
  • Website experiments. An analyst compares average time on page for two page designs with a two-sample t-test before rolling out the new one.
  • Crop trials. An agronomist compares the yields of a new and an old seed variety across matched field plots with a paired t-test.

How to use it

  1. Choose the test. One-sample compares a mean with a fixed value. Welch is for two separate groups, and it's the safe default. Use pooled only if you have reason to think the groups have equal variances (equal spread). Use paired when each value in one list is matched with one in the other.
  2. Enter raw data, or switch to summary statistics and type each group's mean, standard deviation and size.
  3. Set the hypothesized mean (one-sample) or difference (usually 0). Pick two-tailed unless you chose a direction in advance. Then choose α, the cutoff for calling a result significant.
  4. Read the p-value and decision first. Then look at the t statistic, degrees of freedom, confidence interval and effect size.

What the inputs mean

Test
Welch's test doesn't assume equal variances, and it loses very little when they are equal. That's why many statisticians recommend it over the pooled test by default.
Sample 1 (or 'before' values)
Separate with commas, spaces or new lines.
Sample 2 (or 'after' values, in the same order)
For a paired test, the two lists must be in the same order, so the first value of each belongs to the same person or item. The differences are worked out as list 1 minus list 2.
Sample 1 standard deviation (paired: SD of the differences)
Use the sample standard deviation: the one worked out by dividing by n − 1, where n is the number of values.
Hypothesized difference (usually 0)
The difference in means under the null hypothesis: μ₁ − μ₂, or the mean of before − after for paired data.
Alternative hypothesis
Use a one-tailed test only if you fixed the direction before looking at the data. The right-tailed version tests whether the mean (or difference) is greater than the hypothesized value.
Significance level (α)
The false-positive rate you accept. 0.05 is the common choice; 0.01 is stricter.

Formula and method

One-sample: t = (x̄ − μ₀) ÷ (s ÷ √n),  df = n − 1
Paired: t = (d̄ − Δ₀) ÷ (s_d ÷ √n), on the differences d = before − after
Welch: t = (x̄₁ − x̄₂ − Δ₀) ÷ √(s₁²/n₁ + s₂²/n₂)
Welch df = (s₁²/n₁ + s₂²/n₂)² ÷ [(s₁²/n₁)²/(n₁ − 1) + (s₂²/n₂)²/(n₂ − 1)]
Pooled: sₚ² = [(n₁ − 1)s₁² + (n₂ − 1)s₂²] ÷ (n₁ + n₂ − 2),  t = (x̄₁ − x̄₂ − Δ₀) ÷ (sₚ√(1/n₁ + 1/n₂)),  df = n₁ + n₂ − 2
Confidence interval: estimate ± t* × SE, with t* the two-sided critical value at α

Here x̄ is a sample's mean, s its standard deviation and n its size. The small 1 and 2 mark group 1 and group 2. μ₀ is the mean you're testing against, and Δ₀ is the difference you're testing against (usually 0). d is each pair's difference, d̄ is their mean and s_d is their standard deviation. df is the degrees of freedom, sₚ is the pooled standard deviation and SE is the standard error.

Every version divides the difference you saw by its standard error. The standard error shrinks as samples grow. So with more data, the same difference gives a larger t and a smaller p-value.

The paired test works with each pair's difference, which removes the variation from person to person. Then it runs a one-sample test on those differences. That's why it's often far more sensitive than treating the same numbers as two separate groups.

Welch's version gives each group its own variance. It adjusts the degrees of freedom with the Welch–Satterthwaite formula, which usually gives a df that isn't a whole number. The pooled version combines the two variances into one estimate. That's slightly more powerful when the true variances really are equal, but it can mislead when they aren't.

The p-value is the area under the t distribution beyond your t. For a two-tailed test that's both tails; for a one-tailed test it's one tail. The calculator works it out exactly, with a function called the incomplete beta function, rather than looking it up in a table.

Worked example

Group 1 scored 23, 25, 28, 30, 26, 27, 24 and 29; group 2 scored 20, 22, 25, 21, 24, 23, 19 and 22. Is the difference significant at α = 0.05 with Welch's test?

  1. Means and SDs: x̄₁ = 26.5, s₁ = √6 ≈ 2.4495; x̄₂ = 22, s₂ = 2; n₁ = n₂ = 8.
  2. Standard error: √(6/8 + 4/8) = √1.25 ≈ 1.1180.
  3. t = (26.5 − 22 − 0) ÷ 1.1180 ≈ 4.0249.
  4. Welch df = 1.25² ÷ (0.75²/7 + 0.5²/7) ≈ 13.4615.
  5. Two-tailed p-value ≈ 0.00135, which is below 0.05.
  6. 95% confidence interval for the difference: 4.5 ± 2.1529 × 1.1180, or 2.093 to 6.907.

Result: t ≈ 4.0249 with about 13.46 df and p ≈ 0.00135: significant at α = 0.05. Group 1's mean is higher by an estimated 2.093 to 6.907 points.

Understanding the result

A p-value below α means the difference you saw would be unusual if the null hypothesis (no real difference) were true. So you reject it. A p-value above α doesn't prove there's no difference. It means the data can't rule one out.

The confidence interval shows the range of differences that fit the data. Suppose a two-sided interval at level 1 − α leaves out the hypothesized value. Then the two-tailed test at α is significant, and the other way round.

Statistical significance isn't the same as practical importance. Cohen's d gives the difference in standard deviations. Roughly 0.2 is often called small, 0.5 medium and 0.8 large, though what matters depends on the field.

Assumptions and limitations

  • The observations are independent: within each group, and between groups for the two-sample tests.
  • Each group (or the paired differences) comes from a roughly normal, bell-shaped population. With 30 or more observations per group, the test copes well with moderate skew (lopsided data).
  • The pooled test also assumes the two populations have equal variances.
  • The data are measurements on a number scale, not ranks or categories.
  • Strong skew or outliers in small samples can distort the result. A rank-based test such as Mann–Whitney or Wilcoxon may suit that kind of data better.
  • Comparing three or more groups with repeated t-tests raises the chance of false positives. Use analysis of variance (ANOVA) instead.
  • Summary statistics must use the n − 1 divisor for the standard deviation.
  • Extremely small p-values hit the limits of computer arithmetic. Below about 1e-16, they're reported as underflowing (too small to show).

Frequently asked questions

Which t-test should I use?

Use one-sample to compare a mean with a known value. Use paired when the two lists are matched, such as the same patients before and after. Use Welch for two separate groups. Use the pooled version only if you have good reason to think the two variances are equal.

What is the difference between a one-tailed and a two-tailed t-test?

A two-tailed test looks for a difference in either direction. A one-tailed test looks in only one direction, chosen beforehand, and puts all of α in that tail. So its p-value is half the two-tailed one when the effect goes the way you predicted.

Why are Welch's degrees of freedom not a whole number?

The Welch–Satterthwaite formula is an approximation for when the two variances differ. The best-fitting df is usually a fraction. It falls somewhere between the smaller n − 1 and n₁ + n₂ − 2. The t distribution works with fractional df too.

What does a p-value of 0.03 mean?

If the null hypothesis were true, a difference at least this large would turn up in about 3% of samples. At α = 0.05 that's significant; at α = 0.01 it's not.

Can I run a t-test with only the mean and standard deviation?

Yes. Choose summary statistics and enter each group's mean, sample standard deviation and size. For a paired test, enter the mean and standard deviation of the differences and the number of pairs.

How this calculator is checked

Method: Student's one-sample and paired t-tests, Welch's unequal-variance t-test with Welch–Satterthwaite degrees of freedom, and the pooled two-sample t-test; p-values from the regularized incomplete beta function. Checked against published results for Student's sleep data. The calculation is covered by automated tests with known reference values and edge cases. Last updated 2026-10-18. Found a problem? Tell us.

Embed this calculator

Put this T-Test Calculator on your own website or blog for free. Paste this code where you want it to appear: