Z Test: Formula Types and Worked Examples

#Z Test
TL;DR
A z test checks whether a sample mean or proportion differs from a claimed value, using the normal distribution. This guide covers the formula, three types, the t-test difference, and six examples.
Madhukar V·reviewed byPrabhjot KaurLast updated on November 27, 20269 min read

Key Points

  • A z-test compares a sample statistic with a hypothesised value by measuring the gap in standard errors.
  • The one-sample z-test statistic is z = (x̄ − μ₀) ÷ (σ/√n), and it follows a standard normal distribution when H₀ is true.
  • It is used when the population standard deviation is known, or when the sample is large enough for the central limit theorem to apply.
  • Variants test two means against each other and a sample proportion against a claimed proportion.
  • When σ is unknown and the sample is small, a t-test is used instead.

Is a 5 g Gap Worth Worrying About?

A bag of rice should weigh 1,000 g, and a sample of 36 bags averages 1,005 g instead.

The z-test decides whether that 5 g is a real difference or ordinary sampling variation. It converts the gap into a number of standard errors and asks how unusual that would be if the bags were really filled correctly.

a z test result in the rejection region.
Standard normal curve with both tails beyond plus and minus 1.96 shaded as the 5 percent rejection region and a dashed line at the observed z of 2.5, which lies inside the right-hand rejection region.

What Is a Z Test?

A z-test is a hypothesis test whose test statistic follows the standard normal distribution when the null hypothesis is true. For a single mean:

z=xˉ−μ0σ/nz = \frac{\bar{x} - \mu_0}{\sigma / \sqrt{n}}

The numerator is the gap between the sample mean and the claimed mean. The denominator is the standard error, the typical size of that gap from chance alone. So zz counts how many standard errors apart the two are.

Try It Yourself

Use the hypothesis test explorer to see Z Test at work: drag, change the numbers and watch what happens.

What Are the Types of Z Test?

Three are common.

types of z test.
Table of three common z tests: the one-sample mean test with z equal to x-bar minus mu-zero over sigma over root n, used when sigma is known or n is large; the two-sample means test with the difference of means over the square root of the summed variances over sample sizes; and the one-proportion test with p-hat minus p-zero over the square root of p-zero times one minus p-zero over n, used when n p-zero and n times one minus p-zero are both at least 10.

Each has the same shape: an observed difference divided by its standard error.

How Do You Carry Out a Z Test?

Five steps.

steps of a z test.
Five numbered steps for a one-sample z-test: state H0 and H1, check that sigma is known or n is large, compute z, compare z with the critical value or find the p-value, and reject or fail to reject H0 with a conclusion.

At the 5 percent level, a two-tailed test rejects H0H_0 when ∣z∣>1.96|z| > 1.96. The critical value changes with the significance level and the number of tails.

How Is a Z Test Different From a T-Test?

The difference is what is known about the spread.

z test compared with t-test.
Table comparing the z-test and t-test: the z-test uses a known population standard deviation, usually large samples, the standard normal distribution and a 5 percent two-tailed critical value of 1.96; the t-test estimates the standard deviation by s, works with any sample size, uses the t distribution with n minus 1 degrees of freedom, and has larger critical values such as 2.262 for 9 degrees of freedom.

When σ\sigma must be estimated from a small sample, the extra uncertainty widens the distribution, and the t-test accounts for it. For large samples the two give nearly the same answer.

Examples of the Z Test

Example 1

Rice bags should average 1,000 g, with σ=12\sigma = 12 g. A sample of 36 averages 1,005 g. Test at α=0.05\alpha = 0.05, two-tailed.

Standard error 1236=2\frac{12}{\sqrt{36}} = 2, so

z=1005−10002=2.5z = \frac{1005 - 1000}{2} = 2.5

Since 2.5>1.962.5 > 1.96, reject H0H_0. The two-tailed p-value is about 0.012.

Example 2

A student computes Example 1 as z=1005−100012≈0.42z = \frac{1005 - 1000}{12} \approx 0.42 and fails to reject. What went wrong?

Dividing by the standard deviation looks natural, because 12 g is the spread given in the question.

That is the spread of individual bags. The question is about the mean of 36 bags, which varies far less: its standard error is 1236=2\frac{12}{\sqrt{36}} = 2. Dividing by 12 makes the gap look six times smaller than it is and reverses the decision.

Example 3

A school claims 60 percent of students prefer online homework. In a sample of 200, 130 do. Test H0:p=0.6H_0: p = 0.6, two-tailed.

p^=0.65\hat{p} = 0.65, standard error 0.6×0.4200≈0.0346\sqrt{\frac{0.6 \times 0.4}{200}} \approx 0.0346, so z=0.050.0346≈1.44z = \frac{0.05}{0.0346} \approx 1.44. Since 1.44<1.961.44 < 1.96, fail to reject H0H_0 (p≈0.15p \approx 0.15).

Example 4

Two classes of 50 have mean scores 72 and 68, with σ=10\sigma = 10 in each. Is the difference significant at 5 percent?

Standard error 10050+10050=2\sqrt{\frac{100}{50} + \frac{100}{50}} = 2, so z=72−682=2z = \frac{72 - 68}{2} = 2. Since 2>1.962 > 1.96, reject H0H_0, just (p≈0.046p \approx 0.046).

Example 5

In Example 1, would a right-tailed test at 1 percent reject H0H_0?

The critical value is 2.326. Since 2.5>2.3262.5 > 2.326, yes.

Example 6

A sample of 15 has an unknown population standard deviation. Should a z-test be used?

