Z-Test Calculator: Formula, Steps and Worked Example
Calculate a one-sample z-test online. Enter the sample mean, population mean, standard deviation, and sample size to get the z-score and a worked example.
Use this calculator to perform a one-sample Z-test. Enter the required values below.
Z-Score Visualization
Documentation
What is a z-test?
A z-test is a statistical test that checks whether a sample mean differs significantly from a known population mean, when the population's standard deviation is already known. It produces a single number, the z-score, that shows how many standard deviations the sample mean sits from the population mean. Researchers, quality inspectors, and analysts use it to judge whether an observed difference is likely real or just the result of chance.
Z-test formula
The z-test calculates a z-score with this formula:
- is the sample mean
- is the population mean
- is the population standard deviation
- is the sample size
The bottom part of the formula, , is called the standard error. It measures how much sample means are expected to vary just from random sampling.
How to calculate a z-test step by step
- Find the sample mean () from the collected data.
- Identify the known population mean ().
- Identify the known population standard deviation ().
- Count the sample size ().
- Subtract from .
- Divide by the square root of to get the standard error.
- Divide the result of step 5 by the result of step 6. The answer is the z-score.
Worked example
A factory says its bolts average 10 cm long, with a population standard deviation of 0.2 cm. An inspector measures 100 bolts and finds a sample mean of 10.05 cm.
Standard error:
Z-score:
The z-score is 2.5. The sample mean sits 2.5 standard errors above the population mean.
How to interpret a z-score
A z-score near 0 means the sample mean is close to the population mean. A large positive or negative z-score means the sample mean is far from the population mean, which points to a real difference rather than random chance.
Common critical values for a two-tailed test:
- α = 0.10 (90% confidence): z = ±1.645
- α = 0.05 (95% confidence): z = ±1.96
- α = 0.01 (99% confidence): z = ±2.58
If the calculated z-score is beyond the critical value for the chosen significance level, the result is called statistically significant, and the null hypothesis (that there is no difference) is rejected.
In the worked example, z = 2.5 is beyond ±1.96, so the difference is statistically significant at the 0.05 level. The two-tailed p-value for z = 2.5 is about 1.24%, meaning there is roughly a 1-in-80 chance of seeing a difference this large if the true average bolt length really were 10 cm.
When to use a z-test
A z-test is appropriate when:
- The population standard deviation is known.
- The sample size is reasonably large, usually more than 30.
- The data come from random sampling.
- The population is normally distributed, or the sample is large enough for the Central Limit Theorem to apply.
If the population standard deviation is unknown, or the sample is small, a t-test is used instead. The t-test estimates variability from the sample itself and accounts for the added uncertainty this causes.
Z-test vs t-test
Both tests measure how far a sample mean is from an expected value, in units of standard error. The z-test assumes the population standard deviation is known. The t-test estimates that value from the sample and uses a wider, sample-size-dependent distribution to account for the extra uncertainty. In practice, the t-test is used far more often, because the true population standard deviation is rarely known.
Real-world uses of the z-test
- Quality control: checking whether a batch of manufactured parts matches the target specification.
- Medical research: comparing a treatment group's average result to a known population value.
- Education: comparing a class's test scores to a national average.
- Finance: checking whether a fund's returns differ from a benchmark average.
History
The normal distribution behind the z-test was described by Abraham de Moivre in 1733, as an approximation to the binomial distribution. Carl Friedrich Gauss and Pierre-Simon Laplace developed the theory further in the early 1800s. Formal hypothesis-testing methods, including the use of z-scores and critical values to judge statistical significance, were developed in the early 20th century by statisticians including Ronald Fisher, Jerzy Neyman, and Egon Pearson.
Frequently asked questions
What is the difference between a z-test and a t-test?
A z-test requires a known population standard deviation and works best with large samples. A t-test is used when the population standard deviation is unknown and must be estimated from the sample; it works for both small and large samples.
What sample size does a z-test need?
A sample size above 30 is the common rule of thumb. Below that, results from a z-test become unreliable, and a t-test is usually the better choice.
What does a z-score of 2.5 mean?
A z-score of 2.5 means the sample mean is 2.5 standard errors above the population mean. That is beyond the two-tailed critical value of ±1.96 for 95% confidence, so the difference is statistically significant at that level. The two-tailed p-value for z = 2.5 is about 1.24%.
What is a p-value in a z-test?
The p-value is the probability of getting a result at least as extreme as the observed one, if there really were no difference from the population mean. A smaller p-value is stronger evidence against the null hypothesis. A p-value below 0.05 is commonly treated as statistically significant.
What is the null hypothesis in a z-test?
The null hypothesis states that there is no difference between the sample mean and the population mean. The z-test measures how much evidence the sample provides against that claim.
Can a z-test be used for small samples?
It is not recommended. With a small sample, or an unknown population standard deviation, a t-test gives more accurate results because it accounts for the extra uncertainty involved in estimating variability from limited data.