๐Ÿ“– Contents Chapter 12 ยท Two-Sample Tests
Statistics · Chapter 12

Two-Sample Tests

Almost every interesting question in statistics is a comparison. Does this treatment beat that one? Do these two groups of customers behave differently? Did the change we made actually change anything? A one-sample test asks whether a single group differs from a fixed number; a two-sample test asks whether two groups differ from each other — and that is the question the world usually cares about. This chapter builds the four workhorse procedures (two independent means, paired means, two proportions, and the confidence intervals that go with them), shows you exactly how to decide which one a given study calls for, and works the arithmetic all the way through so you can see there is no magic in it.

By the end of this chapter you can

  • Recognize when two samples are independent and when they are paired, and explain why the distinction changes the analysis.
  • State the hypotheses, check the conditions, and compute the test statistic for a two-sample t-test of independent means.
  • Reduce a matched-pairs study to a single sample of differences and run a paired t-test.
  • Carry out a two-proportion z-test, including the pooled proportion and the success–failure check.
  • Use a decision guide to choose the correct test from the study design, and name a sensible alternative when conditions fail.
  • Build and correctly interpret confidence intervals for a difference of two means or two proportions.
  • Explain the duality between a two-sided test and a confidence interval — and the one place it breaks down.
  • State precisely what a p-value and a 95% confidence interval do and do not mean.

Section 1Two independent means

Side-by-side box plots comparing the distribution of a numeric variable across two groups
Reference. Side-by-side box plots — the standard first look at a two-group comparison, showing center, spread, and outliers for each group on one scale. Source and licence: see the figure credits

Two groups, one question

You have measured a numeric outcome — a test score, a reaction time, a blood pressure, a delivery time — on two separate groups of subjects, and the group averages came out different. They always do. Two samples drawn from the very same population will differ by chance alone. The entire job of a two-sample test is to answer one question: is the gap we observed bigger than chance would comfortably produce?

The samples here are independent, which has a precise meaning: knowing any value in group 1 tells you nothing about any value in group 2, and no subject appears in both groups. Two randomly assigned treatment arms are independent. Men and women in one survey are independent. The same forty people measured in January and again in June are not — that is Section 2's problem.

Write the population means as μ1 and μ2. The hypotheses are about the difference:

H0: μ1 − μ2 = 0     Ha: μ1 − μ2 ≠ 0

Notice what the null says: the two populations have the same mean. It does not say the two samples had the same mean — they plainly did not, or you would not be testing anything.

The test statistic, and where it comes from

Every test statistic in this book has the same shape: (what we saw) minus (what the null predicted), divided by how much that quantity naturally wobbles. Our estimate of μ1 − μ2 is x̄1 − x̄2. Its wobble is measured by the standard error of the difference. Because the two samples are independent, their variances add (never their standard deviations):

SE = √( s12/n1 + s22/n2 )

and the test statistic is

t = ( x̄1 − x̄2 − 0 ) / SE

Since we estimated both standard deviations from data, the reference curve is a t-distribution rather than the normal. The degrees of freedom are the awkward part. Welch's approximation — what statistical software gives you by default and what you should use by default — is

df = ( s12/n1 + s22/n2 )2 ÷ [ (s12/n1)2/(n1−1) + (s22/n2)2/(n2−1) ]

This is rarely a whole number, and that is fine. Working by hand without software, you may round the df down to the nearest integer; that is deliberately conservative, giving a slightly wider interval and a slightly larger p-value, so you never overstate your evidence.

ConditionWhat it meansHow to check it
Independence withinObservations inside each group do not influence one anotherRandom sample, or random assignment; sample under 10% of the population
Independence betweenNo subject appears in both groups; no natural pairingRead the study design — this is a design fact, not a data fact
Normality (or size)Each population is roughly normal, or each sample is largeDot plot / box plot per group; n ≥ 30 per group makes mild skew harmless
OutliersNo single point is driving the differenceLook at the box plots; investigate, do not silently delete

A worked example, all the way through

A trainer compares two coaching formats. Format A: n1 = 12, x̄1 = 78.4, s1 = 8.2. Format B: n2 = 15, x̄2 = 71.9, s2 = 9.6. Participants were randomly assigned, so the groups are independent. Test at α = 0.05, two-sided.

Step 1 — the observed difference. 78.4 − 71.9 = 6.5 points.

