Exam Pattern: Two-Sample Z-Test Power and Sample Size
This note consolidates the normal midterm derivation question and the matching makeup question where the same formula is reused for direct power computation.
Source Questions
STA305 Midterm W2026, Question 3STA305 Makeup W2026, Question 3(b)STA305 Makeup W2026, Question 3(c)
Setup
Assume two independent normal groups with means $\mu_1, \mu_2$ and common variance $\sigma^2$. Let
$$ \theta = \mu_1 - \mu_2. $$For the one-sided test
$$ H_0: \theta = 0 \quad \text{versus} \quad H_1: \theta > 0, $$the usual $z$-statistic is
$$ Z = \frac{\bar{Y}_1 - \bar{Y}_2}{\sigma \sqrt{1/n_1 + 1/n_2}}. $$Reject $H_0$ when
$$ Z > z_{\alpha}. $$Power Formula
Under the alternative $\theta > 0$,
$$ Z \sim \mathcal{N}\left( \frac{\theta}{\sigma \sqrt{1/n_1 + 1/n_2}}, 1 \right). $$Therefore,
$$ 1-\beta
1 - \Phi\left( z_{\alpha}
\frac{\theta}{\sigma \sqrt{1/n_1 + 1/n_2}} \right). $$
Equal Allocation Sample Size
If $n_1 = n_2 = n/2$, then
$$ 1/n_1 + 1/n_2 = \frac{4}{n}, $$so the power becomes
$$ 1-\beta
1 - \Phi\left( z_{\alpha} - \frac{\theta \sqrt{n}}{2\sigma} \right). $$
Solving for the total sample size gives
$$ n = \frac{4 \sigma^2 (z_{\alpha} + z_{\beta})^2}{\theta^2}. $$Direct Power Computation
If $n_1$ and $n_2$ are given, plug them directly into
$$ 1-\beta
1 - \Phi\left( z_{\alpha}
\frac{\theta}{\sigma \sqrt{1/n_1 + 1/n_2}} \right). $$
That is the key move in the makeup version where each arm size is specified.
R Template
alpha <- 0.05
theta <- 1
sigma <- 3
n1 <- 80
n2 <- 80
1 - pnorm(qnorm(1 - alpha) - theta / (sigma * sqrt(1 / n1 + 1 / n2)))
Exam Checklist
- Write the rejection rule using $z_{\alpha}$
- Standardize under the alternative, not only under $H_0$
- Keep the common variance factor $\sigma$ in the denominator
- For equal allocation, replace $n_1 = n_2 = n/2$
- Distinguish direct power calculation from solving for $n$