*39*

AÂ **two sample z-test** is used to test whether two population means are equal.

This test assumes that the standard deviation of each population is known.

This tutorial explains the following:

- The formula to perform a two sample z-test.
- The assumptions of a two sample z-test.
- An example of how to perform a two sample z-test.

Letâ€™s jump in!

**Two Sample Z-Test: Formula**

A two sample z-test uses the following null and alternative hypotheses:

**H**Î¼_{0}:Â_{1}= Î¼_{2}(the two population means are equal)**H**Î¼_{A}:Â_{1}â‰ Î¼_{2}(the two population means are not equal)

We use the following formula to calculate the z test statistic:

**z = (****x _{1}â€“ x_{2}) / âˆšÏƒ_{1}^{2}/n_{1} + Ïƒ_{2}^{2}/n_{2})**

where:

**x**sample means_{1}, x_{2}:**Ïƒ**population standard deviations_{1}, Ïƒ_{2}:**n**sample sizes_{1}, n_{2}:

If the p-value that corresponds to the z test statistic is less than your chosen significance level (common choices are 0.10, 0.05, and 0.01) then you can reject the null hypothesis.

**Two Sample Z-Test: Assumptions**

For the results of a two sample z-test to be valid, the following assumptions should be met:

- The data from each population are continuous (not discrete).
- Each sample is a simple random sample from the population of interest.
- The data in each population is approximately normally distributed.
- The population standard deviations are known.

**Two Sample Z-Test****: Example**

Suppose the IQ levels among individuals in two different cities are known to be normally distributed each with population standard deviations of 15.

A scientist wants to know if the mean IQ level between individuals in city A and city B are different, so she selects a simple random sample ofÂ 20 individuals from each city and records their IQ levels.

To test this, she will perform a two sample z-test at significance level Î± = 0.05 using the following steps:

**Step 1: Gather the sample data.**

Suppose she collects two simple random samples with the following information:

- Â
**x**_{1}Â (sample 1 mean IQ) = 100.65 **n**(sample 1 size) = 20_{1}**x**_{2}(sample 2 mean IQ) = 108.8**n**(sample 2 size) = 20_{2}

**Step 2: Define the hypotheses.**

She will perform the two sample z-test with the following hypotheses:

**H**Î¼_{0}:Â_{1}= Î¼_{2}(the two population means are equal)**H**Î¼_{A}:Â_{1}â‰ Î¼_{2}(the two population means are not equal)

**Step 3: Calculate the z test statistic.**

The z test statistic is calculated as:

- z = (x
_{1}â€“ x_{2}) / âˆšÏƒ_{1}^{2}/n_{1}+ Ïƒ_{2}^{2}/n_{2}) - z = (100.65-108.8) / âˆš15
^{2}/20 + 15^{2}/20) - z = -1.718

**Step 4: Calculate the p-value of the z test statistic.**

According to the Z Score to P Value Calculator, the two-tailed p-value associated with z = -1.718 is **0.0858**.

**Step 5: Draw a conclusion.**

Since the p-value (0.0858) is not less than the significance level (.05), the scientist will fail to reject the null hypothesis.

There is not sufficient evidence to say that the mean IQ level is different between the two populations.

**Note:Â **You can also perform this entire two sample z-test by using the Two Sample Z-Test Calculator.

**Additional Resources**

The following tutorials explain how to perform a two sample z-test using different statistical software:

How to Perform Z-Tests in Excel

How to Perform Z-Tests in R

How to Perform Z-Tests in Python