Summarize this article:
1591 LearnersLast updated on November 20, 2025

Most of us have wondered how mathematicians compare different datasets. Well, they use different methods and the z-test is one such method. The z-test can be used to assess the hypotheses concerning population proportions or averages. The z-test is usually applied to one sample, two samples, or proportions. It also has many real-life applications. For example, it can be used to compare the average weight of students belonging to one school to the weight of students from another school. This is done to check if there is any major variation between them. Let’s learn more about these tests.
Key Takeaways from Z-Tests
Z tests are utilized in comparing one sample to another or with a population in various sectors. Let’s look at a few key takeaways:
Z-tests come in various types. We will now explore each of them:
One-sample z-test: We use the one-sample test when a single sample differs extensively from a known population mean. To use this test, the population standard deviation should be known, and the sample size must be more than 30.
Two-sample z-test: This test compares the means of two independent samples.
Let μ1 and μ2 be the population means; X1 and X2 are sample mean.
The null hypothesis of the test could be:
H0: μ1 – μ2 = 0
H1: μ1 – μ2 ≠ 0
We calculate the z-test score using the formula:
\(Z = \frac{(\bar{X}_1 - \bar{X}_2) - (\mu_1 - \mu_2)} {\sqrt{\frac{\sigma_1^2}{n_1} + \frac{\sigma_2^2}{n_2}}}\)
Here:
X = sample mean
σ1 and σ2 = standard deviation
n1 and n2 = population sample sizes for p1 and p2
Z Test Formula
The z-test formula compares the z-statistic with the z-critical value to determine if there is a difference between the means of two populations. In hypothesis testing, the z-critical value separates the distribution into acceptance and rejection regions. If the test statistic falls in the rejection region, the null hypothesis is rejected; otherwise, it is not rejected.
The formulas used to set up hypothesis tests for both one-sample and two-sample z tests are given as:
One-Sample Z Test
A one-sample z test is used to determine whether the sample mean differs significantly from the population mean when the population standard deviation is known.
The formula for calculating the z-test statistic is:
\(z = \frac{\overline{x} - \mu}{\frac{\sigma}{\sqrt{n}}}\)
Where x is the sample mean, μ is the population mean, σ is the population standard deviation, and n is the sample size.
The algorithm to set a one-sample z test based on the z test statistic can be given as:
Left-Tailed Test:
Null Hypothesis: \(H_0 : μ =μ_0\)
Alternate Hypothesis: \(H_1:μ<μ_0\)
The decision criterion is to reject the null hypothesis if the z statistic is less than the z critical value.
Right-Tailed Test:
Null Hypothesis: \(H_0: μ = μ_0\)
Alternate Hypothesis: \(H_1: μ > μ_0\)
The decision criterion is to reject the null hypothesis if the z statistic is greater than the z critical value.
Two-Tailed Test:
Null Hypothesis: H0 : μ = μ0
Alternate Hypothesis: \(H_1 : μ ≠ μ_0\)
The decision criterion is to reject the null hypothesis if the z statistic is greater than the z critical value.
Two-Sample Z Test
A two-sample z test is a statistical method used to determine whether there is a significant difference between the means of two independent samples. It checks whether the averages of two groups differ, assuming the population variances are known and the samples are drawn from normally distributed populations.
The z test statistic formula is expressed as:
\(z = \frac{\left( \bar{x}_1 - \bar{x}_2 \right) - \left( \mu_1 - \mu_2 \right)} {\sqrt{\frac{\sigma_1^2}{n_1} + \frac{\sigma_2^2}{n_2}}} \)
Where \(\bar{x}_1, μ_1, \sigma_1^2\) are the sample mean, population mean and population variance respectively for the first sample. Similarly, \(\bar{x}_2, μ_2, \sigma_2^2\) are the sample mean, population mean, and population variance of the second sample.
The two-sample z test is similar to the one-sample test but is used to compare the means of two different samples. For instance, the null hypothesis can be stated as, \(H_0: μ_1 = μ_2\), meaning the means of the two populations are equal.


