How to use the t-test calculator
- Choose the test: one sample, two independent samples, or paired samples.
- Choose Raw data to paste your numbers, or Summary stats if you already have each group’s size, mean and standard deviation.
- 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
- One sample compares a mean with a fixed value, such as a target or a published average, using t = (x̄ − μ₀) / (s / √n) with n − 1 degrees of freedom.
- Two samples compares the means of two separate groups, such as a treatment group and a control group.
- Paired samples are matched, such as the same people measured twice. “In a hypothesis test for matched or paired samples, subjects are matched in pairs and differences are calculated.” The differences are then tested “using a Student's-t test for a single population mean with n – 1 degrees of freedom, where n is the number of differences.”
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
- t is the difference divided by its standard error: how many standard errors the result is from the hypothesised value.
- Degrees of freedom set the shape of the t curve; fewer degrees of freedom mean heavier tails and a larger critical value.
- p-value is the shaded area on the curve. Compare it with α to decide.
- Critical t gives the same decision from the other side: the result is significant when t is beyond it.
- Confidence interval is the range of plausible values for the true difference at a confidence level of 1 − α. For a two-tailed test it excludes the hypothesised value exactly when the result is significant.
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
- The data are random samples, and for two-sample tests the groups are independent of each other.
- Each group, or the differences for paired data, comes from a roughly normal population, or the sample is large enough. For paired data, OpenStax puts it as: “Either the matched pairs have differences that come from a population that is normal or the number of differences is sufficiently large so that distribution of the sample mean of differences is approximately normal.”
- Strong outliers can distort both the mean and the standard deviation, so look at your data first.
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.