Step 2 — the standard error. First the two pieces:
s12/n1 = 8.22/12 = 67.24/12 = 5.6033
s22/n2 = 9.62/15 = 92.16/15 = 6.1440
Sum = 11.7473, so SE = √11.7473 = 3.4274.

Step 3 — the test statistic. t = 6.5 / 3.4274 = 1.896. The observed gap is about 1.9 standard errors from zero.

Step 4 — degrees of freedom.
Numerator: 11.74732 = 138.00
Denominator: 5.60332/11 + 6.14402/14 = 31.397/11 + 37.749/14 = 2.8543 + 2.6963 = 5.5506
df = 138.00 / 5.5506 = 24.9.

Step 5 — the p-value and the decision. With about 25 degrees of freedom, the two-sided cutoff at α = 0.05 is t* ≈ 2.06. Our 1.896 does not reach it; the two-sided p-value is roughly 0.07. Since 0.07 > 0.05, we fail to reject H0.

Step 6 — say it in English. "A 6.5-point advantage for Format A was observed, but with these sample sizes and this much spread a gap at least that large, in either direction, would arise about 7 times in 100 even if the two formats were truly identical (t = 1.90, df ≈ 24.9, p ≈ 0.07). The data do not provide convincing evidence of a difference." Note what we did not say: we did not say the formats are equal. Failing to reject is a failure to convict, not a verdict of innocence — the study may simply be too small.

Use Welch's test by default. The older "pooled" two-sample t-test assumes the two populations have equal variances and combines them into one estimate, buying slightly more degrees of freedom. That assumption is rarely knowable and, when it is wrong with unequal sample sizes, the pooled test's error rate is wrong too. Welch's version costs almost nothing when variances really are equal and protects you when they are not. If your software says "Welch two-sample t-test," you are in good hands.
Interactive Draw real samples from two populations you control, watch the difference between their means bounce around, and see exactly where its standard error comes from โ€” variances add, standard errors do not. Open full ↑
Key points
  • Independent samples means no subject is in both groups and no natural pairing exists.
  • Variances add: SE = √(s12/n1 + s22/n2). Standard deviations never add.
  • t = (x̄1 − x̄2) / SE, referred to a t-curve with Welch degrees of freedom.
  • "Fail to reject" means insufficient evidence — never proof that the means are equal.

Section 2Paired samples

Chart of repeated measurements taken on the same subjects across conditions
Reference. Repeated measurements on the same subjects — when every subject supplies more than one value, the observations are linked rather than independent, and the analysis must respect that. Source and licence: see the figure credits

What makes a pair a pair

Sometimes the two columns of numbers are not two separate crowds of people but the same people twice, or two people deliberately matched to each other. Each observation in column 1 has a natural, non-arbitrary partner in column 2. That is a matched-pairs (or paired) design, and it shows up constantly:

DesignWhat is pairedTypical example
Before / afterThe same subject at two timesReaction time before and after a training module
Two treatments, one subjectThe same subject under both conditionsLeft eye vs. right eye; two tires on the same car
Matched subjectsTwo different subjects paired on key traitsTwins; customers matched on age, region, and spend
Two raters, one itemThe same item scored twiceTwo graders scoring the same 30 essays
Not pairedNothing links row i of one group to row i of the other40 people in treatment, 45 different people in control

Here is the beautiful part: a paired analysis is not a new theory. You compute each pair's difference, d = (value 1) − (value 2), throw away the original columns, and run an ordinary one-sample t-test on the single column of differences against a null value of 0.

H0: μd = 0     Ha: μd ≠ 0     t = d̄ / ( sd / √n )     df = n − 1

where n is the number of pairs, not the number of measurements. Eight people measured twice give you n = 8 and df = 7, not n = 16.

Because the procedure is a one-sample t-test, its conditions are the one-sample conditions — but applied to the column of differences, not to the original two columns. This is the point students most often skip.

ConditionWhat it meansHow to check it
Independence of pairsOne pair's difference tells you nothing about another pair'sRandom sample of pairs, or random assignment of order within pairs; sample under 10% of the population
Normality of the differencesThe population of differences is roughly normal, or there are enough pairsDot plot / histogram of the d column; n ≥ 30 pairs makes mild skew harmless. The two original columns may be skewed — only d matters
Outliers among differencesNo single pair is driving d̄Scan the d column; one huge difference in a small study can create or erase significance

