Two-Sample T-Test Calculator
This calculator runs a two-sample t-test from summary statistics. Enter the mean, the sample standard deviation and the size of each group, and choose the Welch or the pooled method. The page gives the difference of the means, the standard error, the t statistic and the degrees of freedom, and with the pooled method the pooled standard deviation.
The two-sample t-test compares two means from independent samples. The page needs only the summary statistics of each group. It gives no p-value, no critical value and no decision.
Calculator
Welch method: the variances are not assumed equal
Difference = 10 − 12 = -2.000
SE = √(22/30 + 2.52/35) = 0.5585
t = (10 − 12) / √(22/30 + 2.52/35) = -3.581
With a = 22/30 and b = 2.52/35: df = (a + b)2 / (a2/(30 − 1) + b2/(35 − 1)) = 62.73
Theory of the two-sample t-test
The two-sample t-test compares two means from independent samples. The NIST/SEMATECH e-Handbook gives two forms of the test statistic: the Welch form, which does not assume equal variances, and the pooled form, which assumes that the variances are equal.
Welch method
T = (m1 − m2) / √(s12/N1 + s22/N2)
ν = (s12/N1 + s22/N2)2 / [ (s12/N1)2/(N1 − 1) + (s22/N2)2/(N2 − 1) ]
The degrees of freedom ν of the Welch form are the Welch-Satterthwaite value, which is in general not a whole number.
Pooled method
sp2 = [ (N1 − 1) s12 + (N2 − 1) s22 ] / (N1 + N2 − 2)
T = (m1 − m2) / ( sp √(1/N1 + 1/N2) )
ν = N1 + N2 − 2
Symbols
- m1, m2
- sample means of group 1 and group 2, in the unit of the measurement
- s1, s2
- sample standard deviations of group 1 and group 2, in the unit of the measurement
- N1, N2
- sample sizes of group 1 and group 2, counts with no unit
- sp
- pooled standard deviation, in the unit of the measurement; sp2 is the pooled variance, in the square of that unit
- SE
- standard error of the difference, the denominator of T, in the unit of the measurement
- T
- t statistic, no unit (shown as t in the calculator)
- ν
- degrees of freedom, no unit (shown as degrees of freedom in the calculator)
The calculator divides both standard deviations by the larger one before it squares them and multiplies the result back; this gives the same values and keeps very large and very small inputs representable.
When the formulas do not hold
OpenStax Introductory Statistics 2e, section 10.1, starts from two simple random samples that are independent and, for small samples, from normal populations. It says not to pool the variances when the standard deviations are unknown, and that the Student approximation is very good when both sample sizes are 5 or larger. The page calculates from sizes of 2 up; the numbers describe a t test only when these conditions hold.
Worked example
OpenStax Example 10.1, Welch method: m1 = 2, s1 = 0.866, N1 = 9; m2 = 3.2, s2 = 1, N2 = 16.
- Difference: m1 − m2 = 2 − 3.2 = -1.20000
- s12/N1 = 0.8662/9 = 0.749956/9 = 0.0833284
- s22/N2 = 12/16 = 0.0625000
- s12/N1 + s22/N2 = 0.145828
- SE = √(s12/N1 + s22/N2) = 0.381875
- (s12/N1 + s22/N2)2 = 0.0212659
- (s12/N1)2/(9 − 1) = 0.000867954 and (s22/N2)2/(16 − 1) = 0.000260417, sum 0.00112837
- ν = 0.0212659 / 0.00112837 = 18.8466, shown as 18.85
- T = (m1 − m2) / SE = -1.20000 / 0.381875 = -3.14239
The t statistic, to 4 significant figures: -3.142
OpenStax prints t = -3.14 and degrees of freedom of about 18.8462 from a calculator, against 18.8466 here.
A second check, the NIST e-Handbook example with the pooled method (means 20.14458 and 30.48101, standard deviations 6.4147 and 6.10771, sizes 249 and 79), gives on this page sp = 6.343, t = -12.62 and 326.0 degrees of freedom; NIST prints -12.62059 for t, 6.34260 for sp and 326 degrees of freedom.
Sources: NIST/SEMATECH e-Handbook of Statistical Methods, section 1.3.5.3, Two-Sample t-Test for Equal Means. OpenStax, Introductory Statistics 2e, section 10.1.
How to use the calculator
- Choose the method: Welch if the variances are not assumed equal, pooled if they are assumed equal.
- Enter the mean, the sample standard deviation and the size of group 1. The mean and the standard deviation are in the unit of the measurement.
- Enter the same three values for group 2, in the same unit as group 1.
- Read the difference of the means, the standard error, the t statistic and the degrees of freedom, and with the pooled method the pooled standard deviation. The results update as you type; the Calculate button computes them again.
- Check the formula line under the results: it shows the formulas with your values in place. The page gives no p-value, no critical value and no decision.
Frequently asked questions
Should I use the Welch or the pooled method?
The Welch method does not assume that the variances of the two populations are equal. The pooled method assumes that they are equal and combines the two sample standard deviations into one pooled standard deviation. OpenStax Introductory Statistics says not to pool the variances when the standard deviations are unknown.
Why are the Welch degrees of freedom not a whole number?
The Welch method takes its degrees of freedom from the Welch-Satterthwaite formula, a ratio built from the variance terms of the two groups, and the result is in general not a whole number. In the first example on this page (means 2 and 3.2, standard deviations 0.866 and 1, sizes 9 and 16) it gives 18.85. The pooled method uses n1 + n2 - 2, a whole number.
Are the means, the standard deviations and the sizes enough?
Yes, for the numbers. The difference, the standard error, the t statistic and the degrees of freedom depend only on the two means, the two sample standard deviations and the two sizes, and the page uses only them. The numbers describe a t test only when the conditions in the theory section hold: two independent simple random samples and, for small samples, normal populations.
Can a group have a size of 1?
No. A size of 1 is not accepted: each size is a whole number from 2 to 10000000000. The Welch degrees of freedom divide by n1 - 1 and n2 - 1, which are 0 for a size of 1.
Disclaimer: for preliminary estimation only. This page is not a substitute for a statistical analysis or review by a qualified analyst.