Two-Sample Tests Formula

Two-sample tests are hypothesis tests and confidence intervals for comparing parameters (means or proportions) of two independent populations.

The Formula

t=(xˉ1xˉ2)(μ1μ2)0s12n1+s22n2t = \frac{(\bar{x}_1 - \bar{x}_2) - (\mu_1 - \mu_2)_0}{\sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}}}

When to use: You have two separate groups—say, students taught with Method A vs Method B—and want to know if there's a real difference. Unlike paired tests where the same subjects appear in both groups, here the groups are completely independent. You compare the two sample statistics and ask: 'Is the gap between these groups larger than what random variation alone would produce?'

Quick Example

Method A: xˉ1=78\bar{x}_1 = 78, s1=10s_1 = 10, n1=35n_1 = 35. Method B: xˉ2=84\bar{x}_2 = 84, s2=12s_2 = 12, n2=40n_2 = 40. t=(8478)010235+12240=62.857+3.6=62.542.36t = \frac{(84 - 78) - 0}{\sqrt{\frac{10^2}{35} + \frac{12^2}{40}}} = \frac{6}{\sqrt{2.857 + 3.6}} = \frac{6}{2.54} \approx 2.36 With appropriate dfdf, this gives evidence of a difference.

Notation

For proportions: z=(p^1p^2)0p^(1p^)(1n1+1n2)z = \frac{(\hat{p}_1 - \hat{p}_2) - 0}{\sqrt{\hat{p}(1 - \hat{p})\left(\frac{1}{n_1} + \frac{1}{n_2}\right)}} where p^\hat{p} is the pooled proportion.

What This Formula Means

Hypothesis tests and confidence intervals for comparing parameters (means or proportions) of two independent populations. The two-sample t-test compares means; the two-proportion z-test compares proportions.

You have two separate groups—say, students taught with Method A vs Method B—and want to know if there's a real difference. Unlike paired tests where the same subjects appear in both groups, here the groups are completely independent. You compare the two sample statistics and ask: 'Is the gap between these groups larger than what random variation alone would produce?'

Formal View

t=(xˉ1xˉ2)(μ1μ2)0s12n1+s22n2t = \frac{(\bar{x}_1 - \bar{x}_2) - (\mu_1 - \mu_2)_0}{\sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}}} with dfdf from Welch's approximation

Worked Examples

Example 1

medium
Test whether two teaching methods differ in effectiveness. Method A (nA=30n_A=30, xˉA=75\bar{x}_A=75, sA=8s_A=8) vs. Method B (nB=30n_B=30, xˉB=80\bar{x}_B=80, sB=10s_B=10). Use a two-sample z-test at α=0.05\alpha=0.05.

Answer

z=2.14z = -2.14, p0.032<0.05p \approx 0.032 < 0.05. Reject H0H_0. Methods differ significantly.

First step

1
H0:μA=μBH_0: \mu_A = \mu_B; Ha:μAμBH_a: \mu_A \neq \mu_B

See the full worked solution + why-it-works coaching

SetupKey insightWhy it worksCommon pitfallConnection

Unlock answer keys One Family plan — every worked solution, all subjects

Example 2

hard
Construct a 95% confidence interval for μAμB\mu_A - \mu_B given: xˉA=50\bar{x}_A=50, xˉB=45\bar{x}_B=45, sA=6s_A=6, sB=8s_B=8, nA=nB=25n_A=n_B=25.

Example 3

medium
Compute the standard error of xˉ1xˉ2\bar{x}_1 - \bar{x}_2 given s1=5,n1=25,s2=4,n2=16s_1 = 5, n_1 = 25, s_2 = 4, n_2 = 16.

Common Mistakes

  • Running a two-sample test on paired data - if subjects are matched, use the paired t-test on differences instead.
  • Using a single pooled standard deviation by default - the two-sample t-test typically uses s12/n1+s22/n2\sqrt{s_1^2/n_1+s_2^2/n_2} with separate variances.
  • Choosing a t-test for proportion data - compare proportions with the two-proportion z-test, not the t-test for means.

Why This Formula Matters

Comparing two groups is the workhorse of A/B tests, treatment-vs-control studies, and group comparisons everywhere, and the independence of the groups is exactly what forces the combined standard error s12/n1+s22/n2\sqrt{s_1^2/n_1+s_2^2/n_2}. Recognizing 'independent groups' versus 'paired' picks the right test and the right standard error — get that wrong and the whole conclusion is off. Recognizing it by "Are the two groups made of different, unrelated subjects with no natural pairing between them?" — rather than by familiar numbers — is what lets a student tell it apart from paired t-test and two-proportion z-test and chi-square test in a mixed problem set.

Frequently Asked Questions

What is the Two-Sample Tests formula?

Hypothesis tests and confidence intervals for comparing parameters (means or proportions) of two independent populations. The two-sample t-test compares means; the two-proportion z-test compares proportions.

How do you use the Two-Sample Tests formula?

You have two separate groups—say, students taught with Method A vs Method B—and want to know if there's a real difference. Unlike paired tests where the same subjects appear in both groups, here the groups are completely independent. You compare the two sample statistics and ask: 'Is the gap between these groups larger than what random variation alone would produce?'

What do the symbols mean in the Two-Sample Tests formula?

For proportions: z=(p^1p^2)0p^(1p^)(1n1+1n2)z = \frac{(\hat{p}_1 - \hat{p}_2) - 0}{\sqrt{\hat{p}(1 - \hat{p})\left(\frac{1}{n_1} + \frac{1}{n_2}\right)}} where p^\hat{p} is the pooled proportion.

Why is the Two-Sample Tests formula important in Math?

Comparing two groups is the workhorse of A/B tests, treatment-vs-control studies, and group comparisons everywhere, and the independence of the groups is exactly what forces the combined standard error s12/n1+s22/n2\sqrt{s_1^2/n_1+s_2^2/n_2}. Recognizing 'independent groups' versus 'paired' picks the right test and the right standard error — get that wrong and the whole conclusion is off. Recognizing it by "Are the two groups made of different, unrelated subjects with no natural pairing between them?" — rather than by familiar numbers — is what lets a student tell it apart from paired t-test and two-proportion z-test and chi-square test in a mixed problem set.

What do students get wrong about Two-Sample Tests?

The procedure for two-sample tests is the easy part; the trap is running a two-sample test on paired data. Asking "Are the two groups made of different, unrelated subjects with no natural pairing between them?" first is what keeps a correct-looking calculation from being attached to the wrong concept.

What should I learn before the Two-Sample Tests formula?

Before studying the Two-Sample Tests formula, you should understand: hypothesis testing, confidence interval, sampling distribution, central limit theorem.