In the worked example below there are only eight pairs, so normality of the differences carries real weight. The eight differences run from −3 to 14 with no gaps or outliers — consistent with a roughly symmetric population — so the t-procedure is reasonable. With a clearly skewed or outlier-ridden difference column and this few pairs, the Wilcoxon signed-rank test of Section 4 would be the safer choice.

Why pairing is worth doing

People differ enormously from one another, and that person-to-person variation is pure noise when you are trying to detect a treatment effect. Pairing subtracts that noise away: a naturally slow responder is slow in both columns, so the difference is unaffected by how slow they are. What is left in the difference column is the effect plus measurement noise — a much quieter signal to listen to. That is why a paired design can detect an effect with eight subjects that an independent design would miss with forty. Section 4 shows this on real numbers.

A worked example, all the way through

Eight participants completed a task; their reaction time in milliseconds was recorded before and after a short training module. Same eight people both times, so the data are paired. Test at α = 0.05, two-sided, with d = before − after (so a positive d̄ means they got faster).

ParticipantBefore (ms)After (ms)d = before − after
141240012
23853805
3401404−3
44304219
539638214
64214192
74084017
844543510
Mean412.25405.257.00

Step 1 — mean difference. The differences sum to 12 + 5 − 3 + 9 + 14 + 2 + 7 + 10 = 56, so d̄ = 56/8 = 7.00 ms. (Reassuringly, this equals 412.25 − 405.25 — the mean of the differences is always the difference of the means.)

Step 2 — standard deviation of the differences. Deviations from 7: 5, −2, −10, 2, 7, −5, 0, 3. Squares: 25, 4, 100, 4, 49, 25, 0, 9, summing to 216.
sd2 = 216 / (8 − 1) = 30.857, so sd = 5.555 ms.

Step 3 — standard error. SE = 5.555 / √8 = 5.555 / 2.8284 = 1.964 ms.

Step 4 — test statistic and df. t = 7.00 / 1.964 = 3.564, with df = 8 − 1 = 7.

Step 5 — p-value and decision. On 7 degrees of freedom the two-sided cutoff at α = 0.05 is 2.365, and the cutoff at α = 0.01 is 3.499. Our 3.564 clears both, so the two-sided p-value is a little under 0.01 — about 0.009. We reject H0.

Step 6 — say it in English. "Reaction times improved by an average of 7.0 ms after training. A mean change at least this large, in either direction, would occur in fewer than 1% of studies if training truly had no effect (paired t = 3.56, df = 7, p ≈ 0.009), so there is convincing evidence that reaction time changed." Because this was a before/after study with no control group, we should stop short of crediting the training itself — practice effects and simple familiarity with the task are unaddressed rival explanations. The test is valid; the causal claim is limited by the design.

Pairing is decided by the design, not by the data. You cannot look at two columns of equal length, notice they line up nicely, and declare them paired — nor can you unpair genuinely linked data because the independent test looks tidier. Ask one question of the study: does row 3 of column A have a specific, pre-existing reason to be matched with row 3 of column B? If yes, pair. If the rows could be shuffled without losing information, they are independent.
Interactive Sort ten real study designs into paired and independent, then watch one crossover study's identical numbers analysed both ways โ€” live sliders for the effect, the spread, the pairing correlation ฯ and the number of pairs drive six computed SVG charts that show exactly what the pairing is worth. Open full ↑
Key points
  • Paired data means every observation has one specific partner — same subject twice, or deliberately matched subjects.
  • Collapse the pairs to differences and run a one-sample t-test on them: t = d̄ / (sd/√n), df = n − 1.
  • n is the number of pairs. Eight people measured twice give df = 7.
  • Check the conditions on the difference column: independent pairs, roughly normal differences (or enough pairs), no dominating outlier.
  • Pairing removes subject-to-subject variability, which is why it is far more powerful for the same sample size.

Section 3Two proportions

Diagram comparing event rates between two groups and how their ratio is computed
Reference. Two groups, two event rates — the setup behind every comparison of proportions, whether reported as a difference or as a ratio. Source and licence: see the figure credits

When the outcome is yes-or-no

Now the outcome is not a number but a category with two levels: clicked or did not click, recovered or did not recover, passed or failed. Each group is summarized by a sample proportion, p̂ = (number of successes) / (group size). "Success" simply labels the outcome you are counting; it carries no cheerful connotation.

