Learning Objectives
By the end of this note, you will test $\mu_{1}$ versus $\mu_{2}$ with independent large samples, compute $z=(\bar{x}{1}-\bar{x}{2})/\sqrt{\sigma_{1}^{2}/n_{1}+\sigma_{2}^{2}/n_{2}}$, set hypotheses $H_{0}:\mu_{1}=\mu_{2}$, and interpret the gap with a BS 2081 two office example.
Why Compare Two Means With $z$
A province asks whether Province Hospital A and Province Hospital B differ in mean patient wait time. A ministry asks whether trained and untrained staff differ in mean output. Each question compares two population means $\mu_{1}$ and $\mu_{2}$ from independent samples. With large $n_{1}$ and $n_{2}$, the difference $\bar{X}{1}-\bar{X}{2}$ is approximately normal, so a $z$ test standardizes that difference by its standard error and judges whether an observed gap exceeds chance.
Grouped Framework: Conditions, Statistic, and Decision
Condition 1: Two independent means. You have two separate groups with no pairing. Different wards, different districts, different cohorts. If the same officers are measured before and after, use a paired $t$, not this test.
Condition 2: Large samples. Require $n_{1}\ge 30$ and $n_{2}\ge 30$. Then CLT supports normality of each $\bar{X}$ and of the difference, even when individual incomes or times skew. If either $n$ is small and $\sigma$ is unknown, use a two sample $t$.
Condition 3: Known or estimated variances. When $\sigma_{1}$ and $\sigma_{2}$ are known from long logs, use them. When unknown, substitute $s_{1}$ and $s_{2}$ at large $n$:
\[z=\frac{(\bar{x}_{1}-\bar{x}_{2})-(\mu_{1}-\mu_{2})_{0}}{\sqrt{\sigma_{1}^{2}/n_{1}+\sigma_{2}^{2}/n_{2}}}\]Under $H_{0}:\mu_{1}=\mu_{2}$, the hypothesized difference is $0$, so
\[z=\frac{\bar{x}_{1}-\bar{x}_{2}}{\sqrt{s_{1}^{2}/n_{1}+s_{2}^{2}/n_{2}}}\]written with $s$ when $\sigma$ is estimated.
Variance of the difference. Define
\[\text{SE}_{\text{diff}}=\sqrt{\frac{\sigma_{1}^{2}}{n_{1}}+\frac{\sigma_{2}^{2}}{n_{2}}}\quad\text{or}\quad\sqrt{\frac{s_{1}^{2}}{n_{1}}+\frac{s_{2}^{2}}{n_{2}}}\]Variances add because independent samples contribute separate noise. The SE grows when either group is variable or small.
Hypotheses. Let group 1 be the focus.
\(H_{0}:\mu_{1}=\mu_{2}\quad\text{or}\quad\mu_{1}-\mu_{2}=0\) \(H_{1}:\mu_{1}\neq\mu_{2}\quad\text{or}\quad\mu_{1}>\mu_{2}\quad\text{or}\quad\mu_{1}<\mu_{2}\)
Two tailed $\neq$ asks whether means differ, right tailed $>$ asks whether group 1 exceeds group 2, left tailed $<$ asks whether group 1 sits below.
Critical values and $p$ values.
| $H_{1}$ | Region | Critical at $0.05$ | ||
|---|---|---|---|---|
| $\neq$ | $ | z | >z_{\alpha/2}$ | $\pm 1.96$ |
| $>$ | $z>z_{\alpha}$ | $+1.645$ | ||
| $<$ | $z< -z_{\alpha}$ | $-1.645$ |
| At $0.01$, use $\pm 2.576$ or $\pm 2.33$ one sided. $p$ follows the same tail logic: two tailed $2P(Z> | z | )$, one tailed $P(Z>z)$ or $P(Z<z)$. Reject when $p<\alpha$. |
Confidence interval connection. A $95$ percent interval for $\mu_{1}-\mu_{2}$ is
\[(\bar{x}_{1}-\bar{x}_{2})\pm z^{*}\text{SE}_{\text{diff}}\]with $z^{*}=1.96$. When the interval excludes $0$, the two tailed test at $0.05$ rejects. Report the interval to show magnitude and direction.
Worked Example: Processing Time Across Two Palika Offices in BS 2081
Context. In Kartik 2081, Gandaki Province compares citizen charter processing time at two Palika service counters that operate under the same fee schedule. Counter A serves a dense urban ward, Counter B serves a semi rural ward. Management tests whether mean processing times differ, at $\alpha=0.05$ two sided. Random independent samples are drawn during the same fortnight to control for seasonal demand.
| Group | $n$ | $\bar{x}$ minutes | $s$ minutes |
|---|---|---|---|
| A urban | $50$ | $45$ | $12$ |
| B semi rural | $60$ | $40$ | $10$ |
The question is whether the $5$ minute observed gap reflects a real difference or sampling noise. No pairing links individual citizens across counters.
Step 1: Hypotheses.
\[H_{0}:\mu_{A}=\mu_{B}\quad\text{vs}\quad H_{1}:\mu_{A}\neq\mu_{B}\]Two tailed, difference $0$ under $H_{0}$.
Step 2: Critical value. $\alpha=0.05$ two tailed gives $\pm 1.96$.
Step 3: SE of difference.
\[\text{SE}=\sqrt{\frac{12^{2}}{50}+\frac{10^{2}}{60}}=\sqrt{\frac{144}{50}+\frac{100}{60}}=\sqrt{2.88+1.667}=\sqrt{4.547}\approx 2.13\]Step 4: $z$ statistic.
\[z=\frac{45-40}{2.13}=\frac{5}{2.13}\approx 2.35\]Step 5: $p$ value and decision.
\[p=2P(Z>2.35)=2(1-0.9906)=2(0.0094)=0.0188\]| Since $ | z | =2.35>1.96$ and $p=0.0188<0.05$, reject $H_{0}$ by either method. |
Step 6: Conclude with interval and practical gap.
95 percent CI: $5\pm 1.96(2.13)=5\pm 4.18=(0.82,9.18)$ minutes. The interval lies above $0$, so Counter A averages between $0.8$ and $9.2$ minutes longer. At NPR 800 per overtime hour and $120$ daily cases, a $5$ minute mean shift maps to about $10$ extra staff hours per day, which justifies a staffing review at Counter A rather than a fee change. If the province tested at $\alpha=0.01$ with $\pm 2.576$, the same $2.35$ would fail to reject, so the memo notes sensitivity and recommends a follow up month rather than permanent reallocation.
Direction note. Had the province asked whether urban exceeds semi rural, $H_{1}:\mu_{A}>\mu_{B}$ would be right tailed with critical $1.645$ and $p=P(Z>2.35)=0.0094$, also reject.
Self-check
Try this (calculable): In Poush 2081, a ministry compares mean daily output after a new e filing system in two districts. District 1: $n_{1}=40$, $\bar{x}{1}=85$, $s{1}=15$. District 2: $n_{2}=45$, $\bar{x}{2}=78$, $s{2}=18$. Test $H_{0}:\mu_{1}=\mu_{2}$ vs $H_{1}:\mu_{1}>\mu_{2}$ at $\alpha=0.05$.
(a) Compute $\text{SE}=\sqrt{s_{1}^{2}/n_{1}+s_{2}^{2}/n_{2}}$ and $z$. (b) State critical $z_{\alpha}$ and $p=P(Z>z)$. Decide. (c) Give 95 percent CI for $\mu_{1}-\mu_{2}$ using $z^{*}=1.96$ and interpret.
Answer: (a) $\text{SE}=\sqrt{225/40+324/45}=\sqrt{5.625+7.2}=\sqrt{12.825}\approx 3.58$, $z=(85-78)/3.58\approx 1.96$. (b) Critical $1.645$, $p=P(Z>1.96)=0.025$. Since $1.96>1.645$ and $0.025<0.05$, reject $H_{0}$, support higher mean in district 1 by about $7$ units. (c) $7\pm 1.96(3.58)=7\pm 7.02=(-0.02,14.02)$ for two sided $95$ percent, which barely covers $0$, showing one sided and two sided conclusions can differ near the boundary. A $90$ percent CI $7\pm1.645(3.58)=(1.11,12.89)$ excludes $0$.
Check: recompute at $\alpha=0.01$ with critical $2.33$ and note fail to reject, illustrating alpha choice.
Summary
| Test $\mu_{1}-\mu_{2}$ with independent large samples by standardizing the observed mean gap. Compute $\text{SE}=\sqrt{s_{1}^{2}/n_{1}+s_{2}^{2}/n_{2}}$, then $z=(\bar{x}{1}-\bar{x}{2})/\text{SE}$ under $H_{0}:\mu_{1}=\mu_{2}$, compare $ | z | $ to $z_{\alpha/2}$ or $z_{\alpha}$ or compare $p$ to $\alpha$, and summarize the gap with its confidence interval $(\bar{x}{1}-\bar{x}{2})\pm z^{*}\text{SE}$. The interval and the gap translate the decision into minutes, NPR, or output units for staffing and budget actions. |
Key Takeaways
- Confirm independence and $n_{1}\ge 30$, $n_{2}\ge 30$ before $z$. Match paired designs to paired $t$.
- Compute SE as $\sqrt{s_{1}^{2}/n_{1}+s_{2}^{2}/n_{2}}$ and then $z=(\bar{x}{1}-\bar{x}{2})/\text{SE}$.
- Set tail from $H_{1}$: $\neq$ gives $\pm z_{\alpha/2}$, $>$ gives $+z_{\alpha}$, $<$ gives $-z_{\alpha}$.
-
Reject when $ z >1.96$ two tailed at $0.05$ or when $p<\alpha$. Mirror the test with the CI: $\pm 1.96\text{SE}$ that excludes $0$ signals significance. - Report direction and size, for example urban mean $5$ minutes longer with CI $0.8$ to $9.2$ minutes, to guide operational response.
Discussion
- Two wards sample $n_{1}=25$ and $n_{2}=60$ with skewed times and compare means using $z$. Which condition fails, and what risk does this create for the $p$ value?
- An officer pools variances for this large sample $z$ test. Why is pooling unnecessary here, and when does pooling matter for a small sample $t$?
- Your $95$ percent CI for $\mu_{1}-\mu_{2}$ is $(-0.5,8.5)$ while one sided $p=0.025$ rejects. How do two sided versus one sided questions create this apparent conflict?
Exercises
- Office A $n_{1}=50$, $\bar{x}{1}=45$, $s{1}=12$; Office B $n_{2}=60$, $\bar{x}{2}=40$, $s{2}=10$. Compute SE, $z$, two sided $p$, decision at $0.05$, and 95 percent CI. State the gap in minutes.
- District A $n=100$, $\bar{x}=42000$ NPR, $s=10000$; District B $n=80$, $\bar{x}=38000$, $s=12000$. Test $H_{1}:\mu_{A}>\mu_{B}$ at $\alpha=0.01$. Give $z$, $p$, and critical $2.33$.
- Policy before $n_{1}=60$, $\bar{x}{1}=35$ min, $s{1}=8$; after $n_{2}=50$, $\bar{x}{2}=30$ min, $s{2}=7$. Test left tailed whether wait fell at $\alpha=0.05$. Compute $z$ as $(\bar{x}{2}-\bar{x}{1})/\text{SE}$ and decide.
- Explain why $\text{SE}_{\text{diff}}$ uses sum of $s^{2}/n$ terms rather than difference, and compute SE when both $s=10$ and $n=100$ to show $\sqrt{2}$ scaling.
- Construct and interpret $99$ percent CI for difference when $\bar{x}{1}-\bar{x}{2}=5$, $\text{SE}=2.13$, $z^{*}=2.576$. Compare to the $95$ percent interval $(0.82,9.18)$.


