## Two sample Z-test for means

In this tutorial we will discuss two sample Z test for testing the difference between means of two populations when the population standard deviations are known.

In practice two sample Z test is not used often, because in reality the population standard deviations $\sigma_1$ and $\sigma_2$ are unknown. In such a situation, the sample standard deviations are used and two sample t test (Equal variances) or two sample t-test (Unequal variances) is used.

We will explains six steps approach used in hypothesis testing to test difference between means of two populations when population standard deviations are known.

## Z-Test for Difference of 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$.

## Assumptions

Assumptions for testing two population means are as follows:

a. The two samples are independent.

b. Both the samples are simple random sample.

c. Both the samples comes from population having normal distribution.

d. The two population variances $\sigma^2_1$ and $\sigma^2_2$ are known.

## Step by Step Procedure

We wish to test the hypothesis $H_0 : \mu_1 = \mu_2$.

The standard error of difference between means is

` $$ \begin{aligned} SE(\overline{x}_1-\overline{x}_2) = \sqrt{\frac{\sigma^2_1}{n_1}+ \frac{\sigma^2_2}{n_2}}. \end{aligned} $$ `

The step by step hypothesis testing procedure is as follows:

#### Step 1 State the hypothesis testing problem

The hypothesis testing problem can be structured in any one of the three situations as follows:

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) |

#### Step 2 Define the test statistic

The test statistic for testing above hypothesis testing problem is

` $$ \begin{eqnarray*} Z & =& \frac{(\overline{x}_1-\overline{x}_2)-(\mu_1-\mu_2)}{SE(\overline{x}_1-\overline{x}_2)}\\ & = & \frac{(\overline{x}_1-\overline{x}_2)-(\mu_1-\mu_2)}{\sqrt{\frac{\sigma^2_1}{n_1}+\frac{\sigma^2_2}{n_2}}} \end{eqnarray*} $$ `

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

#### Step 3 Specify the level of significance

Specify the value of level of significance $\alpha$

#### Step 4 Determine the critical values

For the specified value of the level of significance $\alpha$, determine the critical region depending upon the alternative hypothesis.

- For
**left-tailed**alternative hypothesis: Find the $Z$-critical value using

` $$ \begin{aligned} P(Z < -Z_\alpha) &= \alpha. \end{aligned} $$ `

- For
**right-tailed**alternative hypothesis: $Z_\alpha$.

` $$ \begin{aligned} P(Z > Z_\alpha) &= \alpha. \end{aligned} $$ `

- For
**two-tailed**alternative hypothesis: $Z_{\alpha/2}$.

` $$ \begin{aligned} P(|Z| > Z_{\alpha/2}) &= \alpha. \end{aligned} $$ `

#### Step 5 Computation

Compute the test statistic under the null hypothesis $H_0$ using equation

` $$ \begin{aligned} Z_{obs} & = \frac{(\overline{x}_1-\overline{x}_2)-0}{\sqrt{\frac{\sigma^2_1}{n_1}+\frac{\sigma^2_2}{n_2}}} \end{aligned} $$ `

#### Step 6 Decision (Traditional Approach)

The traditional approach is based on the critical values.

- For
**left-tailed**alternative hypothesis: Reject $H_0$ if`$Z_{obs}\leq -Z_\alpha$`

. - For
**right-tailed**alternative hypothesis: Reject $H_0$ if`$Z_{obs}\geq Z_\alpha$`

. - For
**two-tailed**alternative hypothesis: Reject $H_0$ if`$|Z_{obs}|\geq Z_{\alpha/2}$`

.

**OR**

#### Step 6 Decision (p-value Approach)

The p-value approach is based on the $p$-value of the test.

Alternative Hypothesis | Type of Hypothesis | $p$-value |
---|---|---|

$H_a: \mu_1<\mu_2$ | Left-tailed | $p$-value `$= P(Z\leq Z_{obs})$` |

$H_a: \mu_1>\mu_2$ | Right-tailed | $p$-value `$= P(Z\geq Z_{obs})$` |

$H_a: \mu_1\neq \mu_2$ | Two-tailed | $p$-value `$= 2P(Z\geq abs(Z_{obs}))$` |

If $p$-value is less than $\alpha$, then reject the null hypothesis $H_0$ at $\alpha$ level of significance, otherwise fail to reject $H_0$ at $\alpha$ level of significance.

The above six step approach to the hypothesis testing helps you to understand how to test the hypothesis for the difference between two means when the population standard deviations are known.

## Endnote

In this tutorial, you learned the $Z$-test for testing two population means and the assumptions for $Z$-test for testing two population means. You also learned about the step by step procedure to apply $Z$-test for testing two population means.

To learn more about other hypothesis testing problems, hypothesis testing calculators and step by step procedure, please refer to the following tutorials:

Let me know in the comments if you have any questions on **$Z$-test for two population means** and your thought on this article.