Compare two means
T-test calculator
How results are checked
Named statistical review pending. Selected automated reference cases are published on the validation page.Result on the sample data
7.6points
Saw the ad scored higher than Control (Welch t(71.6) = 2.11, p = .038)
Brand liking 0–100 · n = 42 vs 40 · Hedges' g = 0.46
A t test asks whether a difference in means is larger than sampling noise. Use the independent-samples test for two separate groups (Welch's version by default, because it does not assume equal variances), the paired test when the same people are measured twice, and the one-sample test to compare a mean with a fixed value. Report the mean difference with its confidence interval and an effect size such as Cohen's d, not just the p-value.
Run this on your own data — free, no signup
Upload a CSV, Excel, SPSS, Stata, SAS, R, Parquet or JSON file. Everything runs in your browser; your file never leaves your device.
Open the workspace →Calculate online
Type each group's n, mean and standard deviation, or switch to raw data and paste columns from a spreadsheet (or open a CSV, Excel or SPSS file — it is read in your browser and never uploaded). Results update as you type.
Welch's t test
t(71.64) = 2.11
Saw the ad is 7.62 higher than Control (95% CI [0.42, 14.82]); the difference is statistically significant at α = .05.
p = .038 · One-sided p in the observed direction: p = .019.
Descriptive statistics
| n | Mean | SD | |
|---|---|---|---|
| Saw the ad | 42 | 63.14 | 13.69 |
| Control | 40 | 55.52 | 18.54 |
Test
| Test | t | df | p (two-sided) | Mean difference | SE | 95% CI |
|---|---|---|---|---|---|---|
| Welch (unequal variances) | 2.109 | 71.64 | p = .038 | 7.62 | 3.613 | [0.42, 14.82] |
| Student (equal variances) | 2.124 | 80 | p = .037 | 7.62 | 3.587 | [0.48, 14.76] |
Equality of variances
Levene's test needs the raw values. The SD ratio is 1.35; Welch's test does not assume equal variances, so it is the safe choice from summary statistics.
Effect size
| Estimate | 95% CI | |
|---|---|---|
| Cohen's d (pooled SD) | 0.469 | [0.029, 0.907] |
| Hedges' g (bias-corrected) | 0.465 | [0.029, 0.898] |
Welch or Student?
Student's t test pools the two variances and is exact only when the populations have equal variances. Welch's test estimates each variance separately and adjusts the degrees of freedom. When the variances really are equal the two give almost the same answer; when they are not — especially with unequal group sizes — Student's test can be badly miscalibrated. That is why this calculator leads with Welch and shows Student alongside it.
With raw data the calculator also runs Levene's test (centred on the mean) and the Brown–Forsythe variant (centred on the median, more robust to skew). Treat them as a description of the spread, not as a gate: choosing the t test after looking at a variance test changes the error rates, and Welch is a sound default either way. For more than two groups use the one-way ANOVA calculator.
The method
Formula
t = (x̄₁ − x̄₂) / √(s₁²/n₁ + s₂²/n₂) (Welch)
where
- x̄₁, x̄₂ · s₁, s₂ · n₁, n₂
- the two group means, standard deviations and sizes
- df (Welch)
- (s₁²/n₁ + s₂²/n₂)² / [ (s₁²/n₁)²/(n₁ − 1) + (s₂²/n₂)²/(n₂ − 1) ] — the Welch–Satterthwaite approximation
- Student
- uses the pooled SD sₚ = √[((n₁ − 1)s₁² + (n₂ − 1)s₂²)/(n₁ + n₂ − 2)], SE = sₚ√(1/n₁ + 1/n₂) and df = n₁ + n₂ − 2
- paired
- t = d̄ / (s_d/√n) on the n within-pair differences, df = n − 1
- one-sample
- t = (x̄ − μ₀) / (s/√n), df = n − 1
- Cohen's d · Hedges' g
- d = (x̄₁ − x̄₂)/sₚ (paired: d_z = d̄/s_d); g = d·J with J = Γ(df/2) / (√(df/2)·Γ((df − 1)/2)); intervals invert the noncentral t distribution
Worked example
The sample data is a synthetic ad test: 42 people who saw an ad and 40 in a control cell rated the brand from 0 to 100. The means are 63.14 (SD 13.69) and 55.52 (SD 18.54).
Welch's test gives t(71.6) = 2.11, p = .038: the exposed group scored 7.62 points higher, 95% CI [0.42, 14.82]. Student's pooled test agrees closely here (t(80) = 2.12, p = .037). Brown–Forsythe p = .174 gives no strong reason to doubt equal spreads.
The effect is moderate: Cohen's d = 0.47 and Hedges' g = 0.46, 95% CI [0.03, 0.90]. The interval is wide — with about 40 people per cell the data are consistent with anything from a trivial to a large lift.
In the paired sample, 30 respondents rated the brand before and after a product trial; the mean change was 3.67 points (t(29) = -3.10, p = .004, d_z = -0.57).
Using it well
When to use it
Use it when
- Use: Comparing a numeric outcome (score, rating, time, spend) between two independent groups.
- Use: The same respondents measured twice, or matched pairs — use the paired test on the differences.
- Use: Checking a mean against a benchmark, target or scale midpoint — use the one-sample test.
- Use: Approximately normal data, or moderate samples (roughly 30+ per group) where the mean is well behaved.
Not the right tool when
- Avoid: More than two groups — run a one-way ANOVA instead of many t tests.
- Avoid: Heavily skewed data or ordinal ratings in small samples — consider the Mann–Whitney U test.
- Avoid: A yes/no outcome — compare proportions with the chi-square test (or McNemar for paired data).
- Avoid: Weighted survey data or a complex sample design — the formulas here assume simple random samples.
How to interpret it
Rule of thumb
p < 0.05 means a difference this large would be unusual if the true means were equal — it does not say the difference is large or important. Read the confidence interval for the plausible size of the difference, and Cohen's d for its size in SD units (about 0.2 small, 0.5 medium, 0.8 large by Cohen's rough convention). Hedges' g is the same quantity with a small-sample bias correction; prefer it below about 20 per group.
Questions
Frequently asked questions
Should I use Welch's t test or Student's t test?
Use Welch's test by default. It does not assume the two groups have equal variances, loses almost nothing when they do, and stays accurate when they do not — particularly when the group sizes also differ. Student's pooled test is shown for comparison and for reproducing older reports.
Can I run a t test from the mean and standard deviation only?
Yes. The t statistic, degrees of freedom, p-value, confidence interval, Cohen's d and Hedges' g depend only on each group's n, mean and SD, so the summary-statistics mode gives the same results as raw data. Levene's and Brown–Forsythe's variance tests need the individual values, so they appear only in raw-data mode.
What is the difference between a paired and an independent t test?
A paired test is for two measurements on the same units (before/after, two products rated by the same person, matched pairs); it analyses the within-pair differences, which removes between-person variation. An independent test is for two separate groups of people. Using the independent test on paired data usually wastes power, and using the paired test on independent data is simply wrong.
How do I report a t test in APA style?
Give the means and SDs, then the test — for the sample data: Welch's t(71.6) = 2.11, p = .038, mean difference = 7.62, 95% CI [0.42, 14.82], Hedges' g = 0.46. Name which t test you used and report the effect size with its interval.
What does Cohen's d mean and how is its interval calculated?
Cohen's d is the mean difference divided by a standard deviation — the pooled SD for independent groups, the SD of the differences (d_z) for paired data. Its confidence interval is found by inverting the noncentral t distribution, which is exact under normality, rather than by a normal approximation.
Sources and next steps
References & further reading
- [1]Student (1908). The probable error of a mean. Biometrika, 6(1), 1–25.
- [2]Welch, B. L. (1947). The generalization of 'Student's' problem when several different population variances are involved. Biometrika, 34(1–2), 28–35.
- [3]Delacre, M., Lakens, D., & Leys, C. (2017). Why psychologists should by default use Welch's t-test instead of Student's t-test. International Review of Social Psychology, 30(1), 92–101.
- [4]Brown, M. B., & Forsythe, A. B. (1974). Robust tests for the equality of variances. Journal of the American Statistical Association, 69(346), 364–367.
- [5]Hedges, L. V. (1981). Distribution theory for Glass's estimator of effect size and related estimators. Journal of Educational Statistics, 6(2), 107–128.
- [6]Lakens, D. (2013). Calculating and reporting effect sizes to facilitate cumulative science: a practical primer for t-tests and ANOVAs. Frontiers in Psychology, 4, 863.
- [7]SciPy — scipy.stats.ttest_inddocs.scipy.org
Try it on your own data — free, no signup
Upload a CSV, Excel, SPSS, Stata, SAS, R, Parquet or JSON file. Everything runs in your browser; your file never leaves your device.
Open the workspace →