⚗️ T-Test Calculator
One-sample, two-sample or paired — paste data or type mean, SD and n. Get t, df, the p-value, the decision, a confidence interval and the effect size.
T-test formulas
| Test | t statistic | Degrees of freedom |
|---|---|---|
| One-sample | t = (x̄ − μ₀) ÷ (s ÷ √n) | n − 1 |
| Paired | t = d̄ ÷ (s_d ÷ √n), using the differences | n − 1 (pairs) |
| Two-sample, Welch | t = (x̄₁ − x̄₂) ÷ √(s₁²/n₁ + s₂²/n₂) | Welch–Satterthwaite (usually not a whole number) |
| Two-sample, pooled | t = (x̄₁ − x̄₂) ÷ √(s_p²(1/n₁ + 1/n₂)) | n₁ + n₂ − 2 |
Worked examples (checked against R and SciPy)
Two-sample (Welch). Exam scores in two sections: A = 78, 85, 92, 70, 88, 81, 76, 90, 84, 79 and B = 72, 80, 68, 75, 83, 70, 77, 69, 74, 71. Means 82.3 and 73.9, SDs 6.82 and 4.91. SE = √(6.82²/10 + 4.91²/10) = 2.656, t = 8.4 ÷ 2.656 = 3.16, df = 16.36, two-tailed p = 0.0059 → significant at 0.05.
Paired. Quiz scores before and after tutoring for 8 students: before 62, 70, 55, 68, 74, 60, 66, 71; after 68, 74, 61, 70, 79, 63, 72, 75. Mean difference 4.5, SD of differences 1.51, t = 4.5 ÷ (1.51 ÷ √8) = 8.42, df = 7, p = 0.00007.
One-sample. 40 students sleep a mean of 6.8 hours (s = 1.2). Is that different from 7? t = (6.8 − 7) ÷ (1.2 ÷ √40) = −1.05, df = 39, two-tailed p = 0.298 → not significant.
Writing it up (APA style)
“Section A (M = 82.3, SD = 6.8) scored higher than section B (M = 73.9, SD = 4.9), Welch’s t(16.36) = 3.16, p = .006, d = 1.41.” The logic of H₀, H₁ and p-values is explained in the lesson Hypothesis tests and p-values. For an interval estimate instead of a test, use the confidence interval calculator.
Commands: Excel / Sheets =T.TEST(range1, range2, tails, type) (type 1 paired, 2 equal variance, 3 unequal); TI-84 STAT → TESTS → 2:T-Test, 4:2-SampTTest; R t.test(a, b).
Questions and answers
Which t-test should I use?
One-sample: one group compared with a fixed number (is the mean sleep 7 hours?). Two-sample (independent): two separate groups of different people (online vs. in-person sections). Paired: the same people measured twice, or matched pairs (before and after a tutoring program).
Welch or pooled (Student’s) two-sample t-test?
Use Welch’s test unless your instructor asks for the pooled version. Welch does not assume equal variances, works just as well when they are equal, and is the default in R and in many textbooks. The pooled test assumes both groups have the same population SD and uses df = n₁ + n₂ − 2.
How do I interpret the p-value?
If the null hypothesis were true, the p-value is the probability of getting a t statistic at least as extreme as yours. If p is below your significance level α (usually 0.05), reject H₀. A p-value is not the probability that H₀ is true, and a large p-value does not prove H₀.
One-tailed or two-tailed?
Use two-tailed unless you decided before seeing the data that only one direction matters (for example “the new method increases scores”). A one-tailed p-value is half the two-tailed one when the effect goes in the predicted direction.
What does Cohen’s d tell me?
Effect size: the difference in means measured in standard deviations. Rough guide: 0.2 small, 0.5 medium, 0.8 large. With a big sample even a tiny, unimportant difference can be significant, so report d along with p.
What are the conditions for a t-test?
Random sampling or random assignment, independent observations, and roughly normal data — or large samples (n ≥ 30 per group is a common rule), because of the central limit theorem. Check for strong skew and outliers in small samples.