H0: p1 − p2 = 0     Ha: p1 − p2 ≠ 0

Here the reference curve is the standard normal, so the statistic is a z, not a t. The reason is that a proportion's standard deviation is determined entirely by the proportion itself — √(p(1−p)) — so once you assume a value for p there is no separate variance to estimate from data, and no degrees of freedom to lose.

The pooled proportion — and why it appears only in the test

The null hypothesis says the two population proportions are equal to some common value. If that is true, the best estimate of that common value uses every observation you have, ignoring group labels:

p̂pool = (x1 + x2) / (n1 + n2)

and the standard error used for the test is built from that single pooled value:

SEpool = √( p̂pool(1 − p̂pool) × (1/n1 + 1/n2) )     z = (p̂1 − p̂2) / SEpool

A confidence interval, by contrast, is not built under the null — it is an estimate of whatever the difference actually is — so it uses the unpooled standard error with each group's own proportion. That distinction is the single most common slip in this section, and Section 5 returns to it.

The conditions are independence (as before) plus the success–failure condition: the normal approximation only works if you have enough of both outcomes. For the test, check it with the pooled proportion; all four of n1p̂pool, n1(1−p̂pool), n2p̂pool, n2(1−p̂pool) should be at least 10.

A worked example, all the way through

An email is sent in two versions. Version 1: 45 of 150 recipients responded. Version 2: 30 of 160 responded. Recipients were randomly assigned to a version. Test at α = 0.05, two-sided.

Step 1 — the sample proportions.
p̂1 = 45/150 = 0.300   p̂2 = 30/160 = 0.1875
Observed difference = 0.300 − 0.1875 = 0.1125, that is, 11.25 percentage points.

Step 2 — the pooled proportion. p̂pool = (45 + 30)/(150 + 160) = 75/310 = 0.24194.

Step 3 — check success–failure. 150(0.24194) = 36.3 and 150(0.75806) = 113.7; 160(0.24194) = 38.7 and 160(0.75806) = 121.3. All four exceed 10. ✓

Step 4 — pooled standard error.
p̂pool(1 − p̂pool) = 0.24194 × 0.75806 = 0.18340
1/150 + 1/160 = 0.006667 + 0.006250 = 0.012917
Product = 0.18340 × 0.012917 = 0.0023688, so SEpool = √0.0023688 = 0.04867.

Step 5 — the test statistic. z = 0.1125 / 0.04867 = 2.31.

Step 6 — p-value and decision. For the standard normal, the area beyond z = 2.31 in one tail is 0.0104. Doubling it for a two-sided test gives p = 0.021. Since 0.021 < 0.05, we reject H0.

Step 7 — say it in English. "Version 1 drew responses from 30.0% of recipients versus 18.8% for Version 2, an 11.3-percentage-point difference. If the two versions were equally effective, a gap this large or larger, in either direction, would appear in about 2% of experiments (z = 2.31, p = 0.021), so there is convincing evidence that response rates differ." Because assignment was random, a causal reading is defensible here in a way it was not in Section 2.

QuantityFormulaUsed forIn our example
Differencep̂1 − p̂2Both test and interval0.1125
Pooled p̂(x1+x2)/(n1+n2)Test only0.24194
SE, pooled√(p̂pool(1−p̂pool)(1/n1+1/n2))The z-statistic0.04867
SE, unpooled√(p̂1(1−p̂1)/n1 + p̂2(1−p̂2)/n2)Confidence interval only0.04850
Percentage points are not percent. Going from 18.8% to 30.0% is a rise of 11.3 percentage points, but a 60% relative increase (0.1125 / 0.1875 = 0.60). Both numbers are true and they describe the same data; headlines choose whichever sounds larger. State which one you mean, every time.
Interactive Run a two-arm trial patient by patient, watch the gap between two sample proportions bounce around, and see why the test and the confidence interval are built from two different standard errors. Open full ↑
Key points
  • Two proportions use a z-statistic — there are no degrees of freedom to estimate.
  • The pooled proportion is used for the test because the null asserts the proportions are equal.
  • The confidence interval uses the unpooled standard error, because it is not assuming the null.
  • Check success–failure: at least 10 successes and 10 failures expected in each group.

Section 4Choosing the right test

