Two-Sample Tests Examples in Math

Start with the recap, study the fully worked examples, then use the practice problems to check your understanding of Two-Sample Tests.

This page combines explanation, solved examples, and follow-up practice so you can move from recognition to confident problem-solving in Math.

Concept Recap

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?'

Read the full concept explanation β†’

How to Use These Examples

  • Read the first worked example with the solution open so the structure is clear.
  • Try the practice problems before revealing each solution.
  • Use the related concepts and background knowledge badges if you feel stuck.

What to Focus On

Core idea: Two-sample tests compare a mean or proportion between two INDEPENDENT groups to see if they truly differ.

Common stuck point: 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.

Sense of Study hint: Ask: Are the two groups made of different, unrelated subjects with no natural pairing between them?

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, pβ‰ˆ0.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Λ‰1βˆ’xΛ‰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.

Example 4

medium
Diet A produced xˉ1=4.5\bar{x}_1 = 4.5 lb loss (s1=2,n1=40s_1 = 2, n_1 = 40); Diet B produced xˉ2=3.0\bar{x}_2 = 3.0 lb (s2=2.5,n2=40s_2 = 2.5, n_2 = 40). Compute the Welch t-statistic.

Example 5

hard
A two-sample Welch t-test gives t=βˆ’1.10t = -1.10 with df β‰ˆ50\approx 50, two-sided p-value β‰ˆ0.28\approx 0.28. State the decision at Ξ±=0.05\alpha = 0.05 and interpret in plain English.

Practice Problems

Try these problems on your own first, then open the solution to compare your method.

Example 1

easy
When should a two-sample t-test be used instead of a z-test, and what is the key assumption about the two groups?

Example 2

hard
Two independent samples: Group 1 (n=20,xˉ=100,s=15n=20, \bar{x}=100, s=15), Group 2 (n=20,xˉ=95,s=20n=20, \bar{x}=95, s=20). Calculate the t-statistic and df for a Welch's t-test (unequal variances).

Example 3

easy
Two INDEPENDENT groups (Method A vs Method B students) are compared on mean test scores. Paired or two-sample test?

Example 4

easy
In a two-sample test of means, the usual null hypothesis says the two population means are what?

Example 5

easy
Group means are xΛ‰1=50\bar{x}_1 = 50 and xΛ‰2=44\bar{x}_2 = 44. Compute the difference in sample means xΛ‰1βˆ’xΛ‰2\bar{x}_1 - \bar{x}_2.

Example 6

easy
A two-proportion z-test compares two population what?

Example 7

easy
In a two-proportion z-test of H0:p1=p2H_0: p_1 = p_2, what special proportion is used to estimate the common value under the null?

Example 8

easy
The pooled proportion is p^=x1+x2n1+n2\hat{p} = \frac{x_1 + x_2}{n_1 + n_2}. With x1=30,x2=50,n1=100,n2=100x_1 = 30, x_2 = 50, n_1 = 100, n_2 = 100, compute p^\hat{p}.

Example 9

easy
Two independent samples must satisfy which key relationship between them for a two-sample test?

Example 10

easy
A two-sample mean test gives a p-value of 0.300.30 at Ξ±=0.05\alpha = 0.05. What is the conclusion?

Example 11

medium
Two independent samples of means: xΛ‰1βˆ’xΛ‰2=6\bar{x}_1 - \bar{x}_2 = 6, standard error of the difference =2= 2. Compute the two-sample t-statistic.

Example 12

medium
The SE of a difference in means is s12n1+s22n2\sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}}. With s12=16,n1=4,s22=9,n2=9s_1^2 = 16, n_1 = 4, s_2^2 = 9, n_2 = 9, compute it.

Example 13

medium
Sample proportions p^1=0.6\hat{p}_1 = 0.6 (n1=50n_1 = 50) and p^2=0.4\hat{p}_2 = 0.4 (n2=50n_2 = 50). Compute the pooled proportion p^\hat{p}.

Example 14

medium
A two-sample t-test gives t=2.8t = 2.8, p-value =0.008= 0.008, at Ξ±=0.05\alpha = 0.05. Conclude about the two means.

Example 15

medium
A 95% CI for ΞΌ1βˆ’ΞΌ2\mu_1 - \mu_2 is (βˆ’1,5)(-1, 5). What does it imply about a difference in means at the 5% level?

Example 16

medium
Why must you NOT use a paired t-test on two independent random samples of different people?

Example 17

medium
Build a CI for ΞΌ1βˆ’ΞΌ2\mu_1 - \mu_2: difference =8= 8, SE =2.5= 2.5, tβˆ—=2.0t^* = 2.0.

Example 18

medium
For a two-proportion z-test, the pooled SE is p^(1βˆ’p^)(1n1+1n2)\sqrt{\hat{p}(1-\hat{p})(\frac{1}{n_1}+\frac{1}{n_2})}. With p^=0.5\hat{p} = 0.5, n1=n2=50n_1 = n_2 = 50, compute it.

Example 19

medium
A two-sample t-test gives t=1.0t = 1.0, p-value =0.33= 0.33, at Ξ±=0.05\alpha = 0.05. Conclude about the difference in means.

Example 20

challenge
Two independent means: xˉ1=80,xˉ2=74\bar{x}_1 = 80, \bar{x}_2 = 74, s1=10,n1=25s_1 = 10, n_1 = 25, s2=8,n2=16s_2 = 8, n_2 = 16. Compute the t-statistic.

Example 21

challenge
A two-proportion z-test of H0:p1=p2H_0: p_1 = p_2 has successes 40/10040/100 and 30/10030/100. Compute the pooled p^\hat{p}, the SE, and the z-statistic.

Example 22

