What this calculator does
A t-test asks whether a difference in means is larger than you would expect from random sampling alone. It turns the difference into a t statistic (the difference divided by its standard error) and compares that with the t distribution to get a p-value.
The calculator runs all three common versions, accepts raw data or summary statistics, supports one- and two-tailed alternatives, and reports the confidence interval for the difference and the effect size (Cohen’s d) alongside the p-value.
Choosing the right t-test
- One-sample: one group against a fixed value. Does the average weight of “5 kg” atta packs really equal 5 kg?
- Two-sample (independent): two separate groups. Do students taught by the case method score differently from those taught by lectures?
- Paired: two measurements on the same units. Did the same 10 stores sell more after staff training than before? Pairing removes the store-to-store variation, so it detects smaller effects than a two-sample test on the same numbers.
The formulas
Welch: t = (x̄₁ − x̄₂) / √(s₁²/n₁ + s₂²/n₂)
Pooled: t = (x̄₁ − x̄₂) / (sp√(1/n₁ + 1/n₂)), sp² = ((n₁−1)s₁² + (n₂−1)s₂²) / (n₁ + n₂ − 2)
For the paired test, x̄ and s are the mean and standard deviation of the differences. Welch’s degrees of freedom come from the Welch–Satterthwaite formula, which is why they are usually not a whole number. Cohen’s d divides the difference by the standard deviation (the pooled standard deviation for two samples, the standard deviation of the differences for paired data).
Worked example: case method vs lectures
With Two-sample selected, press Load example. It loads mock exam scores out of 100 for two PGDM sections: Section A (12 students, taught with case studies) and Section B (14 students, taught with lectures).
- Means: Section A 75.25, Section B 66.14, a difference of 9.11 marks.
- Welch’s t-test: t = 3.743 on 20.23 degrees of freedom, p = 0.0013. The difference is significant at α = 0.05.
- 95% confidence interval for the difference: 4.04 to 14.18 marks.
- Effect size: Cohen’s d = 1.51, a large effect.
Two cautions. The students were not randomly assigned to sections, so the gap may reflect who joined each section rather than the teaching method. And with groups this small, the interval is wide: the true advantage could be as small as 4 marks.
The Paired and One-sample examples load weekly sales for 10 stores before and after training, and 12 atta pack weights tested against 5 kg.
Assumptions to check
- Independence: each observation (or each pair) is separate from the others.
- Roughly normal data: matters for small samples (under about 30 per group). Check with the Descriptive Statistics Calculator: strong skew or extreme outliers are warning signs. For larger samples the t-test is robust.
- Equal variances: only for the pooled test. Welch’s test does not need it, which is why it is the default here.
Getting the same result in Excel and Python
Excel’s =T.TEST(A2:A13, B2:B15, 2, 3) returns the p-value. The third argument is the
number of tails (1 or 2) and the fourth is the type: 1 for paired, 2 for pooled, 3 for Welch. Excel
does not return t, df or the interval directly. In Python:
from scipy import stats
section_a = [72, 68, 81, 77, 65, 79, 84, 70, 76, 74, 88, 69]
section_b = [66, 71, 59, 73, 62, 68, 64, 70, 58, 75, 61, 67, 63, 69]
res = stats.ttest_ind(section_a, section_b, equal_var=False) # Welch
print(res.statistic, res.df, res.pvalue) # 3.743, 20.23, 0.00126
print(res.confidence_interval()) # (4.04, 14.18)
# Paired: stats.ttest_rel(after, before) One-sample: stats.ttest_1samp(x, 5)
Reporting the result
A standard write-up gives the test, the means, t with its degrees of freedom, the p-value, the interval and the effect size: “Section A scored higher than Section B (75.25 vs 66.14), Welch’s t(20.23) = 3.74, p = .001, 95% CI [4.04, 14.18], d = 1.51.” The Copy summary button gives you these numbers in one block.
Common mistakes
- Running a two-sample test on paired data. It ignores the pairing, inflates the standard error and can miss a real effect.
- Reading “not significant” as “no difference”. A small sample may simply lack the power to detect the difference. Look at the confidence interval.
- Running many t-tests to compare three or more groups. Each extra test raises the chance of a false positive. Use one-way ANOVA instead.