Independent samples t-test calculator
Compare the means of two separate groups. Welch's unequal-variance test is the main result and Student's pooled test sits beside it, each with its own df, p-value and confidence interval, plus Hedges' g, Cohen's d and Glass's delta.
- Enter raw columns or mean, SD and n per group
- Welch and Student in one table
- Pooled SD, SD ratio and three effect sizes
Sources checked on November 21, 2026. Results computed by the site's engine and tested against R and SciPy.
Welch's t-test does not assume equal variances
At the 5% level, there is evidence of a difference between the US cars and Japanese cars means.
| Welch (default) | Student (equal variances) | |
|---|---|---|
| t | −12.9463 | −12.6206 |
| df | 136.87 | 326 |
| p (two-sided) | 1.571 × 10−25 | 5.273 × 10−30 |
| 95% CI | −11.9152 to −8.7576 | −11.9476 to −8.7252 |
| Critical t | 1.9774 | 1.9673 |
| Group | n | Mean | SD |
|---|---|---|---|
| US cars | 249 | 20.1446 | 6.4147 |
| Japanese cars | 79 | 30.4810 | 6.1077 |
Effect sizes: Cohen's ds −1.6297 (pooled SD 6.3426), Hedges' g −1.6259, d* (average variance) −1.6504, Glass's delta −1.6924 using Japanese cars as the control group.
Ratio of the larger SD to the smaller: 1.05. Enter raw data for skewness and outlier checks.
APA Welch: t(136.87) = −12.95, p < .001, g = −1.63, 95% CI [−11.92, −8.76]
Reproduce this result in R or Python
R
m1 <- 20.14458; s1 <- 6.4147; n1 <- 249
m2 <- 30.48101; s2 <- 6.10771; n2 <- 79
se <- sqrt(s1^2 / n1 + s2^2 / n2) # Welch
df <- se^4 / ((s1^2 / n1)^2 / (n1 - 1) + (s2^2 / n2)^2 / (n2 - 1))
t <- (m1 - m2) / se
c(t = t, df = df, p = 2 * pt(-abs(t), df))
(m1 - m2) + c(-1, 1) * qt(0.975, df) * se
sp <- sqrt(((n1 - 1) * s1^2 + (n2 - 1) * s2^2) / (n1 + n2 - 2)) # Student
ts <- (m1 - m2) / (sp * sqrt(1 / n1 + 1 / n2))
c(t = ts, df = n1 + n2 - 2, p = 2 * pt(-abs(ts), n1 + n2 - 2))Python (SciPy)
from scipy.stats import ttest_ind_from_stats
print(ttest_ind_from_stats(20.14458, 6.4147, 249, 30.48101, 6.10771, 79, equal_var=False, alternative="two-sided")) # Welch
print(ttest_ind_from_stats(20.14458, 6.4147, 249, 30.48101, 6.10771, 79, equal_var=True, alternative="two-sided")) # StudentWhen to use it
Use the independent samples test, also called the two-sample or unpaired t-test, when each value belongs to exactly one of two groups and nobody appears in both: treated and control patients, two production lines, two classes taught different ways. If the same people were measured twice, or the values come in natural pairs, use the paired t-test instead, because the two sets of numbers are not independent.
Worked example: US and Japanese car mileage (NIST)
The calculator opens with the example from the NIST/SEMATECH e-Handbook: fuel economy in miles per gallon for 249 US cars and 79 Japanese cars from the AUTO83B dataset. NIST prints only summary statistics, so this example uses the summary input.
NIST runs the pooled (Student) test. From its printed means and SDs we get t = −12.6206 on 326 df, matching NIST's printed T to its five decimals, and a pooled SD of 6.3426. The two-sided critical value at the 5% level is 1.9673, again matching NIST. With |t| far above that, the difference is clear.
Welch's test on the same summaries gives t = −12.9463 on 136.87 df. NIST does not print a Welch result, so this one is ours, checked against SciPy. The df is much lower than 326 because the groups are very unequal in size and the smaller group carries most of the uncertainty. The 95% interval for the difference is −11.92 to −8.76 mpg under Welch and −11.95 to −8.73 under Student. Hedges' g is −1.63.
Reading the two columns
The result table puts Welch on the left and Student on the right. When the two SDs are similar and the groups are about the same size, the columns nearly agree. When the SDs differ and the group sizes differ too, they can disagree, and Welch's column is the one to trust. The SD ratio shown under the table is a quick guide; it is not a test, and you should not switch between the columns based on it.
Both columns use the same mean difference. They differ in the standard error: Welch adds the two variances of the means separately, while Student pools the variances first and assumes one common value.
Formulas
Welch: t = (m1 − m2) / √(s1²/n1 + s2²/n2), with df = (s1²/n1 + s2²/n2)² / [(s1²/n1)²/(n1−1) + (s2²/n2)²/(n2−1)]
Student: t = (m1 − m2) / (sp√(1/n1 + 1/n2)), with sp² = [(n1−1)s1² + (n2−1)s2²] / (n1 + n2 − 2) and df = n1 + n2 − 2
The Welch df is the Welch-Satterthwaite approximation. We keep all its decimals when computing p, as R does; rounding it down to a whole number, as some tables suggest, makes the test slightly conservative. The hand calculation guide works through both formulas line by line.
Effect sizes reported
- Hedges' g: Cohen's ds multiplied by the small-sample correction 1 − 3/(4(n1+n2) − 9), from Lakens (2013). This is the headline effect size.
- Cohen's ds: the mean difference divided by the pooled SD.
- d*: the difference over the square root of the average of the two variances, which does not weight by group size. (The paired calculator's dav, which divides by the plain average of the two SDs, is a different measure.)
- Glass's delta: the difference over the control group's SD alone, useful when a treatment changes the spread. Enter the control group second.
Name the one you report. The Cohen's d calculator explains each in more depth.
Checks before you trust the answer
The test needs independent observations, a sensible measurement scale and either roughly normal data in each group or samples large enough for the means to behave. Paste raw data to see skewness and values beyond 1.5 times the interquartile range. Strong skew in small samples, or a few extreme values, can move a t-test a long way: in R's own example, adding a single value of 200 to the second group changes Welch's p from 1.855 × 10−5 to 0.1245. In that situation consider the Mann-Whitney U test, and read t-test assumptions.
Sources
- NIST/SEMATECH e-Handbook of Statistical Methods, 1.3.5.3 Two-Sample t-Test for Equal Means checked November 21, 2026
- R source code, stats package, t.test.R checked November 21, 2026
- Lakens D. (2013) Calculating and reporting effect sizes to facilitate cumulative science. Frontiers in Psychology 4:863 checked November 21, 2026