Diagram of the null hypothesis significance testing framework
Reference. The null-hypothesis testing framework — every procedure in this chapter is the same skeleton with a different standard error bolted on. Source and licence: see the figure credits

Two questions get you there

Students often try to memorize a dozen tests. You do not need to. For the two-sample world, two questions settle it almost every time.

Question 1: what kind of outcome did you measure? If each subject produced a number you could sensibly average — minutes, dollars, millimetres of mercury — you are comparing means. If each subject produced a yes/no label you are counting, you are comparing proportions. (A 1–5 satisfaction rating is a genuine grey area; treating it as numeric is common and usually defensible, but say what you did.)

Question 2: how are the two groups related? If every value in one group has a specific partner in the other, the data are paired. Otherwise they are independent. This is answered by reading the study design, never by staring at the numbers.

OutcomeGroup relationshipTestStatisticReference curve
NumericIndependentTwo-sample (Welch) t-test(x̄1−x̄2)/√(s12/n1+s22/n2)t, Welch df
NumericPairedPaired t-testd̄/(sd/√n)t, df = n−1
Yes/noIndependentTwo-proportion z-test(p̂1−p̂2)/SEpoolStandard normal
Yes/noPairedMcNemar's testBuilt only from the discordant pairsChi-square, df = 1
Numeric, badly skewed / tiny nIndependentWilcoxon rank-sum (Mann–Whitney)Rank-basedIts own distribution
Numeric, badly skewed / tiny nPairedWilcoxon signed-rankRank-basedIts own distribution
Yes/no, small countsIndependentFisher's exact testExact enumeration— (exact)

What the choice actually costs you

This is not bookkeeping; the wrong choice changes the answer. Take the exact eight participants from Section 2 and pretend, wrongly, that the "before" and "after" columns came from two unrelated groups of eight people. The two column means are unchanged: 412.25 and 405.25, a difference of 7.00 ms. But now the person-to-person spread is back in the denominator. Working from those columns, sbefore = 19.33 and safter = 19.08, so

SE = √(19.332/8 + 19.082/8) = √(46.71 + 45.49) = √92.20 = 9.602

t = 7.00 / 9.602 = 0.73, df ≈ 14, p ≈ 0.48

The same seven-millisecond effect goes from p ≈ 0.009 (paired, correct) to p ≈ 0.48 (independent, wrong) — from convincing evidence to nothing at all. The paired standard error was 1.96 ms; the independent one was 9.60 ms, nearly five times larger, because it is dominated by the fact that participant 8 is simply slower than participant 2. Pairing sweeps that irrelevance out of the calculation. Analyze paired data as independent and you will routinely fail to find effects that are really there.

The reverse mistake is worse. If the data are genuinely independent, there is no way to line them up into pairs, and forcing a pairing (by sort order, or by row number in a spreadsheet) manufactures a relationship that does not exist and produces a p-value with no meaning at all.

Three decisions to make before you look

Fix these in advance, because deciding them after seeing the data invalidates the p-value:

The design chooses the test; the p-value never does. If two procedures give different answers on the same data, that is not a menu — one of them is wrong for that design. Write down which test the design calls for before you compute anything, and stick to it whichever way the number lands.
Interactive Walk a decision tree from a study's description to the right two-sample test, then watch the test at the end of your path run live on the real data beside the test you would have reached by answering differently โ€” and simulate thousands of studies to see what the last question is actually worth. Open full ↑
Key points
  • Two questions choose the test: numeric or yes/no outcome, and independent or paired groups.
  • Paired numeric → paired t; independent numeric → Welch t; independent yes/no → two-proportion z; paired yes/no → McNemar.
  • Analyzing paired data as independent inflates the standard error and hides real effects.
  • Fix your direction, your α, and your number of comparisons before seeing results.

Section 5Two-sample confidence intervals

Illustration of a confidence interval around an estimate
Reference. A confidence interval around an estimate — the range of plausible values that a point estimate alone cannot convey. Source and licence: see the figure credits

From a verdict to a measurement

A test returns a verdict: reject, or fail to reject. That is a thin answer. It does not say how big the difference is, and "significant" and "important" are entirely different words. A confidence interval for the difference answers the better question — how big, give or take how much? — and every two-sample interval in this chapter has one shape:

(point estimate) ± (critical value) × (standard error)

