Skip to content
Statculator
Hypothesis Tests

Two-Sample t-Test Calculator

Free two sample t test calculator: enter means, SDs and sizes or raw data for t, df, the p-value, Cohen’s d and a CI, pooled or Welch, with every step.

Free, no sign-up Runs in your browserBy Hira Noor, BS MathematicsUpdated

Choose the direction your research question predicts. Use two-tailed if any difference matters.

Usually 0.05 or 0.01.

Variances

Equal runs Student’s pooled t-test with df = n₁ + n₂ − 2. Unequal runs Welch’s t-test, which is safer when one SD is more than about twice the other.

Data input
Sample 1
Sample 2

Equal variances gives the classic pooled two-sample t-test. If the standard deviations differ a lot, switch to Unequal (Welch).

Results

t statistic
2.0897
p-value
0.0438
Two-tailed, df = 36

Reject H₀ at α = 0.05

p = 0.0438 ≤ 0.05. At the 5% level there is sufficient evidence that the two population means differ.

Test
Pooled t-test (equal variances)
Mean difference, x̄₁ − x̄₂
6
Degrees of freedom
36
Pooled variance, sₚ²
78.1008
Pooled SD, sₚ
8.8375
Standard error
2.8712
Critical t (α = 0.05)
±2.0281
95% CI for μ₁ − μ₂
(0.1769, 11.8231)
Cohen’s d (pooled SD)
0.6789 (medium)
Welch t-test p (for comparison)
0.0449
Sample 1: x̄₁, s₁, n₁
82, 8.5, 20
Sample 2: x̄₂, s₂, n₂
76, 9.2, 18

Interpretation: The sample means differ by 6, which is 2.0897 standard errors from zero (pooled two-sample t-test, df = 36). A difference this large would be unlikely if the population means were equal.

t distribution curve with the shaded probability region, markers at t = 2.09t = 2.09-4-3-2-101234t distribution, df = 36
Shaded area: rejection region at the chosen α. Dashed line: your test statistic.

Step-by-step solution

  1. 1

    State the hypotheses

    This is a two-tailed test.

    H₀: μ₁ − μ₂ = 0
    H₁: μ₁ − μ₂ ≠ 0
  2. 2

    Choose the significance level

    α = 0.05
  3. 3

    Pool the two variances

    sₚ² = [(n₁ − 1)s₁² + (n₂ − 1)s₂²] / (n₁ + n₂ − 2)
    sₚ² = [(20 − 1)(8.5)² + (18 − 1)(9.2)²] / 36 = 78.1008
    sₚ = √78.1008 = 8.8375
  4. 4

    Find the standard error of the difference

    SE = sₚ √(1/n₁ + 1/n₂) = 8.8375 × √(1/20 + 1/18) = 2.8712
  5. 5

    Calculate the test statistic

    t = (x̄₁ − x̄₂) / SE = (82 − 76) / 2.8712 = 2.0897
  6. 6

    Find the p-value

    Use the t distribution with df = n₁ + n₂ − 2 = 20 + 18 − 2 = 36.

    p = 2 × P(t ≥ |2.0897|) = 0.0438
  7. 7

    Find the critical value

    Critical value: ±2.0281
    Reject H₀ if |t| ≥ 2.0281
  8. 8

    Decision: reject H₀

    At the 5% level there is sufficient evidence that the two population means differ.

    p = 0.0438 ≤ α = 0.05
  9. 9

    Effect size and confidence interval

    Cohen’s d puts the difference in pooled-standard-deviation units; the 95% interval (confidence level 1 − α) gives a plausible range for μ₁ − μ₂.

    d = (x̄₁ − x̄₂) / sₚ = 6 / 8.8375 = 0.6789
    95% CI = (x̄₁ − x̄₂) ± t∗ × SE = 6 ± 2.0281 × 2.8712 = (0.1769, 11.8231)
  10. 10

    Write up the result (APA style)

    The mean was significantly higher in sample 1 (M = 82.00, SD = 8.50, n = 20) than in sample 2 (M = 76.00, SD = 9.20, n = 18), t(36) = 2.09, p = .044, d = 0.68, 95% CI [0.18, 11.82].

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

  1. Pick the alternative hypothesis: two-tailed (≠) if any difference matters, or left- or right-tailed if you predicted a direction before seeing the data.
  2. 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.
  3. Choose Summary statistics and type each group’s mean, standard deviation and size, or Raw data and paste the two samples.
  4. 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:

  1. Find each sample’s mean, standard deviation (dividing by n − 1) and size. The Standard Deviation Calculator does this from raw data.
  2. Pool the variances: sₚ² = [(n₁ − 1)s₁² + (n₂ − 1)s₂²] / (n₁ + n₂ − 2). The Pooled Variance Calculator does this step on its own.
  3. Compute the standard error: SE = sₚ √(1/n₁ + 1/n₂).
  4. Compute t = (x̄₁ − x̄₂) / SE and df = n₁ + n₂ − 2.
  5. 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

