t-Test Calculator
Compare two means, or one mean against a fixed value. Enter means, standard deviations and sample sizes, or paste raw data, and get the t statistic, degrees of freedom, p-value, the confidence interval of the difference, Cohen’s d and a results sentence in APA style.
Independent-samples t-test (Welch)
p-value
t(39.55) = 1.767. The difference is not statistically significant at α = 0.05.
- t statistic
- 1.7673
- Degrees of freedom
- 39.55
- p (two-sided)
- 0.0849
- Mean difference
- 0.8000
- 95% CI
- −0.115 to 1.715
- Standard error
- 0.4527
- Cohen’s d
- 0.501
- medium
- Hedges’ g
- 0.492
Report it like this
A Welch independent-samples t-test found no statistically significant difference between group 1 (M = 5.20, SD = 1.10, n = 20) and group 2 (M = 4.40, SD = 1.90, n = 25), t(39.55) = 1.77, p = .085 (two-sided), mean difference 0.80, 95% CI −0.12 to 1.72, d = 0.50.
How to use the calculator
- Pick the test. Independent for two separate groups, paired for the same people measured twice (or matched pairs), one sample to compare a mean with a fixed value.
- Enter the data. Use the mean, standard deviation and n of each group, as reported in a paper or a summary table, or paste the raw values.
- Choose the hypothesis. Two-sided is standard. Use one-sided only if the direction was fixed before you saw the data.
- Read the result. The p-value, t, df, the confidence interval of the difference and Cohen’s d appear at once, with a sentence you can paste into your results section.
For paired data entered as summary statistics you need the mean and SD of the differences, not the SD of each measurement. If a paper reports only the two separate SDs, paste the raw data instead or ask the authors for the SD of the change.
Which t-test should I use?
- Independent-samples (two-sample) t-test: two unrelated groups, such as treatment and control arms or men and women.
- Paired-samples t-test: two measurements on the same units, such as before and after treatment, left and right eye, or matched case and control.
- One-sample t-test: one group against a known value, such as mean IQ against 100 or a measured concentration against a label claim.
Welch or Student? Student’s version pools the two variances and assumes they are equal. Welch’s version does not, and loses almost no power when the variances are in fact equal. Simulation studies (Ruxton 2006; Delacre, Lakens and Leys 2017) recommend Welch as the default, which is also what R’s t.test() does. Use Student’s test when you need to match an analysis that assumed equal variances.
With more than two groups, run a one-way ANOVA instead of many t-tests. To plan how many participants a t-test needs, use the power analysis calculator.
Formulas
Every version divides a difference in means by its standard error and compares the result with Student’s t distribution.
Welch’s t-test
t = (x̄₁ − x̄₂) / √(s₁²/n₁ + s₂²/n₂)
with the Welch–Satterthwaite degrees of freedom
df = (s₁²/n₁ + s₂²/n₂)² / [(s₁²/n₁)²/(n₁ − 1) + (s₂²/n₂)²/(n₂ − 1)]
Student’s t-test (pooled variance)
sₚ² = [(n₁ − 1)s₁² + (n₂ − 1)s₂²] / (n₁ + n₂ − 2), t = (x̄₁ − x̄₂) / [sₚ√(1/n₁ + 1/n₂)], df = n₁ + n₂ − 2
Paired and one-sample t-tests
t = (x̄ − μ₀) / (s/√n), df = n − 1
For paired data, x̄ and s are the mean and SD of the differences and μ₀ = 0.
Effect size
Cohen’s d is the mean difference divided by the pooled SD (independent groups), the SD of the differences (paired data, written dz) or the sample SD (one sample). Hedges’ g multiplies d by 1 − 3/(4df − 1) to remove its small-sample bias. As a rough guide, 0.2 is small, 0.5 medium and 0.8 large (Cohen 1988), but compare with effects in your own field where you can.
Worked example
A trial reports a pain score of 5.2 (SD 1.1, n = 20) with treatment A and 4.4 (SD 1.9, n = 25) with treatment B. These are the calculator’s default values.
- Standard error = √(1.1²/20 + 1.9²/25) = √(0.0605 + 0.1444) = 0.453
- t = 0.80 / 0.453 = 1.77, with Welch df = 39.55
- Two-sided p = .085; 95% CI for the difference −0.12 to 1.72
- Cohen’s d = 0.80 / 1.597 = 0.50
The difference is not statistically significant at the 5% level, and the confidence interval is wide: the data fit anything from a small advantage for B to a large advantage for A. Student’s test on the same numbers gives t(43) = 1.67, p = .102.
Paired example (the second worked example in the calculator): eight patients measured before and after treatment have a mean change of 0.775 (SD of the changes 0.55), so t(7) = 3.99, p = .005, 95% CI 0.32 to 1.23, dz = 1.41.
How to report a t-test in APA style
APA style gives the test, the degrees of freedom in brackets, the t value to two decimals, the exact p-value (or p < .001) and an effect size, with the confidence interval of the difference:
A Welch independent-samples t-test found no statistically significant difference between treatment A (M = 5.20, SD = 1.10, n = 20) and treatment B (M = 4.40, SD = 1.90, n = 25), t(39.55) = 1.77, p = .085, mean difference 0.80, 95% CI −0.12 to 1.72, d = 0.50.
- Italicise t, p, M, SD, n and d in the manuscript.
- Drop the leading zero for p (p = .085) but keep it for statistics that can exceed 1 (d = 0.50).
- Say which test you used (Welch or Student; paired; one- or two-sided) in the methods.
Many medical journals follow the SAMPL guidelines and ask for the confidence interval more than the p-value. Our guide to statistical reporting in medical manuscripts covers the rest.
Assumptions
- Independent observations. Each value comes from a different unit (or a different pair). Repeated measurements on the same person in one group break this.
- Roughly normal data or means. The t-test is robust to moderate skew once each group has 30 or so values. With small, strongly skewed samples, consider a transformation or the Mann–Whitney U or Wilcoxon signed-rank test.
- Equal variances for Student’s test only. Welch’s test drops this assumption.
A non-significant p-value does not show that two groups are the same. To show equivalence, use an equivalence test (two one-sided tests) with a margin set in advance.
Questions
- How do I calculate a t-test from means and standard deviations?
- Choose the independent test, enter each group’s mean, standard deviation and sample size, and the calculator gives t, df, the p-value and the confidence interval. For example, 5.2 (SD 1.1, n = 20) against 4.4 (SD 1.9, n = 25) gives a Welch t(39.55) = 1.77 and p = .085.
- What is the difference between Welch’s and Student’s t-test?
- Student’s t-test pools the two variances and assumes they are equal; Welch’s t-test estimates them separately and adjusts the degrees of freedom. When the variances and group sizes differ, Student’s test can give a misleading p-value, while Welch’s test stays accurate. When the variances are equal the two give almost the same answer, so Welch is the safer default.
- When should I use a paired t-test?
- Use a paired t-test when each value in one set belongs with one value in the other: the same person before and after, two treatments in a crossover trial, or matched case and control. Analysing paired data with an independent test ignores the pairing and usually loses a lot of power.
- What does the p-value of a t-test mean?
- It is the probability of a difference at least as large as the one observed if the true means were equal. A p-value below 0.05 is called statistically significant by convention. It does not give the probability that the null hypothesis is true, and it says nothing about how large or important the difference is, which is why the confidence interval and effect size are shown too.
- Should I use a one-tailed or two-tailed t-test?
- Use a two-tailed (two-sided) test unless a difference in the other direction would truly be treated the same as no difference and the direction was chosen before seeing the data. A one-tailed p-value is half the two-tailed one when the difference is in the predicted direction, so switching after the fact inflates false positives.
- How do I calculate Cohen’s d for a t-test?
- For two independent groups, d is the mean difference divided by the pooled standard deviation. For paired data it is the mean difference divided by the standard deviation of the differences (dz). The calculator reports both d and Hedges’ g, which corrects d for small samples.
- Can I use a t-test with a small sample?
- Yes. The t distribution was developed for small samples, and the test is exact when the data are normally distributed. The problem with very small samples is that you cannot check normality and the confidence interval will be wide. With fewer than about 10 values per group and skewed data, a nonparametric test may be more appropriate.
Sources
- Student. The probable error of a mean. Biometrika 1908;6(1):1–25. doi:10.1093/biomet/6.1.1
- Welch BL. The generalization of “Student’s” problem when several different population variances are involved. Biometrika 1947;34(1–2):28–35. doi:10.1093/biomet/34.1-2.28
- Ruxton GD. The unequal variance t-test is an underused alternative to Student’s t-test and the Mann–Whitney U test. Behav Ecol 2006;17(4):688–690. doi:10.1093/beheco/ark016
- Delacre M, Lakens D, Leys C. Why psychologists should by default use Welch’s t-test instead of Student’s t-test. Int Rev Soc Psychol 2017;30(1):92–101. doi:10.5334/irsp.82
- Lakens D. Calculating and reporting effect sizes to facilitate cumulative science: a practical primer for t-tests and ANOVAs. Front Psychol 2013;4:863. doi:10.3389/fpsyg.2013.00863
Calculations run in your browser; nothing you enter is sent or stored. Results are checked against SciPy and statsmodels in our test suite. Last updated 22 November 2026.