ComparisonPoint estimateStandard errorCritical value
Two independent meansx̄1 − x̄2√(s12/n1 + s22/n2)t*, Welch df
Paired meansd̄sd/√nt*, df = n − 1
Two proportionsp̂1 − p̂2√(p̂1(1−p̂1)/n1 + p̂2(1−p̂2)/n2) — unpooledz* (1.96 for 95%)

The product of the last two columns is the margin of error. Nothing else changes from procedure to procedure.

Worked: the interval for Section 1's data

Return to the coaching study: x̄1 − x̄2 = 6.5, SE = 3.4274, df ≈ 24.9.

Step 1 — critical value. For 95% confidence with about 25 degrees of freedom, t* ≈ 2.06. (Rounding df down to 24 gives 2.064 — the difference is invisible at two decimals.)

Step 2 — margin of error. 2.06 × 3.4274 = 7.06 points.

Step 3 — the interval. 6.5 − 7.06 = −0.56 and 6.5 + 7.06 = 13.56, giving (−0.56, 13.56) points.

Step 4 — read it. The interval contains 0, so "no difference" is among the plausible values — exactly matching the earlier decision to fail to reject at α = 0.05. But it says far more than the test did: it says Format A could plausibly be a half-point worse or as much as thirteen and a half points better. That is an enormous range. The honest conclusion is not "the formats are the same"; it is "this study was too small to tell us anything useful, and it should be repeated with more participants."

The other two examples work identically. For the paired reaction times: 7.00 ± 2.365 × 1.964 = 7.00 ± 4.65, giving (2.35, 11.65) ms — entirely above zero, matching p ≈ 0.009. For the two email versions, using the unpooled SE = √(0.300×0.700/150 + 0.1875×0.8125/160) = √(0.001400 + 0.000952) = 0.04850, the interval is 0.1125 ± 1.96 × 0.04850 = 0.1125 ± 0.0951, giving (0.017, 0.208) — between 1.7 and 20.8 percentage points, all positive.

Duality — and the one place it leaks

For the two t-procedures, the interval and the two-sided test are two views of one calculation. A 95% interval that excludes 0 corresponds exactly to a two-sided test rejecting at α = 0.05; an interval containing 0 corresponds exactly to failing to reject. Both use the same point estimate, the same standard error, and the same critical value.

For two proportions this correspondence is only approximate, because the test uses the pooled standard error and the interval uses the unpooled one. When a result sits very near the boundary the two can disagree — a p-value of 0.048 alongside an interval whose lower limit is a hair below zero. Neither is a mistake; they are answering slightly different questions. Report both and describe the finding as borderline, which is what it is.

What a confidence interval actually means

Here is the sentence to memorize, because the tempting version is wrong. The parameter μ1 − μ2 is a fixed, unknown number. Your interval is what randomly varied — a different sample would have produced a different one. So the 95% describes the procedure: if you repeated this entire study endlessly, about 95% of the intervals it produced would cover the true difference. It does not say there is a 95% chance the true difference lies in the one interval you happen to be holding. That interval either covers the parameter or it does not; the coin has already landed.

The p-value needs the same care. p = 0.021 means: if the null were true, data at least this extreme would occur about 2.1% of the time. It is not the probability that the null is true, not the probability the result was a fluke, and not a measure of effect size. A trivial difference becomes "significant" with a large enough sample; a large difference stays "non-significant" with a small one. This is precisely why you report the interval alongside the p-value — the p-value tells you whether you can see the effect, and the interval tells you whether it is worth caring about.

"Zero is in the interval" is not "the groups are the same." An interval of (−0.56, 13.56) and an interval of (−0.20, 0.25) both contain zero and both fail to reject — but the first is an admission of ignorance and the second is real evidence that any difference is tiny. Only the width of the interval tells you which one you have, and the test statistic alone never will.
Interactive Build a confidence interval for a difference between two groups from live samples, watch it widen with confidence and narrow with sample size, and work out what it really means when the interval covers zero. Open full ↑
Key points
  • Every two-sample interval is (estimate) ± (critical value)(SE); only the SE and the critical value change.
  • Use t* for means (Welch df, or n−1 when paired) and z* for proportions, with the unpooled SE.
  • An interval containing 0 matches a two-sided test that fails to reject — exactly for t-procedures, approximately for proportions.
  • The 95% belongs to the long-run procedure, not to the single interval in front of you.
  • A p-value is not the probability that the null hypothesis is true.

