Home » Two Sample Z-Test: Definition, Formula, and Example

Two Sample Z-Test: Definition, Formula, and Example

by Erma Khan

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:

  • H0μ1 = μ2 (the two population means are equal)
  • HAμ1 ≠ μ2 (the two population means are not equal)

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

z = (x1x2) / √σ12/n1 + σ22/n2)

where:

  • x1, x2: sample means
  • σ1, σ2: population standard deviations
  • n1, n2: sample sizes

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:

  •  x1 (sample 1 mean IQ) = 100.65
  • n1 (sample 1 size) = 20
  • x2 (sample 2 mean IQ) = 108.8
  • n2 (sample 2 size) = 20

Step 2: Define the hypotheses.

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

  • H0μ1 = μ2 (the two population means are equal)
  • HAμ1 ≠ μ2 (the two population means are not equal)

Step 3: Calculate the z test statistic.

The z test statistic is calculated as:

  • z = (x1x2) / √σ12/n1 + σ22/n2)
  • z = (100.65-108.8) / √152/20 + 152/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

Related Posts