challenge
Researchers compared a drug vs placebo in two independent random groups and found a significant difference in recovery rates. A colleague suggests a paired analysis instead. Explain why the paired test is inappropriate and what would justify one.

Example 23

easy
Group 1 has xΛ‰1=72\bar{x}_1 = 72 and Group 2 has xΛ‰2=68\bar{x}_2 = 68. Compute xΛ‰1βˆ’xΛ‰2\bar{x}_1 - \bar{x}_2.

Example 24

easy
A two-sample test of means gives p-value 0.0120.012. At Ξ±=0.05\alpha = 0.05, what is the decision about H0H_0?

Example 25

easy
Sample proportions: p^1=0.45\hat{p}_1 = 0.45 from n1=200n_1 = 200 and p^2=0.35\hat{p}_2 = 0.35 from n2=200n_2 = 200. Compute p^1βˆ’p^2\hat{p}_1 - \hat{p}_2.

Example 26

easy
A two-sample test of proportions gives p-value 0.210.21 at Ξ±=0.05\alpha = 0.05. State the decision.

Example 27

medium
Two-sample t-test: xΛ‰1βˆ’xΛ‰2=9\bar{x}_1 - \bar{x}_2 = 9, SE=3SE = 3. Compute the t-statistic for H0:ΞΌ1=ΞΌ2H_0: \mu_1 = \mu_2.

Example 28

medium
Build a 95% CI for ΞΌ1βˆ’ΞΌ2\mu_1 - \mu_2: difference =4= 4, SE=1.5SE = 1.5, tβˆ—=2.0t^* = 2.0.

Example 29

medium
Compute the pooled proportion p^\hat{p} for successes 36/12036/120 and 24/8024/80.

Example 30

medium
Pooled SE for a two-proportion z-test: p^=0.4\hat{p} = 0.4, n1=n2=100n_1 = n_2 = 100. Compute the pooled SE.

Example 31

medium
A 99% CI for ΞΌ1βˆ’ΞΌ2\mu_1 - \mu_2 is (2,10)(2, 10). Does the test reject H0:ΞΌ1=ΞΌ2H_0: \mu_1 = \mu_2 at Ξ±=0.01\alpha = 0.01?

Example 32

medium
Two-proportion z-test: p^1βˆ’p^2=0.08\hat{p}_1 - \hat{p}_2 = 0.08, pooled SE=0.05SE = 0.05. Compute the z-statistic.

Example 33

medium
A 95% CI for p1βˆ’p2p_1 - p_2 is (βˆ’0.04,0.06)(-0.04, 0.06). Does the corresponding two-sided test reject H0:p1=p2H_0: p_1 = p_2?

Example 34

medium
For independent samples with s1=6,n1=36,s2=8,n2=16s_1 = 6, n_1 = 36, s_2 = 8, n_2 = 16, compute the SE of xΛ‰1βˆ’xΛ‰2\bar{x}_1 - \bar{x}_2.

Example 35

hard
Welch t-test: xˉ1=102,xˉ2=96\bar{x}_1 = 102, \bar{x}_2 = 96, s1=10,n1=25,s2=8,n2=25s_1 = 10, n_1 = 25, s_2 = 8, n_2 = 25. Compute the t-statistic.

Example 36

hard
Two-proportion z-test: p^1=0.55\hat{p}_1 = 0.55 (n1=200n_1 = 200) and p^2=0.45\hat{p}_2 = 0.45 (n2=200n_2 = 200). Test H0:p1=p2H_0: p_1 = p_2 β€” compute zz.

Example 37

hard
Construct a 95% CI for p1βˆ’p2p_1 - p_2 given p^1=0.6,n1=100\hat{p}_1 = 0.6, n_1 = 100 and p^2=0.5,n2=100\hat{p}_2 = 0.5, n_2 = 100. Use zβˆ—=1.96z^* = 1.96 and the unpooled SE.

Example 38

hard
A study uses a paired t-test on two independent random samples of unrelated subjects. State why the inference may be invalid.

Example 39

hard
A two-sample test rejects H0H_0 with p-value 0.0030.003 and observed difference xΛ‰1βˆ’xΛ‰2=1.2\bar{x}_1 - \bar{x}_2 = 1.2 on a 100-point exam. Is the difference necessarily practically important?

Example 40

hard
Welch t-test gives ∣t∣=2.50|t| = 2.50 with df =30= 30. Using the rough cutoff tβˆ—β‰ˆ2.04t^* \approx 2.04 at the two-sided 5% level, decide whether to reject H0H_0.

Example 41

challenge
Two independent samples: xΛ‰1=50,xΛ‰2=47,s1=s2=6,n1=n2=36\bar{x}_1 = 50, \bar{x}_2 = 47, s_1 = s_2 = 6, n_1 = n_2 = 36. Construct a 95% CI for ΞΌ1βˆ’ΞΌ2\mu_1 - \mu_2 using tβˆ—β‰ˆ1.99t^* \approx 1.99.

Example 42

challenge
An investigator wants 80% power to detect a true difference of ΞΌ1βˆ’ΞΌ2=5\mu_1 - \mu_2 = 5 with common Οƒ=10\sigma = 10. Using the rule-of-thumb nβ‰ˆ2(Οƒ)2(zΞ±/2+zΞ²)2Ξ΄2n \approx \frac{2(\sigma)^2(z_{\alpha/2} + z_{\beta})^2}{\delta^2} with z0.025=1.96z_{0.025} = 1.96 and z0.20=0.84z_{0.20} = 0.84, estimate nn per group.

Background Knowledge

These ideas may be useful before you work through the harder examples.

hypothesis testingconfidence intervalsampling distributioncentral limit theorem