Skip to content

Inference for Two Sample Means (CI and Test)

Two-sample t-interval and t-test for the difference in two population means μ1 - μ2 using independent samples.

Written and reviewed by the Study Mondo Education TeamLast updated
🎯⭐ INTERACTIVE LESSON

Try the Interactive Version!

Learn step-by-step with practice exercises built right in.

Start Interactive Lesson →

📊 Inference for Two Sample Means (CI and Test)

Comparing the means of two populations—such as treatment vs. control, or two manufacturing processes—is one of the most common inference problems. We use two-sample t-procedures to estimate and test the difference μ1−μ2\mu_1 - \mu_2.

Setting Up the Problem

Let μ1\mu_1 and μ2\mu_2 be the true means of two independent populations. We draw independent samples of sizes n1n_1 and n2n_2, obtaining sample means xˉ1\bar{x}_1 and xˉ2\bar{x}_2, and sample standard deviations s1s_1 and s2s_2.

We focus on the difference xˉ1−xˉ2\bar{x}_1 - \bar{x}_2.

Sampling Distribution of xˉ1−xˉ2\bar{x}_1 - \bar{x}_2

When conditions are met:

  • Mean: μxˉ1−xˉ2=μ1−μ2\mu_{\bar{x}_1 - \bar{x}_2} = \mu_1 - \mu_2
  • Standard error: SE=s12n1+s22n2SE = \sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}}
  • Distribution: Approximately tt with complicated degrees of freedom (calculator handles this)

Two-Sample t-Interval for μ1−μ2\mu_1 - \mu_2

Confidence Interval: (xˉ1−xˉ2)±t∗⋅SE(\bar{x}_1 - \bar{x}_2) \pm t^* \cdot SE

where SE=s12n1+s22n2SE = \sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}} and t∗t^* is the critical tt-value based on the degrees of freedom.