Z tests can be used in comparing proportions between a sample and a population, or two samples. For example: Determining whether the proportion of girls in a school differs significantly from the percentage worldwide.
Z Test Proportions:
Z tests can be used to compare proportions between a sample and a population, or between two samples. For example, determining whether the proportion of girls in a school differs significantly from the percentage worldwide.
One Proportion Z Test:
A one-proportion z test is applied when comparing an observed proportion with a theoretical proportion across two groups.
The z test statistic for this test is calculated using the following formula:
\(z = \frac{p - p_0}{\sqrt{\frac{p_0(1 - p_0)}{n}}} \)
where,
p is the observed proportion,
\(P_0\) is the theoretical (or hypothesized) proportion, and
N is the sample size.
The null hypothesis states that the two proportions are equal, while the alternative hypothesis states that they differ.
Two Proportion Z Test:
A two-proportion z-test compares two proportions to determine whether they differ significantly.
The formula for the z test statistic is:
\(z = \frac{p_1 - p_2 - 0}{\sqrt{p(1 - p)\left( \frac{1}{n_1} + \frac{1}{n_2} \right)}} \)
Where, \(p = \frac{x_1 + x_2}{n_1 + n_2} \)
Where \(P_1\) and \(P_2\) are the sample proportions for the two groups, \(n_1\) and \(n_2\) are the sample sizes, and P is the pooled proportion calculated from both groups combined.
How to Calculate Z Test Statistic?
Interpreting the problem correctly is the most crucial step in calculating the z-test statistic. It is essential to identify the appropriate tailed test and determine which category the z statistic falls into before proceeding.
The steps to calculate the z-test statistic are given as;
Step 1: Identify the type of test. For example, if comparing the means of two populations in one direction, a right-tailed two-sample z test is used.
Step 2: Set up the hypotheses:
\(H_0: \mu_1 = \mu_2, H_1: \mu_1 > \mu_2.\)
Step 3: Using the z table, find the critical value for the given alpha level, e.g., 1.645.
Step 4: Calculate the z-test statistic with the formula:
\(z = \frac{ \left( \bar{x}_1 - \bar{x}_2 \right) - \left( \mu_1 - \mu_2 \right) }{ \sqrt{ \frac{\sigma_1^2}{n_1} + \frac{\sigma_2^2}{n_2} } } \)
Substitute the values:
\(X_1 =22.1\), \(\sigma _1 =4.8\), \(n_1 =60\), \(X_2 = 18.8\), \(\sigma _2 =8.1\), \(n_2 =40\) and \(\mu_1-\mu_2 = 0.\) thus, \(z = 2.32.\)
The calculated z statistic is 2.32.
Step 5: Compare the calculated z statistic with the critical value. Since 2.32 > 1.645, reject the null hypothesis.
Step 6: Conclude that there is sufficient evidence to support the claim that the students' scores in the first class are higher.
The comparison between z-test and t-test is given as;
| Z Test | T Test |
| A z-test is a statistical method used to determine if the means of two data sets differ significantly when the population variance is known. | A T-Test is used to determine if there is a difference between the means of two data sets when the population variance is unknown. |
| The sample size of a z-test is greater than or equal to 30. | The sample size is less than 30. |
| The data also follows a normal distribution. | The data follows a Student’s t-distribution. |
| The one-sample z-test statistic is given by \(z = \frac{\bar{x} - \mu}{\sigma / \sqrt{n}} \) | The t-test statistic is given as \(t = \frac{\bar{x} - \mu}{s / \sqrt{n}} \) where s stands for the sample standard deviation. |
Learning about the Z-test helps students compare datasets in real-world situations. The tips and tricks mentioned below will help us understand the concept easily:
Z tests are used in various fields in comparing averages. Let’s explore a few of them:
We now know the importance of perfectly executed Z-tests. However, students can make some errors in calculations, which can lead to incorrect results. We will now look at a few common mistakes to watch out for and the ways to avoid them:
A researcher wants to compare the average scores of two groups of students. Group A (20 students) has an average test score of 60 with a standard deviation of 5, while Group B (25 students) has an average score of 65 with a standard deviation of 10. Test at a 1.5 significance level if there is a significant difference in the means.
We have insufficient evidence at the 1.5% level of significance to determine the variation of the scores.
In the problem, we have that:
Group A:
n1 = 20
X1 = 60
S1 = 5
Group B is given as:
n2 = 25
X2 = 65
S2 = 10
The significance level is given as 1.5 %: \(𝛂 = 0.015\)
Now, state the hypothesis:
H0: μ1 = μ2
H1: μ1 ≠ μ2
Using the formula:
\(Z = \frac{(X1 − X2)} {\sqrt{σ n_1^2 + σ n_2^2 }}\)
\(Z = \frac{60-65}{\sqrt{\frac{5^2}{20} + \frac{10^2}{25}}}\)
\(= \frac{-5}{\sqrt{\frac{25}{20} + \frac{100}{25}}}\)
\(= \frac{-5}{\sqrt{1.25 + 4}}\)
\(= \frac{-5}{\sqrt{5.25}}\)
\(= \frac{-5}{2.291287847\ldots}\)
\(Z \approx -2.182178902 \approx -2.18 \quad(\text{rounded to 2 d.p.})\)
We calculate the critical z-value for 𝛂 = 0.015 as ±2.42.
Since −2.18 > −2.42, we could not reject the null hypothesis at the 1.5% significance level. The evidence is insufficient to conclude a significant difference in test scores.
A fruit seller says that the apples in his shop weigh 200 grams on average. You and your friends pick 35 apples and find that their average weight is 150 grams. You also know that apples usually have a weight variation of 15 grams. Should we believe the fruit seller’s claim?
The possibility of getting a sample with an average weight of 150 grams if the true mean was 200 grams is exceedingly low. This shows the fruit seller’s assertion was low.
Given that,
Claimed average weight = 200 grams
Sample average weight = 150 grams
Standard deviation = 15 grams
Sample size = 35 apples
Here, we use the z-test formula:
\(Z = \frac{\bar{x} - \mu}{\sigma / \sqrt{n}}\)
\(Z = \frac{150 - 200}{15 / \sqrt{35}}\)
= −50 / (15 / 5.92)
\(= \frac{-50}{2.53}\) = −19.76
Z = −19.76
Since Z is below any significance threshold, we should reject the null hypothesis and conclude that the fruit seller’s claim is likely false.
A company says their new running shoes help people run 5 minutes faster than usual. Your school tests these shoes on 35 students and finds that, on average, students run 5.5 minutes faster with a variation of 4.5 minutes. Can we believe the company?
As the value does not cross the critical value, we cannot reject the null hypothesis. Therefore, we cannot deny the company’s claim.
We have that:
n = 35
Claimed change = 5 minutes
Sample average change = 5.5 minutes
Standard deviation = 4.5 minutes
Step 1 is to formulate the hypotheses:
Null hypothesis: The company’s claim is true.
H0: μ = 5
Alternative hypothesis: The true mean could be different from 5 minutes.
H𝛼: μ ≠ 5
Using Z-test:
\(Z = \frac{\bar{x} - \mu}{\sigma / \sqrt{n}}\)
\(Z = \frac{5.5 - 5}{\frac{4.5}{\sqrt{35}}}\)
\(= \frac{0.5}{\frac{4.5}{5.916}}\)
\(= \frac{0.5}{0.76}\)
= 0.66
To find the critical value:
For a two-tailed Z-test with a significance threshold of 0.05, the crucial value is ± 1.96.
Now, we make the decision; the calculated value is \(0.66 < 1.96\)
As the value does not cross the critical value, we cannot reject the null hypothesis. Therefore, we cannot deny the company’s claim.
Jaipreet Kour Wazir is a data wizard with over 5 years of expertise in simplifying complex data concepts. From crunching numbers to crafting insightful visualizations, she turns raw data into compelling stories. Her journey from analytics to education ref
: She compares datasets to puzzle games—the more you play with them, the clearer the picture becomes!






