One-proportion z-test calculator
Is your sample percentage different from a target? Get z, the p-value, the exact test and confidence intervals.
Enter p0 as a decimal between 0 and 1 (0.25 for 25%). x is the count of successes, not a percentage.
What does a one-proportion z-test tell me?
It tests whether the share of “successes” in a population equals a value p0 that you fix in advance: a claim, a standard, last year’s rate. With x successes in n independent trials the sample proportion is p̂ = x ÷ n, and z = (p̂ − p0) ÷ √(p0(1 − p0) ÷ n). If the null hypothesis p = p0 is true, the sample proportion is approximately normal with mean p0 and standard deviation √(p0(1 − p0) ÷ n) (OpenStax Introductory Statistics, section 9.3), so z is compared with the standard normal curve. The p-value is the probability of a sample proportion at least this far from p0 (in the direction of your alternative) when p0 is the truth. It says whether the gap is bigger than chance, not whether it is big enough to matter; for that look at the confidence interval.
Why does the standard error use p0 and not the sample proportion?
A hypothesis test asks what the data would look like if the null hypothesis were true, so the spread of p̂ is worked out from p0. OpenIntro Statistics puts the rule in one line: for a test the null value stands in for the unknown p, while a confidence interval has no null value and uses p̂ instead. That is why the standard error in the table above and the standard error behind the Wald interval differ whenever p̂ ≠ p0. For the flea-shampoo example in OpenStax (17 of 42 fleas killed, p0 = 0.25) the test uses √(0.25 × 0.75 ÷ 42) = 0.0668, while the 95% interval uses √(p̂(1 − p̂) ÷ 42), and its Wald form is the (0.26, 0.55) the book prints.
Worked example: first-time brides
OpenStax, Example 9.17: Joon believes that 50% of first-time brides in the United States are younger than their grooms. She samples 100 brides, and 53 are younger; she tests p = 0.50 against p ≠ 0.50 at the 1% level. Here p̂ = 0.53, the standard error is √(0.5 × 0.5 ÷ 100) = 0.05, so z = 0.6 and the two-sided p-value is 0.5485. That is far above 0.01, so she cannot reject the null hypothesis. The exact binomial test, which needs no normal approximation, gives 0.6173: a different number, the same conclusion. Enter x = 53, n = 100 and p0 = 0.5 above to see every line.
Should the test be one-sided or two-sided?
Use a two-sided test unless, before collecting data, only one direction matters. In the OpenStax flea example a shampoo is claimed to kill more than 25% of fleas, so the alternative is p > 0.25. With 17 of 42 killed (p̂ = 0.4048), z = 2.3163 and the right-tailed p-value is 0.0103. At α = 0.01 that is not significant (0.0103 is above 0.01), and the book calls the result “not very definitive” because the p-value is so close to α. A two-sided test would have given 0.0205, twice as large. Choosing the direction after seeing the data inflates the false-positive rate.
When is the normal approximation good enough?
The z-test treats the binomial count as normal, which needs enough expected successes and failures. OpenStax (section 9.3) requires np0 > 5 and n(1 − p0) > 5; OpenIntro Statistics (section 6.1) is stricter and asks for both to be at least 10. The calculator checks both. For the OpenStax zoo exercise (39 of 50 students, p0 = 0.85) np0 = 42.5 and n(1 − p0) = 7.5: acceptable under the first rule, not the second; the z-test gives 0.1657 and the exact test 0.1660, close enough. Rare events are harder: for blood type AB− (11 of 37,937 against 0.078%) np0 = 29.6 passes both rules, yet the z-test p-value is 0.0006 while the exact one is 0.0001. Both are below 0.01, but when the numbers are small or the proportion is near 0 or 1, report the exact p-value.
What is the exact binomial test?
It uses the binomial distribution itself instead of the normal curve. For a right-tailed alternative the p-value is P(X ≥ x), for a left-tailed one P(X ≤ x), both sums of binomial probabilities. The two-sided p-value is what R’s binom.test returns: the total probability of all outcomes that are no more likely than the one you observed (allowing a relative tolerance of 10⁻⁷ for ties). For R’s own example, 682 giant and 243 dwarf plants against an expected 3/4 giants (Mendel’s data as given by Conover), the exact p-value is 0.3825. The plain z-test gives 0.3723, and the continuity-corrected version, which R’s prop.test prints, 0.393 (X² = 0.72973).
Which confidence interval should I use?
The calculator shows four, all for the same level. The Wald interval, p̂ ± z√(p̂(1 − p̂) ÷ n), is the one in most textbooks, but it is unreliable for small samples or proportions near 0 or 1, and at p̂ = 0 or 1 it shrinks to zero width (Wikipedia, “Binomial proportion confidence interval”). The Wilson score interval, with or without continuity correction, is much safer. The Clopper–Pearson interval is exact: R’s documentation says its confidence level is at least the one you ask for, though it is not always the shortest. For Mendel’s 682 of 925: Wald 0.7089 to 0.7657, Wilson 0.7080 to 0.7646, Clopper–Pearson 0.7077 to 0.7654. With 0 successes in 20 trials, Wald gives 0 to 0, Wilson 0 to 0.1611, Clopper–Pearson 0 to 0.1684.
Common mistakes and limits
Enter p0 as a decimal: 0.25, not 25. Use the number of successes, not the percentage, for x. Do not put p̂ in the standard error of a test; use p0. The test needs independent trials with the same chance of success, for example a simple random sample that is small compared with the population; it does not repair a biased sample. Non-significant does not mean equal: a small sample cannot detect a modest difference, so look at the interval, and use the sample size calculator to plan how many observations you need. To compare two groups with each other instead of one group with a number, use the two-proportion z-test calculator; for the chance of exactly k successes when p is known, the binomial probability calculator.
Sources: OpenStax, Introductory Statistics 2e, sections 9.3 “Probability Distribution Needed for Hypothesis Testing” and 9.5 “Additional Information and Full Hypothesis Test Examples” (Examples 9.17, 9.19, 9.21, 9.22 and Try It 9.17); OpenIntro Statistics (Diez, Çetinkaya-Rundel, Barr), section 6.1 “Inference for a single proportion”; documentation and source code of R (stats::binom.test and stats::prop.test) and SciPy (scipy.stats.binomtest); Wikipedia, “Binomial proportion confidence interval”; C. J. Clopper and E. S. Pearson, Biometrika 26 (1934) 404–413; R. G. Newcombe, Statistics in Medicine 17 (1998) 857–872. Related: two-proportion z-test calculator, binomial probability calculator, confidence interval calculator, sample size calculator and p-value calculator.