The chapter in one breath

  • A two-sample test asks whether an observed gap between two groups is larger than chance alone would comfortably produce.
  • For independent means, variances add: SE = √(s12/n1 + s22/n2), and t = (x̄1 − x̄2)/SE on Welch degrees of freedom.
  • For paired data, collapse each pair to a difference and run a one-sample t-test on the differences with df = n − 1, where n counts pairs.
  • Pairing removes subject-to-subject variability — the same 7 ms effect gave p ≈ 0.009 paired and p ≈ 0.48 analyzed (wrongly) as independent.
  • For two proportions, use a z-statistic with the pooled proportion in the test and the unpooled SE in the interval; check success–failure.
  • The design picks the test: numeric vs. yes/no outcome, independent vs. paired groups — decided before any computing.
  • Every two-sample confidence interval is (estimate) ± (critical value)(SE), and it reports the size of the effect the test only votes on.
  • The 95% describes the long-run procedure, and a p-value is the probability of the data given the null — never the probability the null is true.

ReferenceWords worth knowing

A quick reference for the terms in this chapter — skim it now, or circle back whenever a word trips you up.

Alternative hypothesis (Ha)
The claim that there is a difference; in this chapter usually μ1 − μ2 ≠ 0 or p1 − p2 ≠ 0.
Confidence interval
A range of plausible values for a parameter, built as (estimate) ± (critical value)(standard error). Its confidence level describes the long-run success rate of the procedure.
Degrees of freedom
The parameter that sets the shape of a t-curve; n − 1 for a paired test, Welch's approximation for two independent means.
Independent samples
Two groups in which no subject appears twice and no observation is naturally matched to another.
Margin of error
The half-width of a confidence interval: the critical value times the standard error.
Matched pairs
A design in which each observation in one condition has one specific partner in the other — the same subject twice, or deliberately matched subjects.
Nonparametric test
A procedure that does not assume a normal population, typically working from ranks; e.g., Wilcoxon rank-sum and Wilcoxon signed-rank.
Null hypothesis (H0)
The claim of no difference between the two populations, against which the data are weighed.
Paired t-test
A one-sample t-test applied to the within-pair differences, testing μd = 0.
Point estimate
The single best guess at a parameter from the sample: here x̄1 − x̄2, d̄, or p̂1 − p̂2.
Pooled proportion
(x1 + x2)/(n1 + n2), the common proportion estimated under the null; used in the two-proportion test only.
Pooled two-sample t-test
The older variant that assumes equal population variances and combines them into one estimate; Welch's test is the safer default.
p-value
The probability of observing data at least as extreme as yours if the null hypothesis were true. It is not the probability that the null is true.
Sampling distribution
The distribution of a statistic across all possible samples; for a difference of means it is approximately a t-curve centered on the true difference.
Significance level (α)
The threshold, fixed in advance, at which a p-value counts as convincing; equivalently, the tolerated rate of Type I error.
Standard error
The estimated standard deviation of a statistic — how much the difference between the two samples would wobble from study to study.
Success–failure condition
The requirement of at least 10 expected successes and 10 expected failures in each group before trusting the normal approximation for proportions.
t-distribution
A bell curve with heavier tails than the normal, used when the standard deviation is estimated from data; it approaches the normal as df grows.
Test statistic
(Observed − hypothesized) divided by the standard error — the observed difference expressed in standard errors.
Two-sample t-test
The test of μ1 − μ2 = 0 from two independent samples of a numeric outcome.
Type I error
Rejecting a null hypothesis that is actually true — a false positive; its long-run rate is α.
Welch's t-test
The two-sample t-test that does not assume equal variances, using an approximate degrees-of-freedom formula; the recommended default.

Check yourself

