1-sample Z test: formula, example and when to use it

Updated

The 1-sample Z test checks whether the mean of a process differs from a target value when the process standard deviation σ is already known. It compares the sample mean with the target in units of the standard error σ/√n and reads the p-value from the standard normal distribution. If σ is not known and must be estimated from the same sample, use the 1-sample t-test instead.

When to use it

  • A process has a long, stable history (for example a year on an I-MR chart), so its standard deviation is well established, and you want to know whether a change moved the mean.
  • You are checking a new lot or setup against a nominal value with a known measurement and process spread.
  • You are learning hypothesis tests: the Z test is the simplest case, and the t-test builds on it.

In practice σ is rarely known exactly. Use the Z test only when the known σ comes from much more data than the sample you are testing and the process has stayed stable since.

How it works

Hypotheses, with μ the process mean and μ₀ the target:

  • H₀: μ = μ₀ (the mean is on target).
  • H₁: μ ≠ μ₀ (two-sided), or μ > μ₀, or μ < μ₀ (one-sided, chosen before you see the data).

The test statistic:

Z = (x̄ − μ₀) / (σ / √n)

Under H₀, Z follows the standard normal distribution. For a two-sided test, the p-value is 2 × (1 − Φ(|Z|)), where Φ is the standard normal CDF. For H₁: μ > μ₀ it is 1 − Φ(Z).

The 95% confidence interval for the mean is:

x̄ ± z(0.975) · σ / √n, with z(0.975) = 1.960

Assumptions: the observations are independent, σ is known, and either the data are roughly normal or n is large enough for the sample mean to be close to normal.

Example

A CNC lathe turns shafts with an outer diameter of 12.000 ± 0.030 mm. A year of individuals charts shows a stable process with σ = 0.008 mm. After a tool change, the operator measures 16 consecutive shafts:

Diameter (mm)
12.00912.00912.00012.004
12.00512.00512.02212.002
12.00212.00112.01312.001
12.00412.01212.01111.997
Shaft diameter after the tool change12.0012.0112.02Diameter (mm)CL=1213579111315Shaft
Shaft diameter after the tool change

The engineer tests H₀: μ = 12.000 against the two-sided H₁: μ ≠ 12.000 at α = 0.05.

  • Sample mean: x̄ = 12.00606 mm.
  • Standard error: σ/√n = 0.008/√16 = 0.002 mm.
  • Z = (12.00606 − 12.000)/0.002 = 3.03.
  • p-value = 2 × (1 − Φ(3.03)) = 0.0024.
  • 95% CI: 12.00606 ± 1.960 × 0.002 = 12.0021 to 12.0100 mm.
NMeanσ (known)SE MeanZp-value95% CI
1612.006060.0080.0023.030.0024(12.0021, 12.0100)

How to read the results

  • The p-value of 0.0024 is far below 0.05. If the mean were still at 12.000 mm, a sample mean this far away would happen only about 1 time in 400. The engineer concludes the tool change moved the mean.
  • The interval says the new mean is somewhere between about 12.002 and 12.010 mm. It does not contain 12.000, which agrees with the test.
  • Translate it into engineering terms. With σ = 0.008 mm, the shift costs capability. Centered, Cpk would be 0.030/(3 × 0.008) = 1.25. With the mean at 12.006, Cpk = (12.030 − 12.006)/(3 × 0.008) = 1.00. An offset adjustment of about −0.006 mm on the lathe brings the process back to center.
  • Check the known σ. The sample standard deviation here is 0.0063 mm, consistent with 0.008 mm. If the sample spread were much larger than the known σ, the Z test would overstate the evidence, and the t-test would be the safer choice.

Common mistakes

  • Using the sample standard deviation as "known" σ. That turns the test into a t-test with the wrong distribution, and the p-value comes out too small for small samples.
  • Using a σ from before a process change. If the tool change also changed the spread, the old σ no longer applies.
  • Testing on non-independent data. Consecutive parts from a drifting process are correlated. The test treats them as independent and overstates the evidence.
  • Confusing significant with important. With large samples, the test flags shifts of a micron. Always compare the interval with the tolerance.

Frequently asked questions

What is the difference between a Z test and a t-test?

The Z test uses a known σ and the normal distribution. The t-test estimates σ from the sample and uses the t distribution, which has heavier tails to account for that extra uncertainty. As n grows, the two give nearly the same answer.

When is σ really "known"?

When it comes from a large amount of earlier data, collected while the process was stable, under the same conditions as the sample you are testing. A control chart with many subgroups in control is a typical source.

Should I use a one-sided or two-sided test?

Two-sided, unless only one direction matters and you decided that before collecting data, such as testing whether a fill weight has dropped below the label. Choosing one-sided after seeing the data halves the p-value without justification.

How many parts do I need?

It depends on the smallest shift you need to detect and the risk you accept. See sample size for the 1-sample Z.

Try it with your own data

StatLab SPC is free, open-source statistics for engineers. It runs in your browser, works offline, and never uploads your data.

Open StatLab