Degrees of Freedom (Welch's adjustment): df=(s12n1+s22n2)2(s12/n1)2n1−1+(s22/n2)2n2−1df = \frac{\left( \frac{s_1^2}{n_1} + \frac{s_2^2}{n_2} \right)^2}{\frac{(s_1^2/n_1)^2}{n_1-1} + \frac{(s_2^2/n_2)^2}{n_2-1}}

(Most calculators compute this automatically; always use the more conservative estimate if doing by hand.)

Two-Sample t-Test for μ1=μ2\mu_1 = \mu_2

Null Hypothesis: H0:μ1=μ2H_0: \mu_1 = \mu_2 (or equivalently, μ1−μ2=0\mu_1 - \mu_2 = 0)

Test Statistic: t=(xˉ1−xˉ2)−0SEt = \frac{(\bar{x}_1 - \bar{x}_2) - 0}{SE}

Compare to the tt-distribution with the appropriate df to find the p-value.

Alternative Hypotheses:

  • Two-tailed: Ha:μ1≠μ2H_a: \mu_1 \neq \mu_2
  • One-tailed: Ha:μ1>μ2H_a: \mu_1 > \mu_2 or Ha:μ1<μ2H_a: \mu_1 < \mu_2

Conditions for Two-Sample t-Procedures

All methods require:

ConditionRequirement
Random samplesBoth samples randomly selected.
IndependenceSamples are independent of each other; within each sample, observations are independent (10% condition if sampling without replacement).
Nearly NormalEach sample is approximately Normal (large sample or no extreme outliers). For n≥30n \geq 30, use t-procedures even if distribution is somewhat non-normal.

Robustness of t-Tests

t-procedures are robust to departures from Normality, especially for large samples and balanced designs (n1≈n2n_1 \approx n_2). However:

  • With very small samples (n<15n < 15) and skewed data, be cautious.
  • With very large samples (n>100n > 100), slight departures from Normality are not a concern.

Worked Example 1: Two-Sample t-Interval

Two high schools compare math proficiency test scores:

  • School A: n1=25n_1 = 25, xˉ1=78\bar{x}_1 = 78, s1=8s_1 = 8
  • School B: n2=30n_2 = 30, xˉ2=75\bar{x}_2 = 75, s2=10s_2 = 10

Construct a 95% CI for μA−μB\mu_A - \mu_B.

Standard error: SE=8225+10230=6425+10030=2.56+3.333=5.893≈2.427SE = \sqrt{\frac{8^2}{25} + \frac{10^2}{30}} = \sqrt{\frac{64}{25} + \frac{100}{30}} = \sqrt{2.56 + 3.333} = \sqrt{5.893} \approx 2.427

Degrees of freedom (conservative estimate: use n−1=24n - 1 = 24 from smaller sample): Using df=24df = 24 and 95% confidence, t∗≈2.064t^* \approx 2.064.

CI: (78−75)±2.064(2.427)=3±5.008=(−2.008,8.008)(78 - 75) \pm 2.064(2.427) = 3 \pm 5.008 = (-2.008, 8.008)

We are 95% confident that School A's mean exceeds School B's by between −2.0 and +8.0 points.

Worked Example 2: Two-Sample t-Test

Test H0:μ1=μ2H_0: \mu_1 = \mu_2 vs. Ha:μ1≠μ2H_a: \mu_1 \neq \mu_2 at α=0.05\alpha = 0.05 using the data above.

Test statistic: t=3−02.427≈1.236t = \frac{3 - 0}{2.427} \approx 1.236

p-value (two-tailed with df≈24df \approx 24): p-value=2×P(T>1.236)≈2(0.114)≈0.228p\text{-value} = 2 \times P(T > 1.236) \approx 2(0.114) \approx 0.228

Since p-value=0.228>0.05p\text{-value} = 0.228 > 0.05, we fail to reject H0H_0. Insufficient evidence that the school means differ.

Common Pitfalls

⚠️ Confusing SE with ss: SE=s12/n1+s22/n2SE = \sqrt{s_1^2/n_1 + s_2^2/n_2} is the standard error of xˉ1−xˉ2\bar{x}_1 - \bar{x}_2. Do not use the sample standard deviations directly as if they were the population SDs.

⚠️ Forgetting Independence: Two-sample t-tests require independent samples. If the samples are paired (same individuals measured twice), use a paired t-test instead.

⚠️ Misinterpreting CI: A 95% CI does not mean there is a 95% probability that μ1−μ2\mu_1 - \mu_2 is in the interval for this specific data. Rather, the method has 95% long-run success rate.

Calculator Tip

💡 TI-84 / TI-Nspire: Use 2-SampTInt for confidence intervals and 2-SampTTest for hypothesis tests. Enter the summary statistics (xˉ1,s1,n1,xˉ2,s2,n2\bar{x}_1, s_1, n_1, \bar{x}_2, s_2, n_2) and the alternative hypothesis. The calculator computes df and the interval or test automatically (with or without assuming equal variances).

📚 Practice Problems

1Problem 1easy

❓ Question:

Two basketball teams have mean shooting percentages: Team A (n=20n=20, xˉ=45%\bar{x}=45\%, s=8%s=8\%) and Team B (n=25n=25, xˉ=42%\bar{x}=42\%, s=10%s=10\%). Construct a 90% CI for μA−μB\mu_A - \mu_B.

💡 Show Solution

Standard error: SE=8220+10225=6420+10025=3.2+4=7.2≈2.683SE = \sqrt{\frac{8^2}{20} + \frac{10^2}{25}} = \sqrt{\frac{64}{20} + \frac{100}{25}} = \sqrt{3.2 + 4} = \sqrt{7.2} \approx 2.683

Degrees of freedom (conservative: min⁡(n1−1,n2−1)=19\min(n_1 - 1, n_2 - 1) = 19): For df=19df = 19 and 90% confidence, t∗≈1.729t^* \approx 1.729.

CI: (45−42)±1.729(2.683)=3±4.637=(−1.637,7.637)(45 - 42) \pm 1.729(2.683) = 3 \pm 4.637 = (-1.637, 7.637)

We are 90% confident that Team A's mean shooting % exceeds Team B's by between −1.6% and +7.6%.

2Problem 2medium

❓ Question:

A sleep study compares two treatments: Placebo (n=15n=15, xˉ=6.2\bar{x}=6.2 hours, s=1.1s=1.1) and Drug (n=15n=15, xˉ=7.4\bar{x}=7.4 hours, s=1.3s=1.3). Test H0:μplacebo=μdrugH_0: \mu_{placebo} = \mu_{drug} vs. Ha:μplacebo<μdrugH_a: \mu_{placebo} < \mu_{drug} at α=0.05\alpha = 0.05.

💡 Show Solution

Standard error: SE=1.1215+1.3215=1.2115+1.6915=2.915≈0.440SE = \sqrt{\frac{1.1^2}{15} + \frac{1.3^2}{15}} = \sqrt{\frac{1.21}{15} + \frac{1.69}{15}} = \sqrt{\frac{2.9}{15}} \approx 0.440

Test statistic: t=(6.2−7.4)−00.440=−1.20.440≈−2.727t = \frac{(6.2 - 7.4) - 0}{0.440} = \frac{-1.2}{0.440} \approx -2.727

Degrees of freedom (conservative: df=14df = 14): For one-tailed, Ha:μ1<μ2H_a: \mu_1 < \mu_2: P(T<−2.727∣df=14)≈0.008P(T < -2.727 \mid df = 14) \approx 0.008

Since p-value≈0.008<0.05p\text{-value} \approx 0.008 < 0.05, we reject H0H_0. Significant evidence that the drug increases sleep compared to placebo.

3Problem 3hard

❓ Question:

In a quality control study, Product A (n1=50n_1=50, xˉ1=100\bar{x}_1=100, s1=12s_1=12) and Product B (n2=50n_2=50, xˉ2=102\bar{x}_2=102, s2=15s_2=15) are compared. Calculate the 99% CI for μA−μB\mu_A - \mu_B and interpret whether the products differ significantly.

💡 Show Solution

Standard error: SE=12250+15250=14450+22550=36950=7.38≈2.717SE = \sqrt{\frac{12^2}{50} + \frac{15^2}{50}} = \sqrt{\frac{144}{50} + \frac{225}{50}} = \sqrt{\frac{369}{50}} = \sqrt{7.38} \approx 2.717

Degrees of freedom (approximate, using Welch's formula or conservative df=49df = 49): For df=49df = 49 (or even ∞\infty for large samples) and 99% confidence, t∗≈2.681t^* \approx 2.681.

CI: (100−102)±2.681(2.717)=−2±7.286=(−9.286,5.286)(100 - 102) \pm 2.681(2.717) = -2 \pm 7.286 = (-9.286, 5.286)

Interpretation: At 99% confidence, the true difference μA−μB\mu_A - \mu_B is between −9.286 and +5.286. Since 0 is in the interval, there is no significant difference between the products at the 0.01 level. The observed 2-unit difference in samples could easily be due to random variation.

Explain using:

⚠️ Common Mistakes: Inference for Two Sample Means (CI and Test)

Avoid these 3 frequent errors

📌 Related Topics in Unit 7: Inference for Quantitative Data — Means

❓ Frequently Asked Questions

What is Inference for Two Sample Means (CI and Test)?▾
Two-sample t-interval and t-test for the difference in two population means μ1 - μ2 using independent samples.
How can I study Inference for Two Sample Means (CI and Test) effectively?▾
Start by reading the study notes and working through the examples on this page. Then use the flashcards to test your recall. Practice with the 3 problems provided, checking solutions as you go. Regular review and active practice are key to retention.
Is this Inference for Two Sample Means (CI and Test) study guide free?▾
Yes — all study notes, flashcards, and practice problems for Inference for Two Sample Means (CI and Test) on Study Mondo are free to access. No account is needed.
What course covers Inference for Two Sample Means (CI and Test)?▾
Inference for Two Sample Means (CI and Test) is part of the AP Statistics course on Study Mondo, specifically in the Unit 7: Inference for Quantitative Data — Means section. You can explore the full course for more related topics and practice resources.
Are there practice problems for Inference for Two Sample Means (CI and Test)?▾
Yes, this page includes 3 practice problems with detailed solutions. Each problem includes a step-by-step explanation to help you understand the approach.