A z test calculator tests a hypothesis about a mean or a proportion using the standard normal distribution. Choose the test, enter your sample results and the value under the null hypothesis, and you get the z statistic, the p-value for a two-tailed, right-tailed or left-tailed test, the critical value and a decision at your significance level. It covers one mean, two means and one or two proportions. It runs in your browser.
How to use the z test calculator
- Choose the test and the alternative hypothesis.
- Enter the sample results and the null value.
- Change the significance level if it is not 0.05.
- Press Calculate.
The z statistic for a mean
The Wikipedia article on the Z-test gives the statistic for a mean as Z = (X̄ − μ₀) ÷ s, where s is the standard error σ ÷ √n, for a population standard deviation σ and a sample size n.[1] The standard error is the typical size of the gap between a sample mean and the population mean. The statistic says how many standard errors the sample mean is from the null value.
The worked example from the page
The page's example is a reading test. The regional mean is 100 with a standard deviation of 12, and a sample of 55 pupils from a school has a mean of 96. The standard error is 12 ÷ √55 = 1.62, so z = (96 − 100) ÷ 1.62 = −2.47. The one-sided p-value is about 0.0068, and the two-sided one is about 0.014. The page concludes that, with 98.6 percent confidence, the null hypothesis is rejected.[1] Enter these numbers: the calculator gives a z of −2.472, a two-tailed p-value of 0.0134 and a left-tailed one of 0.0067, which are the same to rounding. The page adds that a sample of 900 pupils with a mean of 99 gives nearly the same z and p, which shows that a large sample can make a small difference significant.[1]
p-values and critical values
The page gives the p-values in terms of the standard normal cumulative distribution Φ: Φ(Z) for a lower-tailed test, Φ(−Z) for an upper-tailed test and 2Φ(−|Z|) for a two-tailed test. For the hypotheses, H₁ with a mean less than the null value is lower-tailed, one with a mean greater is upper-tailed, and one with a different mean is two-tailed.[1] The critical value is the z that cuts off the tail: the page's example is 1.96 for a 5 percent two-tailed test.[1] The calculator shows ±1.96 for the two-tailed test and 1.645 for a one-tailed test at 5 percent, the latter being worked out by us. If the p-value is not above your significance level, the null hypothesis is rejected.
Two proportions
For two proportions, the page gives the pooled statistic z = (p̂₁ − p̂₂) ÷ √(p̂(1 − p̂)(1 ÷ n₁ + 1 ÷ n₂)), with the pooled proportion p̂ = (x₁ + x₂) ÷ (n₁ + n₂).[1] With 45 successes in 100 and 30 in 100, the pooled proportion is 0.375, the standard error is 0.0685 and z = 2.19, so the difference is significant at 5 percent. The calculator has this test.
One proportion and two means
The pages we read do not give the other two cases, and we derived them from the same idea. For one proportion, the statistic is (p̂ − p₀) ÷ √(p₀(1 − p₀) ÷ n), so 60 successes in 100 against a null of 0.5 gives z = 2 and a two-tailed p-value of 0.0455. For two means with known standard deviations, it is (x̄₁ − x̄₂ − d₀) ÷ √(σ₁² ÷ n₁ + σ₂² ÷ n₂). You can set a difference under the null hypothesis other than 0.
When to use a z-test
The article says that the unknown quantities in the test, such as the standard deviation, should be known or estimated very accurately, and that the test statistic should be approximately normal, which the central limit theorem often ensures. It adds that if the standard deviation is unknown and the sample is small, a t-test may be more appropriate, and it gives rules of thumb of 30 or 50 observations.[1] Because the pages disagree on that cutoff, the calculator does not enforce one. For small samples with an estimated standard deviation, use the t-test.
Using the result
After you have the p-value, compare it with your significance level, which you should choose before you look at the data. If the p-value is not above the level, reject the null hypothesis. Report the z statistic, the p-value and the size of the difference, not only the decision. Look at the confidence interval too, since it shows the range of values that fit the data. For the reading example, the sample mean of 96 with a standard error of 1.62 gives a 95 percent interval of about 92.8 to 99.2, which does not contain 100.
Choosing the tail
Use a two-tailed test when you want to know if the value differs in either direction, and a one-tailed test only when a difference in the other direction would have no meaning. A one-tailed test has a lower critical value, so it finds an effect in the chosen direction more easily, which is why the choice must be made in advance. If in doubt, use the two-tailed test.
Common mistakes
- Using the sample standard deviation with a small sample. Use a t-test.
- Choosing the tail after you see the data. Decide the direction first.
- Reading p as the chance that the null is true. It is not.
- Ignoring practical size. A large sample makes small effects significant.
What next
Use this often? Add Z Test to your Home screen.
Frequently asked questions
What is a z test calculator?
A tool that tests a hypothesis about a mean or a proportion with the standard normal distribution, giving the z statistic and the p-value.
What is the z-test formula for a mean?
z = (sample mean − null mean) ÷ (σ ÷ √n), with σ the known population standard deviation.
How is the p-value found?
Φ(z) for a left-tailed test, Φ(−z) for a right-tailed test and 2Φ(−|z|) for a two-tailed test.
What is the critical value at 5 percent?
±1.96 for a two-tailed test and 1.645 for a one-tailed test.
When should I use a t-test instead?
When the population standard deviation is unknown and the sample is small.
Sources
Was this tool helpful?
What went wrong?
We only receive the reason you pick, never what you typed into the tool.
Thanks for your feedback.