1. A study measures cholesterol in 40 people before a diet and in the same 40 people after it. A colleague runs a two-sample t-test with n1 = n2 = 40. What is wrong, and what should be done instead?
The samples are not independent — they are the same 40 people twice, so this is a matched-pairs design. Compute the 40 within-person differences and run a paired t-test on them with df = 39. Treating paired data as independent leaves all the person-to-person variability in the standard error, inflating it and making a real effect much harder to detect.
2. Two independent samples have s1 = 6 with n1 = 9, and s2 = 8 with n2 = 16. Compute the standard error of the difference in means.
SE = 2.828. s12/n1 = 36/9 = 4; s22/n2 = 64/16 = 4; sum = 8; √8 = 2.828. Note that the variances are added, never the standard deviations — adding 6 and 8 would be a serious error.
3. A two-sided test gives p = 0.03 at α = 0.05. A classmate says, "There is a 3% chance the null hypothesis is true." Correct them precisely.
The p-value is the probability of data at least this extreme given that the null is true — not the probability that the null is true. The null is either true or false; it has no probability in this framework. The correct reading: if the two populations really were identical, results this extreme would occur about 3% of the time.
4. In the paired reaction-time example, d̄ = 7.00 ms, sd = 5.555, n = 8. Recompute t and give the degrees of freedom.
t = 3.56 with df = 7. SE = 5.555/√8 = 5.555/2.8284 = 1.964; t = 7.00/1.964 = 3.564. Degrees of freedom are n − 1 = 7, where n is the number of pairs — not 16 measurements and not df = 15.
5. Why does the two-proportion test use a pooled proportion while the confidence interval does not?
The test is computed assuming the null is true, and the null says both populations share one common proportion — so the best estimate of it uses all the data combined. A confidence interval makes no such assumption; it estimates whatever the difference actually is, so each group contributes its own p̂ to the standard error.
6. Group 1: 24 successes in 80. Group 2: 12 successes in 60. Compute the two sample proportions, the pooled proportion, and check the success–failure condition.
p̂1 = 0.300, p̂2 = 0.200, p̂pool = 36/140 = 0.2571; the condition is met. Expected counts: 80(0.2571) = 20.6 and 80(0.7429) = 59.4; 60(0.2571) = 15.4 and 60(0.7429) = 44.6. All four are at least 10, so the normal approximation is safe.
7. A 95% confidence interval for μ1 − μ2 is (2.1, 8.7). State two things you can conclude and one common statement you must avoid.
Conclude: (a) zero is not in the interval, so a two-sided test at α = 0.05 would reject the null; (b) the plausible size of the difference runs from about 2 to about 9 units, with group 1 larger. Avoid: "there is a 95% chance the true difference is between 2.1 and 8.7." The parameter is fixed; the 95% refers to the long-run performance of the procedure across repeated studies.
8. Explain why a paired design can find an effect that an independent design of the same size misses.
Pairing subtracts out subject-to-subject variability, which is noise with respect to the treatment effect. Each person serves as their own control, so a naturally high or low baseline cancels in the difference. The result is a much smaller standard error — in the chapter's example, 1.96 ms paired versus 9.60 ms unpaired, shifting p from about 0.009 to about 0.48 for the identical 7 ms effect.
9. Two independent means: x̄1 − x̄2 = 5.0, SE = 2.0, df ≈ 30, so t* = 2.042. Build the 95% confidence interval and state the test decision it implies.
(0.92, 9.08), and the two-sided test rejects H0 at α = 0.05. Margin of error = 2.042 × 2.0 = 4.084; 5.0 − 4.084 = 0.916 and 5.0 + 4.084 = 9.084. Because zero lies outside the interval, "no difference" is not a plausible value at this confidence level.
10. When would you reach for a Wilcoxon rank-sum test instead of a two-sample t-test, and when for McNemar's test?
Wilcoxon rank-sum: numeric outcome, independent groups, but small samples with clear skew or outliers so the normality condition fails. McNemar: a yes/no outcome measured on paired subjects. The two-proportion z-test assumes independent groups and would be wrong for paired yes/no data.
11. A researcher gets a two-sided p of 0.08, then switches to a one-sided test to obtain p = 0.04 and declares significance. What is the problem?
The direction of the test must be fixed before seeing the data; choosing it afterward doubles the real false-positive rate. A one-sided test is legitimate only when a difference in the opposite direction would be of no interest whatsoever, and only when that decision is pre-registered. Post hoc switching makes the reported p-value meaningless.
12. Interval A is (−0.56, 13.56); interval B is (−0.20, 0.25). Both contain zero, so both tests fail to reject. Why are these two results scientifically very different?
Interval A is wide — it is consistent with no effect but also with a large effect, so the study is simply uninformative and should be repeated with a bigger sample. Interval B is narrow and pinned near zero, which is genuine evidence that any real difference is too small to matter. "Fail to reject" is identical in both cases; only the interval reveals the difference between ignorance and precision.