T-Test Calculator
Paste or type two groups of numbers to test whether their means differ…
Paste or type two groups of numbers to test whether their means differ: Welch’s t-test by default, Student’s if you choose, with the p-value shaded on the t curve.
Read 10 values; left out the header row (“Lectures”).
Read 11 values; left out the header row (“Practice tests”).
More optionsTwo-sided, 95% confidence
The significance level is 1 − the confidence level (0.05 at 95%). Welch’s test is the safer default; Student’s assumes both groups have the same spread.
ExampleP-value
0.00031
Lectures averages 8.982 less than Practice tests (difference −8.982, 95% CI −13.26 to −4.708). Significant at the 5% level (p < 0.05).
Paste your own numbers to test them.
Every value is a dot and the box is the middle half; the diamond is the mean with its confidence interval.
The distribution the statistic follows if there were no difference; the shaded area beyond it is the p-value.
- t (Welch), df
- −4.3995, 18.95
- Cohen’s d (Hedges g)
- −1.908 (−1.831)
- Difference, 95% CI
- −8.982 [−13.26 to −4.708]
How this works: 9 sources,
How this works
Method
A two-sample t-test asks whether two independent groups have different means, judged against how much the values vary inside each group. With the example’s two classes, the class taught with practice tests averaged 81.2 and the lecture class 72.2. That 9-point gap is about four times its standard error, which is why the p-value is so small: a gap that big would be rare if both methods worked equally well. Full method
Sources
- Delacre, Lakens and Leys, Why psychologists should by default use Welch’s t-test instead of Student’s t-test (International Review of Social Psychology, 2017)
- Welch, The generalization of Student’s problem when several different population variances are involved (Biometrika, 1947)
- Hedges, Distribution theory for Glass’s estimator of effect size and related estimators (Journal of Educational Statistics, 1981)
- NIST/SEMATECH e-Handbook of Statistical Methods
- Abramowitz and Stegun, Handbook of Mathematical Functions, chapters 6, 7 and 26 (1964)
- SciPy 1.18 scipy.stats (reference values for the tests)
- statsmodels 0.15 (reference values for the A/B test and regression intervals)
- Fleiss, Levin and Paik, Statistical Methods for Rates and Proportions, 3rd edition (sample size for two proportions) (2003)
- Hyndman and Fan, Sample quantiles in statistical packages (The American Statistician) (1996)
How it’s tested
4 worked examples for this page are checked by automated tests before every release: given the inputs, the tool must show the expected answer.
Privacy
On your device. Nothing you enter or open leaves this browser. About privacy labels
Changes
- First published: live curves with draggable cut-offs, and tests on pasted data (t-tests, ANOVA, chi-square, Fisher’s exact, correlation, regression, A/B), checked against SciPy.
How the two-sample t-test works
A two-sample t-test asks whether two independent groups have different means, judged against how much the values vary inside each group. With the example’s two classes, the class taught with practice tests averaged 81.2 and the lecture class 72.2. That 9-point gap is about four times its standard error, which is why the p-value is so small: a gap that big would be rare if both methods worked equally well.
The statistic is t = (mean₁ − mean₂) ÷ SE. Welch’s version, the default here, takes the standard error as √(s₁²/n₁ + s₂²/n₂) and works out fractional degrees of freedom from both groups, so it stays honest when one group is more spread out or larger than the other. Student’s original version pools the two variances first; it is slightly more powerful when the spreads really are equal, and noticeably wrong when they are not and the groups differ in size.
A p-value says nothing about how big the difference is, so the answer also gives the confidence interval of the difference and Cohen’s d, the gap measured in pooled standard deviations. Hedges’ g is d with a small-sample correction. Around 0.2 is usually called small, 0.5 medium and 0.8 large, but what matters is whether the difference is big enough to care about in your field.
t = (x̄₁ − x̄₂) ÷ √(s₁²/n₁ + s₂²/n₂) · Welch df = (s₁²/n₁ + s₂²/n₂)² ÷ Σ (sᵢ²/nᵢ)²/(nᵢ − 1)
- Welch’s test does not assume equal variances; simulations show it controls false positives as well as Student’s test when variances are equal and far better when they are not, so it is the better default. Source: Delacre, Lakens and Leys, Why psychologists should by default use Welch’s t-test instead of Student’s t-test (International Review of Social Psychology, 2017).
- Welch introduced the approximate degrees of freedom for the difference of two means with unequal variances in 1947. Source: Welch, The generalization of Student’s problem when several different population variances are involved (Biometrika, 1947).
- Hedges’ g removes the small upward bias of Cohen’s d by multiplying it by Γ(m/2) ÷ (√(m/2) Γ((m − 1)/2)), with m = n₁ + n₂ − 2. Source: Hedges, Distribution theory for Glass’s estimator of effect size and related estimators (Journal of Educational Statistics, 1981).
The same difference at different sample sizes
Two groups with means 5 apart and a standard deviation of 10 in each (d = 0.5): how the t statistic, the p-value and the 95% interval change with the number in each group (Welch’s test).
| Per group | t | df | p-value | 95% CI of the difference |
|---|---|---|---|---|
| 5 | 0.791 | 8 | 0.452 | −9.58 to 19.58 |
| 10 | 1.118 | 18 | 0.2783 | −4.4 to 14.4 |
| 15 | 1.369 | 28 | 0.1818 | −2.48 to 12.48 |
| 20 | 1.581 | 38 | 0.1221 | −1.4 to 11.4 |
| 30 | 1.936 | 58 | 0.0577 | −0.17 to 10.17 |
| 50 | 2.5 | 98 | 0.0141 | 1.03 to 8.97 |
| 64 | 2.828 | 126 | 0.0054 | 1.5 to 8.5 |
| 100 | 3.536 | 198 | 0.0005 | 2.21 to 7.79 |
| 200 | 5 | 398 | 8.61e-7 | 3.03 to 6.97 |
| 500 | 7.906 | 998 | 7.03e-15 | 3.76 to 6.24 |
Show all 11 rowsShow fewer
| 1,000 | 11.18 | 1998 | 3.43e-28 | 4.12 to 5.88 |
Common questions
Should I use Welch’s or Student’s t-test?
Welch’s, unless you have a good reason to believe both groups have the same spread. It costs almost nothing when the spreads are equal and protects you when they aren’t. Excel’s T.TEST type 3, R’s t.test default and SciPy’s ttest_ind with equal_var=False are all Welch’s test.
My groups have different sizes. Is that a problem?
No, the test handles unequal groups. It matters more for Student’s version, whose pooled variance gives the larger group more say; another reason to stay with Welch.
What if my data aren’t normal?
With 30 or so values per group the t-test is robust to moderate skew, because it is about means. For small, skewed samples or ratings on a scale, the Mann-Whitney U test compares the groups by rank instead.
I only have the means and standard deviations. Can I still run it?
Yes. Switch “Enter” to “Mean and SD” and type each group’s size, mean and standard deviation; the test needs nothing else. That is also what a shared link sends when your data are too big for a link.