Z-Test Calculator
A one-sample z-test from a sample mean, a hypothesised mean, a known sigma and n, with the two-tailed p.
What the z-test calculator does
It tests one sample mean against a hypothesised mean when the population standard deviation is known: z = (x̄ − μ₀)/(σ/√n), and the two-tailed p is 2(1 − Φ(|z|)), with Φ the standard normal CDF.
A sample mean of 12 against a hypothesised 10, with σ = 4 and n = 25, has a standard error of 4 ÷ √25 = 0.8 and a z of 2.5. The two-tailed p is 0.0124, so a difference this large is uncommon under the null — the page prints the number and leaves the decision to the reader.
σ is required rather than estimated. That is what makes this a z-test rather than the t-test the catalogue already serves: with only the sample's s, the t-test page is the right one, and this page says so in its result. The normal CDF is evaluated with the Abramowitz and Stegun 7.1.26 approximation, whose error is below 1.5 × 10⁻⁷, so the printed p is good to four decimals.
σ must be above zero and n must be a whole number of at least 1. A negative or non-numeric σ, a fractional n and a missing value are each refused by name. A p-value below 0.0001 is printed as < 0.0001 rather than as 0.
Figures print to up to four decimal places with trailing zeros trimmed.
How to use it
Enter Sample mean, Hypothesised mean μ₀, Known standard deviation σ and Sample size n.
Press Run. The result prints the standard error, z, the two-tailed p and the basis line that points at the t-test page.
Worked example
Input with the defaults:
12, μ₀ 10, σ 4, n 25
Output:
Standard error: 0.8 (σ ÷ √n)
z: 2.5
p (two-tailed): 0.0124
Why it runs in your browser
The test statistic and the p-value are computed in this tab. Your sample summary is never uploaded.
The page runs a one-sample z-test: a sample mean against a hypothesised mean, with a population standard deviation you supply. A mean of 12 against 10, with σ = 4 and n = 25, gives a standard error of 0.8, z = 2.5 and a two-tailed p of 0.0124.
σ is a required input, not something the page estimates. That is what separates a z-test from a t-test, and the result line points at the t-test page when only the sample standard deviation is available.
The p-value is computed from the standard normal CDF with the Abramowitz and Stegun 7.1.26 approximation, whose error is below 1.5 × 10⁻⁷, so four printed decimals are safe.
When a z-test is the right test
Use it when the standard deviation of the population is known before the sample is taken, or when the sample is large enough that estimating it changes nothing material. The formula is z = (x̄ − μ₀)/(σ/√n), and it assumes the observations are independent and the sample mean is approximately normal.
If the only spread you have is the sample's own s, the statistic is a t, not a z, and the t-test page is the one to use. The two differ most at small n, which is precisely where the wrong choice matters.
Reading a two-tailed p-value
The p-value is the probability of a z at least this far from zero in either direction, assuming the hypothesised mean is true. The page prints it, not a verdict: whether 0.0124 is small enough is a decision about the cost of being wrong, which the page does not know.
A p-value below 0.0001 is printed as `< 0.0001` rather than 0. A printed zero would suggest the event is impossible, which the approximation cannot support.
How to use Z-Test Calculator
Enter Sample mean and Hypothesised mean μ₀.
Enter Known standard deviation σ and Sample size n.
Press Run. The result prints the standard error, z, the two-tailed p and the basis line.
What to Expect
Best for
- Testing one sample mean against a stated target with a known σ
- A large-sample test where s and σ are close
- Teaching the difference between a z and a t statistic
Not ideal for
- A small sample with only its own standard deviation, which needs a t-test
- Two samples, a paired design or a count table
- Deciding what a p-value means for your field
What this tool keeps
- The four values you typed
- The σ and n the standard error was built from
What may need cleanup
- A sample mean that has to be computed from raw data first
- A one-tailed hypothesis, which this page does not compute
Common errors
- Using the sample s in place of a known σ
- Reading the p-value as the probability that the null is true
Example use cases
- Checking a process mean against a specification
- Comparing a class mean with a national mean when σ is published
- Demonstrating a two-tailed p-value by hand
Sample input
Sample mean 12, hypothesised mean 10, known σ 4, sample size 25.
Sample output
A standard error of 0.8, z = 2.5 and a two-tailed p of 0.0124.
Who this is for
- Students meeting the z-test before the t-test
- Analysts testing a mean against a published σ
Frequently asked questions
Why does the page need σ instead of the sample standard deviation?
A z-test is defined with the population standard deviation. Substituting the sample s turns the statistic into a t, which has heavier tails at small n. The t-test page serves that case.
Is the p-value one-tailed or two-tailed?
Two-tailed: it doubles the upper tail of the standard normal, so a difference in either direction counts. A one-tailed test would be half this value, and the page does not offer that choice.
Why is a very small p printed as less than 0.0001?
Because four decimals cannot distinguish 0.00004 from 0.0000001, and printing 0 would imply the event cannot happen. The bound is honest about the precision the page has.
Does a small p mean the difference matters?
No. The p-value says how surprising the mean is under the hypothesised value; it says nothing about the size of the difference or whether it is worth acting on. The effect-size page standardises the difference for that question.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.