T-Test Calculator
Last updated: 27 June 2026
Reviewed by Gavin Meiring, Lead research and primary author ยท Doctoral Candidate (Corporate Governance) ยท Research and drafting assisted by AI
- The t-test was invented by William Sealy Gosset, a chemist working for the Guinness brewery in Dublin, who published his 1908 paper under the pseudonym 'Student'.
- Guinness required employees to publish under pen names to protect trade secrets โ which is why the test is still called 'Student's t-test' rather than Gosset's.
- Gosset's insight was that when the sample is small and the standard deviation must be estimated, the test statistic follows a different distribution that depends on the sample size โ the degrees of freedom.
T-Test Calculator
A t-test calculator performs one-sample, independent two-sample, and paired t-tests, computing the t-statistic, p-value, and confidence interval for the difference between means. It is used by students, researchers, and analysts to determine whether differences between group means are statistically significant or likely due to chance.
How to Use the T-Test Calculator
- Select your test type: one-sample (compare a sample mean to a known value), independent two-sample (compare two separate groups), or paired (compare the same subjects under two conditions).
- Enter your data values directly or input the sample means, standard deviations, and sample sizes.
- Enter the hypothesised mean difference (usually 0 for tests of no difference) and select one-tailed or two-tailed.
- Click Calculate to see the t-statistic, degrees of freedom, p-value, and 95% confidence interval.
- Interpret the output using the decision rule and effect size provided.
The Formula
One-sample t-test: t = (x_bar - mu_0) / (s / sqrt(n))
Independent two-sample t-test: t = (x_bar1 - x_bar2) / sqrt(s1^2/n1 + s2^2/n2)
Paired t-test: t = d_bar / (s_d / sqrt(n)), where d_bar is the mean difference between pairs and s_d is the standard deviation of the differences.
Degrees of freedom: df = n - 1 for one-sample and paired tests; for two-sample tests, use Welch's formula.
Reject the null hypothesis when p < alpha (typically 0.05).
Real-World Example
A clinical trial tests whether a new supplement reduces blood pressure. Twelve participants have their systolic blood pressure measured before and after a 4-week course.
Mean difference (before minus after): d_bar = 8 mmHg Standard deviation of differences: s_d = 6 mmHg n = 12
t = 8 / (6 / sqrt(12)) = 8 / (6 / 3.464) = 8 / 1.732 = 4.62
df = 11
For t = 4.62 with 11 degrees of freedom, the two-tailed p-value is approximately 0.0008.
Since 0.0008 < 0.05, the result is highly significant. The supplement appears to reduce blood pressure.
Choosing the Right T-Test
Selecting the correct t-test is important for valid results. Use a one-sample t-test when you want to compare your sample mean against a known benchmark or theoretical value, such as comparing a batch of products against a target weight. Use an independent two-sample t-test when you have two separate, unrelated groups, such as a treatment group and a control group in a randomised experiment. Use a paired t-test when each observation in one group is matched with a specific observation in the other, such as before-and-after measurements on the same individuals. The paired test is more powerful in these situations because it removes between-subject variability by focusing on within-subject changes. All three t-tests assume that the data is approximately normally distributed or that the sample size is large enough for the central limit theorem to apply.
Frequently Asked Questions
What assumptions does a t-test make? The t-test assumes that the data is drawn from a normally distributed population, that observations are independent of one another, and (for the independent two-sample version) that the two samples have equal or similar variances (Welch's t-test relaxes the equal variance assumption). If the normality assumption is seriously violated with small samples, non-parametric alternatives such as the Mann-Whitney U test should be considered.
What is the difference between Student's t-test and Welch's t-test? Student's t-test assumes the two groups have equal variances and pools them. Welch's t-test makes no assumption about equal variances and uses a corrected degrees of freedom formula. Welch's test is generally recommended by default because it performs well whether variances are equal or not, whereas Student's test can produce misleading results when variances differ substantially.
What effect size should I report with a t-test? Cohen's d is the standard effect size for t-tests. It equals the difference in means divided by the pooled standard deviation. By convention, d = 0.2 is small, d = 0.5 is medium, and d = 0.8 is large. Reporting effect size alongside the p-value is important because statistical significance depends on sample size: a trivially small difference can be statistically significant with a large enough sample.
Can a t-test handle more than two groups? No. The t-test is designed for comparing exactly two groups (or one group against a fixed value). When comparing three or more groups simultaneously, use ANOVA (Analysis of Variance). Using multiple t-tests across several groups inflates the risk of a false positive; ANOVA controls for this by testing all groups in a single analysis.
The paired example checked line by line
The clinical trial example above uses a mean difference of 8 mmHg with a standard deviation of differences of 6 across 12 participants. Working it from the formula:
| Step | Working | Result |
|---|---|---|
| Standard error of the differences | 6 divided by the square root of 12, or 6 divided by 3.464102 | 1.732051 |
| t statistic | 8 divided by 1.732051 | 4.618802 |
| Degrees of freedom | 12 minus 1 | 11 |
| Two-tailed p value | from the t distribution at 11 degrees of freedom | 0.000742 |
The page prints t as 4.62 and the p value as approximately 0.0008. The recomputed p at that t is 0.000742, so 0.0008 is a little high, by about eight percent. Nothing turns on it. Both readings sit far below 0.05, which is the decision the example is making.
The confidence interval on the same data
A p value tells you whether an effect exists. The interval tells you how large it might be. For the same 12 participants, with a standard error of 1.732051 and a critical t of 2.200985 at 95 percent confidence:
| Quantity | Working | Value |
|---|---|---|
| Standard error | 6 divided by the square root of 12 | 1.732051 mmHg |
| Critical t, 95 percent, 11 df | from the t distribution | 2.200985 |
| Margin of error | 2.200985 times 1.732051 | 3.812218 mmHg |
| Lower bound | 8 minus 3.812218 | 4.1878 mmHg |
| Upper bound | 8 plus 3.812218 | 11.8122 mmHg |
The interval runs from 4.19 to 11.81 mmHg. It excludes zero, which agrees with the significant p value, and its width is the honest measure of what 12 participants can tell you. A trial of 12 people showing a mean drop of 8 mmHg is consistent with a true effect anywhere between about 4 and about 12.
Effect size for the same pair of readings
Cohen's d for a paired test divides the mean difference by the standard deviation of the differences, which here is 8 divided by 6, or 1.3333. The conventions quoted in the FAQ above put 0.2 at small, 0.5 at medium and 0.8 at large. An effect of 1.3333 sits well beyond the large threshold, so the finding is not one of those statistically significant but practically trivial results that large samples produce. The study used 12 people and found a large effect, which is the good version of that trade.
Critical values at the sample sizes you meet
Every t test compares its statistic against a threshold that depends on the degrees of freedom. These are the two-tailed critical values at the two conventional levels:
| Degrees of freedom | t at the 5 percent level | t at the 1 percent level |
|---|---|---|
| 1 | 12.706 | 63.657 |
| 5 | 2.571 | 4.032 |
| 10 | 2.228 | 3.169 |
| 11 | 2.201 | 3.106 |
| 15 | 2.131 | 2.947 |
| 20 | 2.086 | 2.845 |
| 30 | 2.042 | 2.750 |
| 60 | 2.000 | 2.660 |
| 120 | 1.980 | 2.617 |
Notice how little the threshold moves after about 30 degrees of freedom. Going from 20 to 120 participants lowers the 5 percent threshold from 2.086 to 1.980, a change of five percent, while going from 5 to 20 lowers it from 2.571 to 2.086, a change of nineteen percent. Small studies pay a heavy price in the size of the effect they can detect.
The smallest effect this study could have found
With 12 participants and a standard deviation of 6, the standard error is 1.732051 mmHg. Multiplying by the critical value gives the detection floor:
| Significance level | Critical t | Smallest detectable mean difference |
|---|---|---|
| 5 percent, two-tailed | 2.200985 | 3.8122 mmHg |
| 1 percent, two-tailed | 3.1058 | 5.3794 mmHg |
The study found 8 mmHg, which clears both floors. That is the useful reading of the result: the design was capable of detecting a difference of 3.81 mmHg and it found more than twice that. Had the true effect been 3 mmHg, this trial would very likely have reported nothing.
How many participants the effect needs
Working the other way, the sample size a paired test needs to detect an effect of d = 1.3333 at 80 percent power with a 5 percent two-tailed level:
| Participants | Power |
|---|---|
| 4 | 0.3258 |
| 5 | 0.5785 |
| 6 | 0.7421 |
| 7 | 0.8398 |
| 8 | 0.8991 |
Seven participants is the first sample that clears 80 percent. The trial used 12, so it carried margin on top of the minimum. On the same table, a trial with 4 participants would have had only a one in three chance of detecting an effect of this size, which is the reason underpowered studies so often report a null result that a larger study then overturns.
The same numbers read as an independent test
Suppose the 12 readings came from two unrelated groups of 12, rather than the same 12 people measured twice. The mean difference is still 8 and the spread in each group is still 6, but the test changes.
| Version of the test | t | Degrees of freedom | p value | 95 percent interval |
|---|---|---|---|---|
| Paired | 4.618802 | 11 | 0.000742 | 4.1878 to 11.8122 mmHg |
| Independent, same spread and size | 3.265986 | 22 | 0.003536 | 2.9201 to 13.0799 mmHg |
Two things happen. The p value rises from 0.000742 to 0.003536, so the same difference looks less certain. The interval widens from about 7.6 mmHg to about 10.2 mmHg. The paired design wins because each participant acts as their own control, which removes the variation between people from the comparison. The arithmetic shows the size of that gain exactly: with equal group sizes and equal variances the paired t is the square root of two times the unpaired t, here 4.618802 against 3.265986, and the ratio of their squares is 2.0000.
Welch's degrees of freedom when the groups differ
The independent test above uses Welch's formula rather than Student's, because Welch's version does not assume the two groups share a variance. The formula divides the square of the summed variances by a sum of squared terms:
df equals (s1 squared over n1 plus s2 squared over n2) squared, divided by (s1 squared over n1) squared over n1 minus 1, plus (s2 squared over n2) squared over n2 minus 1.
Three worked cases show how it behaves:
| Groups | Welch degrees of freedom |
|---|---|
| Standard deviations 4 and 9, 10 in each group | 12.4220 |
| Standard deviations 4 and 9, 10 in one group and 25 in the other | 32.4524 |
| Standard deviations 9 and 4, 25 in one group and 10 in the other | 32.4524 |
The second and third rows give the same answer, which is what the formula should do, since swapping the two groups cannot change how much information you have. Where the variances are equal and the sizes match, Welch's formula returns 22, exactly the same as Student's n1 plus n2 minus 2. Welch's version costs almost nothing when the assumption holds and protects you when it does not, which is why it is the sensible default. The FAQ above makes the same point and the arithmetic here confirms it.
The two Biometrika papers behind the test
Student's t test was published as "The probable error of a mean", Biometrika, volume 6, issue 1, pages 1 to 25, in 1908. The author wrote under the pen name Student, which is the name that has stayed attached to the test. Welch's version is B. L. Welch, "The generalization of Student's problem when several different population variances are involved", Biometrika, volume 34, issues 1 and 2, pages 28 to 35, in 1947. The critical values and p values quoted on this page were computed from the t distribution rather than read off a printed table, so the last digit of each figure is correct for the stated degrees of freedom.
Also try these free tools: