## Two sample Z test for means

Let $\overline{x}_1$ be the mean of a random sample of size $n_1$ from a population with mean $\mu_1$ and variance $\sigma^2_1$ and $\overline{x}_2$ be the mean of a random sample of size $n_2$ from a population with mean $\mu_2$ and variance $\sigma^2_2$.

The hypothesis testing problem can be setup as one of the three situations:

Situation Hypothesis Testing Problem
Situation A : $H_0: \mu_1=\mu_2$ against $H_a : \mu_1 < \mu_2$ (Left-tailed)
Situation B : $H_0: \mu_1=\mu_2$ against $H_a : \mu_1 > \mu_2$ (Right-tailed)
Situation C : $H_0: \mu_1=\mu_2$ against $H_a : \mu_1 \neq \mu_2$ (Two-tailed)

## Formula

The test statistic under $H_0 : \mu_1 = \mu_2$ is

### $Z = \frac{(\overline{x}_1-\overline{x}_2)-(\mu_1-\mu_2)}{SE(\overline{x}_1-\overline{x}_2)}$

where,

• $\overline{x}_1$ is the sample mean of first sample of size $n_1$,

• $\overline{x}_2$ is the sample mean of second sample of size $n_2$,

• $SE(\overline{x}_1-\overline{x}_2) = \sqrt{\frac{\sigma^2_1}{n_1}+ \frac{\sigma^2_2}{n_2}}$`,

The test statistic $Z$ follows standard normal distribution $N(0,1)$.