No. With a small sample and σ\sigma estimated from the data, use a t-test.

Why the Z Test Matters

It is the clearest example of how a test statistic works.

  • It measures gaps in standard errors. That idea carries over to t, F and chi-square tests.
  • It suits large samples. By the central limit theorem, means of large samples are close to normal.
  • It tests proportions. Survey and poll results are checked against claims with the proportion z-test.
  • It links to intervals. A two-tailed 5 percent z-test rejects exactly when the claimed value lies outside the 95 percent interval.

OpenStax's Hypothesis Testing of a Single Mean and Single Proportion section works through z-tests for means with known σ\sigma and for proportions in the same way.

What Most Guides Get Wrong About the Z Test

Two points are often missed.

The first is the standard error. Many explanations present the formula without stressing why σ\sigma is divided by n\sqrt{n}. Example 2 shows what happens without it: the test loses most of its power and gives the wrong decision.

The second is the condition for using it. Guides sometimes say "use a z-test for large samples" and leave it there. The real condition is that the sampling distribution is close to normal and the standard error is known or well estimated. For proportions, that means both np0np_0 and n(1−p0)n(1 - p_0) should be at least 10.

Where Students Trip Up on the Z Test

Mistake 1: Dividing by σ instead of σ/√n

Where it slips in: The test statistic, as in Example 2.

Don't do this: Using the population standard deviation as the denominator.

The correct way: Use the standard error, σ/n\sigma/\sqrt{n}.

Students divide by σ\sigma because it is the only standard deviation in the question, and the step from individuals to means is not written anywhere.

Mistake 2: Using a z-test for small samples with unknown σ

Where it slips in: Example 6 and similar.

Don't do this: Applying 1.96 when the sample is small and σ\sigma is estimated.

The correct way: Use a t-test.

Mistake 3: Using p^\hat{p} in the proportion standard error

Where it slips in: Proportion tests, as in Example 3.

Don't do this: Computing p^(1−p^)/n\sqrt{\hat{p}(1 - \hat{p})/n} for the test.

The correct way: Use the hypothesised p0p_0, because the test assumes H0H_0 is true.

Quality inspectors run z-tests routinely. A packaging line with a known process standard deviation is sampled every hour, and a mean that drifts more than about two standard errors from the target triggers an adjustment before customers ever receive underfilled packs.

Bottom Line

  • A z test measures the gap between a sample result and a claimed value in standard errors.
  • The one-sample statistic is (xˉ−μ0)÷(σ/n)(\bar{x} - \mu_0) \div (\sigma/\sqrt{n}).
  • Variants test two means and single proportions.
  • Small samples with unknown σ\sigma need a t-test instead.
  • To work through statistics with a teacher, explore Bhanzu's high school math tutor sessions or math classes online.

A Practical Next Step

Ask 40 people whether they prefer tea or coffee and test whether the proportion preferring tea differs from 50 percent. Compute the standard error with p0=0.5p_0 = 0.5, find zz, and decide at the 5 percent level.

Practice these to solidify your understanding. If σ still sits in the denominator on its own, return to Example 2. Want a live Bhanzu trainer to walk through more statistics problems? Book a free demo class, online globally, or in person at our McKinney, TX center.

Read More

Research Behind This Article

  1. OpenStax, Introductory Statistics 2e, 10.2 Two Population Means with Known Standard Deviations (2023). openstax.org
  2. OpenStax, Introductory Statistics 2e, 8.1 A Single Population Mean Using the Normal Distribution (2023). openstax.org
  3. NIST/SEMATECH, e-Handbook of Statistical Methods, 7.1.3 What are statistical tests? (2022). itl.nist.gov
  4. NIST/SEMATECH, e-Handbook of Statistical Methods, 1.3.6.7.1 Cumulative Distribution Function of the Standard Normal Distribution (2022). itl.nist.gov
  5. NIST/SEMATECH, e-Handbook of Statistical Methods, 7.2.2.2 Sample sizes required (2022). itl.nist.gov

Quick Quiz: Check Yourself

Three levels, fresh numbers every time, instant feedback with the working.

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

What is a z test?
A hypothesis test whose test statistic follows the standard normal distribution under the null hypothesis, used to compare a sample mean or proportion with a claimed value.
What is the formula for a z test?
For one mean, z=(xˉ−μ0)÷(σ/n)z = (\bar{x} - \mu_0) \div (\sigma/\sqrt{n}).
When should you use a z-test instead of a t-test?
When the population standard deviation is known, or the sample is large enough for the standard error to be well estimated.
What is a z-test for proportions?
A test of whether a sample proportion differs from a claimed proportion, using z=(p^−p0)÷p0(1−p0)/nz = (\hat{p} - p_0) \div \sqrt{p_0(1 - p_0)/n}.
What does the z value mean?
How many standard errors the sample result lies from the value claimed by the null hypothesis.
✍️ Written By
Madhukar V
Madhukar V
Math Columnist & Analyst
I see mathematics as more than just numbers and formulas—it is a way of thinking, questioning, and understanding the world around us. I work at the intersection of mathematics, EdTech, technology, and AI-powered learning, I enjoy exploring how mathematical ideas can be made simple, meaningful, and relatable. Through my articles, I aim to present mathematics with curiosity and a practical perspective, helping readers see the beauty and relevance behind every concept in a Bhanzu way.
LinkedIn
🔬 Reviewed By
Prabhjot Kaur
Subject Matter Expert & Curriculum Developer
Book a FREE Demo ClassBook Now →