What is a Two-Sample t-Test Calculator?
A two-sample t-test (2 sample t-test, also called an independent-samples or unpaired t-test) checks whether two independent groups have different population means. The pooled version divides x̄₁ − x̄₂ by the standard error sₚ√(1/n₁ + 1/n₂) to get a t statistic with n₁ + n₂ − 2 degrees of freedom, then turns t into a p-value. If p ≤ α, reject H₀: μ₁ = μ₂. When the variances differ, Welch’s version is used instead.
What the Two-Sample t-Test Calculator does
This free two sample t test calculator runs the test from summary statistics (x̄, s and n for each group) or from raw data. Choose equal variances for Student’s pooled t-test or unequal variances for Welch’s t-test. It returns the t statistic, degrees of freedom, p-value, critical value and decision, plus Cohen’s d, a confidence interval for μ₁ − μ₂ and an APA-style results sentence, draws the t distribution with the rejection region shaded, and writes out every step with your numbers. It doubles as a t test calculator for two samples, a 2 sample t-test calculator and a test statistic calculator for two samples.
Use it when one numeric outcome is measured in two separate groups, for example test scores under two teaching methods, blood pressure in a treatment and a control group, or output from two machines. If the same subjects are measured twice (a dependent or paired design), the samples are not independent; use the Paired t-Test Calculator instead. For pooled and Welch results side by side with Levene’s test, use the Independent Samples t-Test Calculator, and the T-Test Calculator covers one-sample, two-sample and paired tests on one page.
How to use the Two-Sample t-Test Calculator
- Pick the alternative hypothesis: two-tailed (≠) if any difference matters, or left- or right-tailed if you predicted a direction before seeing the data.
- Enter the significance level α (0.05 is standard) and choose Variances: Equal (pooled) for the classic test, or Unequal (Welch) when one standard deviation is much larger than the other.
- Choose Summary statistics and type each group’s mean, standard deviation and size, or Raw data and paste the two samples.
- Read the t statistic, p-value and decision. The step-by-step solution shows the pooled variance (or the Welch df), the standard error, the test statistic, Cohen’s d, the confidence interval and a ready-to-paste APA sentence.
What is a two-sample t-test?
A two-sample t-test compares the means of two independent populations using a sample from each. The null hypothesis is H₀: μ₁ = μ₂ (equivalently μ₁ − μ₂ = 0); the alternative is μ₁ ≠ μ₂ (two-tailed), μ₁ < μ₂ (left-tailed) or μ₁ > μ₂ (right-tailed). Because the population standard deviations are unknown and estimated by s₁ and s₂, the test statistic follows Student’s t distribution rather than the normal distribution.
The pooled form is often called Student’s two-sample t-test, after William Sealy Gosset, who published the t distribution as “Student” in 1908. B. L. Welch extended it in 1947 to populations with unequal variances. If σ₁ and σ₂ are genuinely known, use the Two-Sample Z-Test Calculator. For a longer explanation with more examples, read the independent-samples t-test guide.
Two-sample t-test with equal vs unequal variances
The pooled (equal-variance) test averages the two sample variances into one estimate sₚ², weighted by degrees of freedom, and uses df = n₁ + n₂ − 2. It is slightly more powerful when the population variances really are equal. Welch’s (unequal-variance) test keeps s₁²/n₁ and s₂²/n₂ separate and uses the Welch–Satterthwaite df, which is usually not a whole number. It stays accurate when the variances differ, especially when the group sizes also differ.
A practical rule: if one SD is more than about twice the other, or the group sizes are very unequal, choose Unequal (Welch). Many statisticians use Welch by default, because it loses very little when the variances are equal. In the teaching example below, the pooled test gives t = 2.0897, p = 0.0438 and Welch gives t = 2.0808, p = 0.0449 on 34.78 df, so both reject H₀. The calculator always shows the other version’s p-value for comparison.
How to interpret two-sample t-test results
To report it, give each group’s mean and SD, t with its degrees of freedom, p, d and the interval, for example: “Scores were significantly higher with method A (M = 82.00, SD = 8.50, n = 20) than method B (M = 76.00, SD = 9.20, n = 18), t(36) = 2.09, p = .044, d = 0.68, 95% CI [0.18, 11.82].” The calculator writes this sentence for your data in the last step.
- p-value: if p ≤ α, reject H₀ and conclude the population means differ (or differ in the direction you chose). If p > α, the data do not show a difference; that is not proof the means are equal.
- t statistic: how many standard errors the difference x̄₁ − x̄₂ lies from zero. A positive t means sample 1 has the higher mean.
- Critical value t∗: the cut-off from the t distribution with the test’s df. Rejecting when |t| > t∗ gives the same decision as p ≤ α. Look it up with the T Critical Value Calculator or the t-table.
- Confidence interval for μ₁ − μ₂: the plausible size of the difference. A two-tailed test at level α rejects H₀ exactly when 0 falls outside the (1 − α) interval.
- Cohen’s d: the difference in pooled-standard-deviation units (about 0.2 small, 0.5 medium, 0.8 large). Read it next to p, because with large samples a tiny difference can still be significant.
How to calculate a two-sample t-test by hand
To calculate the test statistic for two samples with the pooled formula:
- Find each sample’s mean, standard deviation (dividing by n − 1) and size. The Standard Deviation Calculator does this from raw data.
- Pool the variances: sₚ² = [(n₁ − 1)s₁² + (n₂ − 1)s₂²] / (n₁ + n₂ − 2). The Pooled Variance Calculator does this step on its own.
- Compute the standard error: SE = sₚ √(1/n₁ + 1/n₂).
- Compute t = (x̄₁ − x̄₂) / SE and df = n₁ + n₂ − 2.
- Get the p-value from the t distribution with that df, using the P-Value from t Calculator, and compare it with α. For a two-tailed test, p = 2 · P(T ≥ |t|).
Two-sample t-test formula
| Symbol | Meaning |
|---|---|
| x̄₁, x̄₂ | sample means of groups 1 and 2 |
| s₁, s₂ | sample standard deviations (divide by n − 1) |
| n₁, n₂ | sample sizes |
| sₚ | pooled standard deviation, an estimate of the common σ |
| t∗ | critical value of the t distribution with the test’s df |
This two sample t test formula (the 2 sample t-test equation) gives the p-value as the probability, under H₀: μ₁ = μ₂, of a t statistic at least as extreme as the one observed. For a two-tailed test, p = 2 · P(T ≥ |t|) with T following a t distribution on df degrees of freedom.
Sources: NIST/SEMATECH e-Handbook, Two-Sample t-Test for Equal Means; Welch, B. L. (1947), Biometrika 34(1–2), 28–35.
Worked example
Worked example: two teaching methods
Problem. Class A (n₁ = 20) averaged 82 with s₁ = 8.5; class B (n₂ = 18) averaged 76 with s₂ = 9.2. At α = 0.05, is there a difference in mean scores?
- 01Hypotheses: H₀: μ₁ − μ₂ = 0 versus H₁: μ₁ − μ₂ ≠ 0 (two-tailed).
- 02Pooled variance: sₚ² = [19(8.5²) + 17(9.2²)] / 36 = (1372.75 + 1438.88) / 36 = 78.1008, so sₚ = 8.8375.
- 03Standard error: SE = 8.8375 × √(1/20 + 1/18) = 8.8375 × 0.32489 = 2.8712.
- 04t = (82 − 76) / 2.8712 = 2.0897 with df = 36.
- 05Two-tailed p-value = 2 · P(T₃₆ ≥ 2.0897) ≈ 0.0438; critical value ±2.0281.
- 06Effect size d = 6 / 8.8375 = 0.68 (medium). 95% CI for μ₁ − μ₂: 6 ± 2.0281 × 2.8712 = (0.18, 11.82).
Answer. Because p ≈ 0.044 < 0.05 (and |t| = 2.09 > 2.03), reject H₀. Class A scored about 6 points higher, and the 95% interval for the difference excludes 0. A right-tailed test (μ₁ > μ₂) on the same data gives p ≈ 0.0219 with critical value 1.6883.
Worked example 2: two-sample t-test from raw data
Two production lines are timed on 12 jobs each. Line 1: 78, 82, 85, 80, 79, 88, 84, 81, 86, 83, 77, 90. Line 2: 72, 75, 77, 74, 76, 79, 73, 78, 71, 80, 74, 76. These are the calculator’s raw-data defaults, so switch to Raw data to follow along. Test H₀: μ₁ = μ₂ against H₁: μ₁ ≠ μ₂ at α = 0.05 with equal variances.
- Summaries: x̄₁ = 993 / 12 = 82.75, s₁ = 4.0255; x̄₂ = 905 / 12 = 75.4167, s₂ = 2.7784.
- Pooled variance: sₚ² = [11(4.0255²) + 11(2.7784²)] / 22 = 11.9621, so sₚ = 3.4586.
- Standard error: SE = 3.4586 × √(1/12 + 1/12) = 1.4120.
- t = (82.75 − 75.4167) / 1.4120 = 5.1937, with df = 22.
- Two-tailed p ≈ 0.000033, far below 0.05, so reject H₀. Cohen’s d = 7.3333 / 3.4586 = 2.12 (large); 95% CI for μ₁ − μ₂: (4.41, 10.26).
Two-sample t-test vs paired t-test vs z-test
A dependent t-test is another name for the paired t-test. For more than two groups, use the ANOVA Calculator; for yes/no outcomes rather than means, use the Two Proportion Z-Test Calculator. If the data are small and clearly skewed, a rank test such as Mann–Whitney is the usual alternative.
| Two-sample t-test (pooled) | Welch’s t-test | Paired t-test | Two-sample z-test | |
|---|---|---|---|---|
| Design | Two independent groups | Two independent groups | Matched pairs or before and after | Two independent groups |
| Population σ | Unknown, assumed equal | Unknown, may differ | Unknown (of the differences) | Known |
| Standard error | sₚ √(1/n₁ + 1/n₂) | √(s₁²/n₁ + s₂²/n₂) | s_d / √n | √(σ₁²/n₁ + σ₂²/n₂) |
| Degrees of freedom | n₁ + n₂ − 2 | Welch–Satterthwaite | n − 1 pairs | None (normal) |
| Calculator | This page | Welch’s t-Test Calculator or Unequal here | Paired t-Test Calculator | Two-Sample Z-Test Calculator |
Two-sample t-test in R, Excel, Python and the TI-84
All four use the same formulas as this calculator, so t and the p-value should match to rounding.
- R:
t.test(x, y, var.equal = TRUE)runs the pooled test; leave outvar.equalfor Welch, which is R’s default. - Excel:
=T.TEST(A2:A13, B2:B13, 2, 2)returns the two-tailed pooled p-value; type 3 instead of the last 2 for unequal variances. - Python (SciPy):
scipy.stats.ttest_ind(x, y)is pooled; addequal_var=Falsefor Welch. From summaries, usettest_ind_from_stats. - TI-84: STAT → TESTS → 4:2-SampTTest, choose Data or Stats, and set Pooled to Yes (equal) or No (Welch).
Common use cases
- Comparing a treatment group with a control group in an experiment.
- A/B tests on a continuous metric such as order value or time on page.
- Comparing average yield, strength or output between two suppliers or machines.
- Checking whether two survey subgroups differ on a rating-scale score.
Assumptions and limitations
- Independence: each observation belongs to exactly one group and observations do not influence each other. Matched or repeated measurements need the paired t-test.
- Normality: each population should be roughly normal. With about 30 or more per group the test is robust thanks to the central limit theorem; for small, skewed samples check with the Shapiro–Wilk Test Calculator or use a rank test such as Mann–Whitney.
- Equal variances (pooled version only): the pooled test assumes σ₁ = σ₂. If one SD is more than twice the other, or the group sizes are very unequal, choose Unequal (Welch), which does not need this assumption.
- A significant p-value says the difference is unlikely to be zero, not that it is large or important. Report Cohen’s d and the confidence interval for the difference alongside it.
Frequently asked questions
What is the difference between a two-sample t-test and Welch’s t-test?
When should I use a paired t-test instead?
Do the two groups need the same sample size?
How do I find the p-value for a 2 sample t-test?
How do I report a two-sample t-test result?
What if my population standard deviations are known?
Cite this page
Statculator. (2026, November 14). Two-Sample t-Test Calculator. Retrieved November 14, 2026, from https://statculator.com/hypothesis-tests/two-sample-t-test-calculator/