ThisCalculator

Statistics

Calculating a Z Test Statistic: Formula and Examples

Updated · Standard formula, shown below

Z test statistic 2.0000
Standard error
1.0000
Result
Sample mean
52
You entered
Hypothesized mean
50
You entered

Calculating a Z Test Statistic: Formula and Examples

A z test statistic measures how far a sample result is from a hypothesized population value, in standard-error units. Enter the sample mean, hypothesized mean, population standard deviation, and sample size to calculate the one-sample z statistic; the result is signed, so its direction matters.

Formula

For a one-sample test of a population mean when the population standard deviation is known, calculate the statistic as:

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

  • z is the z test statistic, a dimensionless number.
  • x̄ is the sample mean, in the same units as the measured data.
  • μ₀ is the hypothesized population mean under the null hypothesis, in those same units.
  • σ is the population standard deviation, in the data’s units.
  • n is the number of independent observations, a count.
  • σ / √n is the standard error of the sample mean, in the data’s units.

The calculator accepts any consistent measurement unit because the units cancel in the division. Its sample size must be a positive whole number; the default is 64. The formula assumes the population standard deviation is known and the sampling distribution of the mean is normal or adequately approximated by a normal distribution.

Worked Example

Use the calculator’s default inputs: x̄ = 52, μ₀ = 50, σ = 8, and n = 64. First find the standard error:

SE = 8 / √64 = 8 / 8 = 1.

Then compare the observed sample mean with the hypothesized mean and divide by that standard error:

z = (52 − 50) / 1 = 2.0000.

The sample mean is therefore 2 standard errors above the hypothesized mean. The second calculator output, standard error, is 1.0000. These figures describe the test statistic and its scale; they do not, by themselves, establish whether the result is statistically significant.

When to Use a Z Test

A one-sample z test for a mean is appropriate when the question concerns a population mean, the observations are independent, and the population standard deviation is known. The sample should come from a suitable sampling process. If the population is normal, the sample mean has a normal distribution for any sample size; for a non-normal population, a sufficiently large sample may make a normal approximation reasonable, depending on the distribution and sampling conditions.

Do not choose a z test solely because a sample is “large.” In many practical settings, the population standard deviation is not known. A one-sample t test, which estimates spread from the sample and uses the t distribution, is generally the relevant method for testing a mean in that case. For proportions, specialized z procedures use a different standard error and assumptions; this calculator is not a proportion test.

Reading the Statistic and Finding a P-Value

The sign gives the direction of the difference: a positive z means the sample mean exceeds the hypothesized mean, while a negative z means it falls below it. The magnitude gives the distance in standard errors. For example, z = −1.5 means the sample mean is 1.5 standard errors below the null value.

A z statistic is not a probability. To assess evidence against a null hypothesis, use the statistic with the standard normal distribution to obtain a p-value, then compare that p-value with a significance level chosen for the analysis. The tail calculation depends on the alternative hypothesis:

  • For a greater-than alternative, use the upper-tail probability beyond the observed z.
  • For a less-than alternative, use the lower-tail probability.
  • For a two-sided alternative, count outcomes at least as extreme in either direction; for a continuous standard normal distribution, this is twice the upper-tail probability beyond |z|.

A p-value is not the probability that the null hypothesis is true. Nor does a small p-value measure how large or practically important an effect is. Consider the estimated difference and its context as well.

Common Mistakes and Limitations

  • Using the wrong spread: The formula requires the population standard deviation σ, not the sample standard deviation s. When σ is unknown, use an appropriate t procedure rather than silently substituting s into this z formula.
  • Mixing units: The sample mean, null mean, and standard deviation must use matching units. Converting all three consistently leaves z unchanged; mixing, for example, centimeters and meters does not.
  • Using the wrong sample size: n is the number of independent observations contributing to the mean, not the number of categories or the standard deviation. Dependence, such as repeated measurements on the same people, requires a method that accounts for it.
  • Rounding too early: Keep full precision through the calculation and round the final statistic to a sensible number of decimal places. This calculator displays four decimals.
  • Confusing statistical and practical importance: A large sample can produce a sizeable z statistic for a small difference. Report the difference and relevant uncertainty, not just z or a p-value.

The calculation also does not repair biased sampling, outliers that undermine the model, or violations of independence. A formula can return a number even when the assumptions needed to interpret it are not met.

Frequently Asked Questions

How do you calculate a z test statistic?
Subtract the hypothesized mean from the sample mean, then divide by the standard error: z = (x̄ − μ₀) / (σ / √n). Use the population standard deviation when applying this one-sample mean formula.

What does a z test statistic of zero mean?
It means the sample mean equals the hypothesized mean, so their difference is zero standard errors. It does not alone show that the study design or assumptions are sound.

Can I use the sample standard deviation in this formula?
Not for the standard one-sample z test for a mean when population variability is unknown. A one-sample t test normally accounts for estimating the standard deviation from the sample.

How do I get a p-value from a z statistic?
Use the standard normal distribution and the direction of the alternative hypothesis. A one-sided test uses one tail; a two-sided test includes equally extreme values in both tails.

Does a larger absolute z always mean a more important result?
It means the result is farther from the null value in standard-error units, but not necessarily more important in practical terms. The standard error depends on sample size, so also examine the estimated difference and study context.

Related

Formula used
in xbar | Sample mean | - | 52 | 0
in mu | Hypothesized mean | - | 50 | 0
in sigma | Population standard deviation | - | 8 | 0
in n | Sample size | - | 64 | 1
out z | Z test statistic | - | (xbar - mu) / (sigma / sqrt(n)) | 4
out se | Standard error | - | sigma / sqrt(n) | 4

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.