Pooled variance
sₚ² = [(n₁ − 1)s₁² + (n₂ − 1)s₂²] / (n₁ + n₂ − 2)
Test statistic (equal variances)
t = (x̄₁ − x̄₂) / [ sₚ √(1/n₁ + 1/n₂) ]
Degrees of freedom
df = n₁ + n₂ − 2
Test statistic (Welch)
t = (x̄₁ − x̄₂) / √(s₁²/n₁ + s₂²/n₂)
Effect size
d = (x̄₁ − x̄₂) / sₚ
Confidence interval
(x̄₁ − x̄₂) ± t∗ · SE
Formula symbols
SymbolMeaning
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?

  1. 01Hypotheses: H₀: μ₁ − μ₂ = 0 versus H₁: μ₁ − μ₂ ≠ 0 (two-tailed).
  2. 02Pooled variance: sₚ² = [19(8.5²) + 17(9.2²)] / 36 = (1372.75 + 1438.88) / 36 = 78.1008, so sₚ = 8.8375.
  3. 03Standard error: SE = 8.8375 × √(1/20 + 1/18) = 8.8375 × 0.32489 = 2.8712.
  4. 04t = (82 − 76) / 2.8712 = 2.0897 with df = 36.
  5. 05Two-tailed p-value = 2 · P(T₃₆ ≥ 2.0897) ≈ 0.0438; critical value ±2.0281.
  6. 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.

  1. Summaries: x̄₁ = 993 / 12 = 82.75, s₁ = 4.0255; x̄₂ = 905 / 12 = 75.4167, s₂ = 2.7784.
  2. Pooled variance: sₚ² = [11(4.0255²) + 11(2.7784²)] / 22 = 11.9621, so sₚ = 3.4586.
  3. Standard error: SE = 3.4586 × √(1/12 + 1/12) = 1.4120.
  4. t = (82.75 − 75.4167) / 1.4120 = 5.1937, with df = 22.
  5. 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.

Choosing between the two-sample t-test and related tests
Two-sample t-test (pooled)Welch’s t-testPaired t-testTwo-sample z-test
DesignTwo independent groupsTwo independent groupsMatched pairs or before and afterTwo independent groups
Population σUnknown, assumed equalUnknown, may differUnknown (of the differences)Known
Standard errorsₚ √(1/n₁ + 1/n₂)√(s₁²/n₁ + s₂²/n₂)s_d / √n√(σ₁²/n₁ + σ₂²/n₂)
Degrees of freedomn₁ + n₂ − 2Welch–Satterthwaiten − 1 pairsNone (normal)
CalculatorThis pageWelch’s t-Test Calculator or Unequal herePaired t-Test CalculatorTwo-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 out var.equal for 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; add equal_var=False for Welch. From summaries, use ttest_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?

Both compare two independent means. The two-sample (pooled) t-test assumes the populations share one variance and uses df = n₁ + n₂ − 2. Welch’s t-test estimates each variance separately and uses the Welch–Satterthwaite degrees of freedom, so it stays accurate when variances differ. This calculator runs either one: set Variances to Equal or Unequal.

When should I use a paired t-test instead?

Use a paired (dependent) t-test when each observation in one group is naturally matched to one in the other, such as before-and-after measurements on the same people or twins assigned to different treatments. Treating paired data as independent ignores the pairing and usually loses power.

Do the two groups need the same sample size?

No. The two-sample t-test works with unequal sample sizes. However, when sizes are very unequal, the pooled test is more sensitive to unequal variances, which is another reason to choose Welch’s version.

How do I find the p-value for a 2 sample t-test?

Compute t and the degrees of freedom, then find the area beyond t in the t distribution: one tail for a one-tailed test, both tails (2 · P(T ≥ |t|)) for a two-tailed test. The calculator does this exactly; by hand you can bracket it with a t table or use the p-value from t calculator.

How do I report a two-sample t-test result?

A common APA format is: “Scores were higher with method A (M = 82.00, SD = 8.50) than method B (M = 76.00, SD = 9.20), t(36) = 2.09, p = .044, d = 0.68, 95% CI [0.18, 11.82].” The last step of the solution writes this sentence for your own data.

What if my population standard deviations are known?

If σ₁ and σ₂ are genuinely known (rare outside textbook problems and some industrial settings), use the Two-Sample Z-Test Calculator, which uses the normal distribution instead of t.

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/