Skip to content
DeviceCheckHub

T-Test Calculator

Test whether a mean, or the difference between two means, is significant. Paste raw data or type summary statistics, and get the p-value, a confidence interval, the effect size and each step.

Your test

Group 1
Group 2
t = −3.142 with 18.8466 degrees of freedom, p = 0.005402.

t = −3.142, p = 0.005402

Significant at α = 0.05: reject the null hypothesis that the difference in means (1 − 2) is 0.

−4−2024

The shaded area is the p-value. The solid line is your t; dashed lines are the critical values.

t
−3.142
Degrees of freedom
18.8466
p-value
0.005402
Difference in means (1 − 2)
−1.2
Standard error
0.381875
95% confidence interval
−1.99971 to −0.400286
Cohen’s d
−1.26
Critical t (α = 0.05)
±2.0942

In R: t.test(group1, group2)

Step by step

  1. Hypotheses: H₀: μ₁ − μ₂ = 0 against Hₐ: μ₁ − μ₂ ≠ 0.
  2. Standard error = √(s₁²/n₁ + s₂²/n₂) = √(0.0833284 + 0.0625) = 0.381875. Welch’s degrees of freedom: (s₁²/n₁ + s₂²/n₂)² / ((s₁²/n₁)²/(n₁ − 1) + (s₂²/n₂)²/(n₂ − 1)) = 18.8466.
  3. t = (x̄₁ − x̄₂ − 0) / SE = (−1.2 − 0) / 0.381875 = −3.142.
  4. p-value from Student’s t with 18.8466 df, two-tailed: p = 0.005402. That is below α = 0.05, so reject H₀.
  • Welch’s test doesn’t assume the two groups have the same standard deviation, so it is the safer default.
  • With fewer than 30 values in a group, the t test assumes the data come from a roughly normal population. Check for strong skew or outliers.

How to use the t-test calculator

  1. Choose the test: one sample, two independent samples, or paired samples.
  2. Choose Raw data to paste your numbers, or Summary stats if you already have each group’s size, mean and standard deviation.
  3. Pick the tail that matches your alternative hypothesis and the significance level α, usually 0.05. The result updates as you type.

What a t test does

A t test asks whether a difference between means is bigger than you would expect from sampling variation alone. It divides the difference by its standard error to get t, then finds how unusual that t would be under Student’s t distribution if the null hypothesis of no difference were true. That tail probability is the p-value; when it is below α, the difference is called statistically significant.

One sample, two samples or paired

Pairing matters. Treating paired data as two independent groups ignores the fact that each person is compared with themselves, which can make the test much less sensitive.

Welch’s test or the pooled test

For two independent groups there are two versions. The pooled test assumes both groups share one standard deviation and uses n₁ + n₂ − 2 degrees of freedom. Welch’s test lets the spreads differ; OpenStax notes that “the degrees of freedom formula was developed by Aspin-Welch,” and it usually gives a fractional df. Welch’s test is what R’s t.test runs unless you ask for equal variances, and it is the calculator’s default too. If the two groups have clearly different spreads, the pooled test’s equal-spread assumption doesn’t hold.

Example: two independent groups

OpenStax’s Introductory Statistics compares the hours per day that girls and boys aged seven to 11 spend playing sports: 9 girls averaged 2 hours (s = 0.866) and 16 boys averaged 3.2 hours (s = 1). These are the calculator’s starting values. Welch’s test gives t = −3.142, p = 0.005402 with 18.85 degrees of freedom, so at the 5% level the means are different. The 95% confidence interval for the difference (girls − boys) is −1.99971 to −0.400286 hours, and Cohen’s d is −1.26. The pooled test gives a similar answer here: t = −3.014, p = 0.006183 with 23 degrees of freedom.

Example: paired data

In another OpenStax example, eight people rate their pain before and after hypnotism. Choosing Paired samples, Raw data and a left-tailed test (less pain afterwards), with the before values first and the after values second, the mean difference is −3.125 and the test gives t = −3.036, p = 0.009478 with 7 degrees of freedom. Since p is below 0.05, the data support a reduction in pain.

Example: one sample

Suppose five measurements are 4, 5, 6, 7 and 8, and you want to know whether the true mean is above 5. Choose One sample, Raw data, enter 5 as the hypothesised mean and pick the right tail. The sample mean is 6, but with so few values the test gives t = 1.414, p = 0.1151 with 4 degrees of freedom: not significant at the 5% level. A larger sample with the same mean and spread could well be significant, which is why a non-significant result isn’t proof that there is no difference.

Reading the result

To write it up, give the test, t with its degrees of freedom, the p-value and the interval, for example: Welch’s t(18.85) = −3.142, p = 0.005402, 95% CI −1.99971 to −0.400286.

Effect size and confidence interval

A p-value says whether a difference is likely to be real, not how big it is. With a large sample, even a tiny difference can be significant. That is why the calculator also gives the difference itself with a confidence interval, which shows the range of plausible values, and Cohen’s d, the difference in standard deviations. Report all three.

Assumptions

Running the same test in Excel or R

Excel’s T.TEST(array1, array2, tails, type) returns the p-value directly. tails is 1 or 2, and type is 1 for paired, 2 for “two-sample equal variance (homoscedastic)” and 3 for “two-sample unequal variance (heteroscedastic)”, which is Welch’s test. In R, t.test(x, y) runs Welch’s test, and the calculator shows the matching R call for your choices under the result.

Your data stays on your device

Everything is worked out in your browser. Nothing you type or paste is sent anywhere or stored.

Frequently asked questions

Which t test should I use?

Use a one-sample test to compare one mean with a fixed value, a two-sample test for two separate groups, and a paired test when each value in one set is matched to a value in the other, such as the same person before and after.

Welch or pooled?

Welch’s test doesn’t assume the two groups have equal standard deviations and is the default in R. The pooled test assumes they are equal. When the groups have similar spreads and sizes the two give almost the same answer; when they don’t, the results can differ, and Welch’s test doesn’t rely on the equal-spread assumption.

Can I paste data from a spreadsheet?

Yes. Choose Raw data and paste a column or row of numbers into each box. Spaces, tabs, commas, semicolons and new lines all work, and each box takes up to 10,000 values.

What is Cohen’s d?

It is the size of the difference measured in standard deviations: the difference in means divided by the standard deviation (pooled for two groups, of the differences for paired data). Unlike the p-value, it doesn’t grow just because the sample is larger.

What does a one-tailed test change?

It looks for a difference in one stated direction only. If the result goes that way, the p-value is half the two-tailed one; if it goes the other way, the p-value is large. Decide on the direction before you look at the data.

Is my data uploaded?

No. Everything is worked out in your browser and nothing you type is sent anywhere or stored.

Last updated · About DeviceCheckHub