Two-Sample Tests
Medication dosages, IV drip rates, vital monitoring
Many real-world questions are about comparing two groups. Is a new drug more effective than the standard treatment? Do students who attend tutoring score higher than those who do not? Is there a difference in defect rates between two factories? Single-sample tests cannot answer these questions — you need a test that compares two sets of data. In this lesson, you will learn three such tests: the two-sample t-test for comparing independent means, the two-proportion z-test for comparing independent proportions, and the paired t-test for matched-pairs data. Together, these cover the vast majority of two-group comparisons you will encounter.
Two-Sample T-Test for Independent Means
Use this test when you have two independent groups and you want to compare their population means. “Independent” means the subjects in one group have no connection to the subjects in the other — for example, a treatment group and a control group with different people in each.
Test statistic (Welch’s t-test):
where are the sample means, are the sample standard deviations, and are the sample sizes.
Degrees of freedom: The exact degrees of freedom for Welch’s t-test use the Welch-Satterthwaite formula, which is complex. In practice, use software to compute it. For hand calculations, a conservative approximation is , which gives a slightly larger p-value than the exact method (a safe, conservative approach).
Conditions:
- Both samples are random and independent of each other
- Observations within each sample are independent
- Both populations are approximately normal, OR both sample sizes are large ( and )
- No extreme outliers, especially for small samples
Example 1: Treatment vs Control
A medical researcher tests a new cognitive training program. The treatment group () completes the program and scores with on a standardized test. The control group () receives no training and scores with . Is there evidence that the treatment group scores higher? Test at .
Step 1: State the hypotheses.
Step 2: Choose significance level: .
Step 3: Check conditions. Independent random assignment ✓. Both sample sizes are moderate (25 and 30) ✓. Test scores are typically approximately normal ✓.
Step 4: Calculate the test statistic.
Step 5: Find the p-value. Using conservative :
Step 6: Make a decision. Since , we reject .
Step 7: Conclusion in context. There is statistically significant evidence that the cognitive training program improves test scores. The treatment group scored an average of 6 points higher than the control group. This difference is both statistically significant and large enough to suggest the program has a meaningful effect on cognitive performance.
Why Welch’s T-Test?
You may encounter two versions of the two-sample t-test: the pooled (equal variance) version and the Welch (unequal variance) version. Welch’s t-test does not assume the two populations have equal standard deviations. Since this assumption is hard to verify and often violated, Welch’s t-test is the safer default. Most modern software uses Welch’s version by default. When the standard deviations are actually equal, both versions give nearly identical results — so nothing is lost by using Welch’s test.
Two-Proportion Z-Test
Use this test when you want to compare proportions from two independent groups — for example, the success rates of two treatments, the defect rates of two production lines, or the pass rates of two schools.
Pooled proportion (used under ):
where and are the number of successes in each group.
Test statistic:
The pooled proportion is used because under , we assume the two population proportions are equal. The best single estimate of that common proportion combines both samples.
Conditions:
- Both samples are independent random samples
- Observations within each sample are independent
- Large sample condition: , , , and (using the pooled )
Example 2: Drug Side Effects
A pharmaceutical company is comparing the side-effect rates of two drugs. Drug A is given to 200 patients, and 18 experience side effects. Drug B is given to 250 patients, and 30 experience side effects. Is there evidence that Drug A has a lower side-effect rate? Test at .
Step 1: State the hypotheses.
Step 2: Choose significance level: .
Step 3: Calculate the pooled proportion and check conditions.
Large sample check (using pooled ): ✓, ✓, ✓, ✓.
Step 4: Calculate the test statistic.
Step 5: Find the p-value. One-sided left:
Step 6: Make a decision. Since , we fail to reject .
Step 7: Conclusion in context. There is not sufficient evidence to conclude that Drug A has a lower side-effect rate than Drug B. While the sample rates differ (9% vs 12%), this 3-percentage-point difference could reasonably be due to random variation. A larger study would be needed to detect such a small difference if it truly exists.
Paired T-Test (Matched Pairs)
The paired t-test is used when you have two measurements on the same subjects — before and after a treatment, left eye and right eye, or any other naturally paired design. Because the two measurements are on the same individual, they are not independent of each other, so you cannot use a two-sample t-test. Instead, you compute the difference for each pair and then perform a one-sample t-test on those differences.
Procedure:
- For each pair, calculate the difference: (or whichever direction is relevant)
- Compute (the mean of the differences) and (the standard deviation of the differences)
- Test statistic: with , where is the number of pairs
Conditions:
- The pairs are randomly selected or randomly assigned
- The differences are independent of each other (one pair does not influence another)
- The population of differences is approximately normal, OR
Example 3: Blood Pressure Before and After Medication
A physician measures the systolic blood pressure of 12 patients before and after taking a new medication. The differences (after minus before) are:
Is there evidence the medication lowers blood pressure? Test at .
Step 1: State the hypotheses. Since negative differences mean blood pressure decreased:
Step 2: Choose significance level: .
Step 3: Check conditions. Random sample of patients ✓. Differences are independent (different patients) ✓. With , we need approximate normality of the differences — the values appear roughly symmetric with no extreme outliers ✓.
Step 4: Calculate and .
To find , compute each deviation from the mean and square it:
Now calculate the test statistic:
Step 5: Find the p-value. With and a one-sided left test:
The p-value is extremely small — well below any conventional significance level.
Step 6: Make a decision. Since , we reject .
Step 7: Conclusion in context. There is overwhelming evidence that the medication lowers systolic blood pressure. The average reduction of 6.8 mmHg is both statistically significant and clinically meaningful. Every single patient in the sample showed a decrease, and the magnitude of the average drop exceeds the threshold that physicians consider relevant for cardiovascular risk reduction.
Why Paired Instead of Two-Sample?
You might wonder why we do not simply compare the “before” group and the “after” group with a two-sample t-test. The answer is that the paired design is far more powerful. By computing differences within each subject, you eliminate the large person-to-person variability in baseline blood pressure. Patient A might have a baseline of 160 and Patient B might have a baseline of 120, but the medication effect within each patient can be isolated. The standard deviation of the differences () is much smaller than the standard deviation of the raw measurements would be, giving a much larger test statistic and a much smaller p-value.
Choosing the Right Two-Sample Test
| Situation | Test | Key Formula |
|---|---|---|
| Comparing means of two independent groups, unknown | Two-sample t-test (Welch) | |
| Comparing proportions of two independent groups | Two-proportion z-test | |
| Comparing two measurements on the same subjects | Paired t-test |
Decision process:
- Are you comparing means or proportions?
- Means: go to step 2
- Proportions: use the two-proportion z-test
- Are the two groups independent or paired?
- Independent (different subjects in each group): use the two-sample t-test
- Paired (same subjects measured twice, or naturally matched pairs): use the paired t-test
A common mistake is using a two-sample t-test when the data is actually paired. This ignores the pairing structure and loses statistical power. Always ask: “Are the two measurements connected to the same individual?” If yes, use the paired t-test.
Real-World Application: Nursing — Comparing Treatment Protocols
A hospital evaluates two wound-care protocols. Protocol A (the current standard) is used on 35 randomly assigned patients, with a mean healing time of days and days. Protocol B (a new approach) is used on 40 patients, with days and days. Is Protocol B faster? Test at .
(Note: tests whether Protocol A takes longer, meaning Protocol B is faster.)
Using conservative :
Since , reject . There is evidence Protocol B produces faster healing. The 1.7-day average improvement is clinically relevant: fewer inpatient days, lower infection risk, and reduced treatment costs. The nursing team should consider transitioning to Protocol B, with continued monitoring to confirm the results hold across a broader patient population.
Practice Problems
Test your understanding with these problems. Click to reveal each answer.
Problem 1: A school district compares math scores between two teaching methods. Method 1 (): , . Method 2 (): , . Is there evidence that Method 1 is better? ()
, (one-sided right)
Conservative . .
Since , reject .
Answer: There is statistically significant evidence that Method 1 produces higher math scores than Method 2. The 5-point average difference is statistically significant.
Problem 2: A marketing team tests two ad designs. Ad A: 45 clicks out of 500 impressions. Ad B: 60 clicks out of 500 impressions. Is Ad B’s click rate higher? ()
, (one-sided, testing if Ad B is higher means Ad A is lower)
.
Since , fail to reject .
Answer: There is not sufficient evidence at the 5% level that Ad B has a higher click-through rate. The observed difference of 3 percentage points could be due to chance. A larger sample size would increase the power to detect such a difference.
Problem 3: Ten runners are timed on a 5K before and after a training program. The differences (after minus before, in seconds) are: . Is there evidence the training reduces 5K time? ()
, (one-sided left)
Deviations from mean:
Squared deviations:
With , .
Since , reject .
Answer: There is strong evidence the training program reduces 5K time. The average improvement of 10.8 seconds is highly statistically significant. Nine of the ten runners improved.
Problem 4: Two hospitals compare infection rates. Hospital X: 12 infections out of 300 surgeries. Hospital Y: 20 infections out of 350 surgeries. Is there a difference in infection rates? (, two-sided)
,
Two-sided p-value .
Since , fail to reject .
Answer: There is not sufficient evidence of a difference in infection rates between the two hospitals. The observed difference (4% vs 5.7%) is not statistically significant.
Problem 5: A dietitian measures cholesterol levels of 20 patients before and after a 12-week diet program. The mean difference (after minus before) is mg/dL with mg/dL. Test whether the diet reduces cholesterol at .
, (one-sided left)
With , .
Since , reject .
Answer: There is strong evidence that the diet program reduces cholesterol. The average decrease of 18.5 mg/dL is both statistically significant and clinically meaningful — a reduction of this magnitude is associated with meaningful cardiovascular risk reduction.
Key Takeaways
- The two-sample t-test (Welch’s) compares the means of two independent groups using
- The two-proportion z-test compares proportions from two independent groups using a pooled proportion under
- The paired t-test compares two measurements on the same subjects by analyzing the differences:
- Choosing the right test depends on two questions: (1) Are you comparing means or proportions? (2) Are the groups independent or paired?
- Using a two-sample test when data is actually paired wastes statistical power — the pairing removes between-subject variability
- Welch’s t-test is preferred over the pooled t-test because it does not assume equal variances
- For the two-proportion z-test, always use the pooled proportion when calculating the standard error under
- In clinical settings, two-sample tests are essential for comparing treatment protocols, evaluating new interventions, and making evidence-based decisions about patient care
- As with all hypothesis tests, consider both statistical significance and practical significance — a statistically significant difference may or may not be large enough to matter in practice
Return to Statistics for more topics in this section.
Next Up in Statistics
All Statistics topicsLast updated: March 29, 2026