Parameters
Online calculator that computes z, the p-value and the test decision for a proportion.
The reference value stated in H₀: p = p₀. The standard error of the test is computed with this value, not with the observed proportion.
The sample proportion obtained (successes / n) that you want to compare with p₀.
Number of observations in the sample. The normal approximation is reasonable when n·p₀ and n·(1−p₀) are at least 5 or 10.
False-positive risk you accept when rejecting H₀. The usual standard value is 0.05.
Two-tailed if you are looking for any difference from p₀; one-tailed (right or left) if you only care about an increase or a decrease.
Rejection regions and observed statistic
What is a hypothesis test for one proportion?
It is the procedure for deciding, from a sample, whether the proportion of a population that meets a condition equals a reference value \(p_0\). It is used when each observation has only two possible outcomes —yes or no, defective or fine, buys or does not buy— and what matters is the percentage of "yes": is customer satisfaction still 65%? Does the defect rate exceed the 5% the supplier guarantees? Has a campaign reached its 30% response target?
The logic is that of any test. You start from the null hypothesis that the proportion is \(p_0\) and look at how far the sample proportion \(\hat{p}\) is from it. A sample never reproduces the population proportion exactly: the question is whether the observed difference is larger than sampling variation can reasonably explain. If it is, \(H_0\) is rejected in favour of the alternative hypothesis.
Hypotheses and test statistic
\(H_0: p = p_0\)
\(H_1: p \neq p_0\), \(p > p_0\) or \(p < p_0\)
\( z = \dfrac{\hat{p} - p_0}{\sqrt{p_0(1-p_0)/n}} \)
- \(\hat{p} = x/n\): sample proportion, the number of successes \(x\) divided by the sample size.
- \(p_0\): proportion stated by the null hypothesis.
- \(n\): sample size.
The denominator is the standard error of the sample proportion if \(H_0\) were true. Note that it is computed with \(p_0\), not with \(\hat{p}\): the test asks what variability you would expect if the proportion really were \(p_0\). That is why, unlike the one-mean test, you do not need to enter any standard deviation here: for a yes/no variable, the variability is determined by the proportion itself.
Thanks to the central limit theorem, with large enough samples the z statistic approximately follows a standard normal under \(H_0\). The statistic measures how many standard errors \(\hat{p}\) lies from \(p_0\).
How to carry out the test, step by step
- State the hypotheses before seeing the data: the value \(p_0\) and whether you care about any difference or only one direction.
- Set the significance level \(\alpha\), usually 0.05.
- Compute the sample proportion \(\hat{p} = x/n\) and check that the normal approximation is acceptable.
- Compute the z statistic and the p-value, or compare it with the critical value from the normal table (1.96 for a two-tailed test with \(\alpha = 0.05\)).
- Decide and interpret, reporting the decision together with the confidence interval for \(p\).
Decision rule
- If the p-value is less than \(\alpha\), \(H_0\) is rejected.
- If the p-value is greater than or equal to \(\alpha\), there is not enough evidence to reject \(H_0\).
- Not rejecting \(H_0\) does not prove that the proportion equals \(p_0\).
Two-tailed or one-tailed?
| Type | Alternative hypothesis | Example question |
|---|---|---|
| Two-tailed | \(H_1: p \neq p_0\) | Has satisfaction changed, in either direction? |
| Right-tailed | \(H_1: p > p_0\) | Does the defect rate exceed the guaranteed 5%? |
| Left-tailed | \(H_1: p < p_0\) | Has the churn rate fallen below 20%? |
The tail must be chosen before seeing the data and for a reason rooted in the problem. Choosing it after seeing which way \(\hat{p}\) points doubles the real risk of a false positive. When in doubt, use the two-tailed test.
When the normal approximation holds
The z-test is an approximation: the number of successes actually follows a binomial distribution, which looks like a normal when you expect plenty of successes and plenty of failures. The usual rule of thumb is
\( n\,p_0 \geq 10 \quad \text{and} \quad n\,(1-p_0) \geq 10 \)
(some texts accept 5). With \(p_0\) close to 0 or 1 you need large samples: for \(p_0 = 0.02\), at least 500 observations. If the rule fails, the p-value of the z-test can be quite inaccurate and an exact binomial test is preferable. The calculator warns you when the rule is not met.
Assumptions of the test
- A dichotomous variable: each observation is a success or a failure. If your variable is numeric, use the one-mean test.
- Independent observations: one response does not influence another. This fails, for example, if several people from the same household are surveyed as if they were independent.
- A random sample from the population you want to draw conclusions about. With convenience samples (volunteers, whoever answers an online survey) the test may be correct and the conclusion wrong.
- A large enough sample for the normal approximation, as explained above.
Worked example 1: two-tailed test
According to previous studies, 65% of a company's customers are satisfied with the service. After an improvement campaign, \(n = 120\) customers are surveyed and 85 say they are satisfied: \(\hat{p} = 85/120 \approx 0.708\). Has the proportion changed? We test \(H_0\colon p = 0.65\) against \(H_1\colon p \neq 0.65\) with \(\alpha = 0.05\).
The normal approximation is valid: \(n p_0 = 78\) and \(n(1-p_0) = 42\). The standard error under \(H_0\) is
\( SE = \sqrt{\dfrac{0.65 \times 0.35}{120}} \approx 0.0435 \)
and the statistic
\( z = \dfrac{0.708 - 0.65}{0.0435} \approx 1.34 \)
Since \(|z| = 1.34 < 1.96\), the statistic does not fall in the rejection region; the two-tailed p-value is \(p \approx 0.180\). \(H_0\) is not rejected.
Conclusion: these data do not provide enough evidence that satisfaction has changed. But you cannot claim the campaign was useless either: the 95% Wilson interval for \(p\) runs from 62.2% to 78.2%, compatible with no change and also with an improvement of more than 10 points. With 120 customers, the test detects with 80% probability only changes of about 12 points or more.
In the calculator: p₀ = 0.65, p̂ = 0.7083, n = 120 and "Two-tailed (≠)".
Worked example 2: one-tailed test
A supplier guarantees that at most 5% of its parts are defective. A customer inspects a random sample of \(n = 400\) parts and finds 30 defective: \(\hat{p} = 0.075\). It only worries about the rate exceeding the guarantee, so it tests \(H_0\colon p = 0.05\) against \(H_1\colon p > 0.05\) with \(\alpha = 0.05\).
\( SE = \sqrt{\dfrac{0.05 \times 0.95}{400}} \approx 0.0109, \qquad z = \dfrac{0.075 - 0.05}{0.0109} \approx 2.29 \)
The approximation is valid (\(n p_0 = 20\)). The right-tailed critical value is 1.645 and the p-value is \(P(Z \geq 2.29) \approx 0.011\). \(H_0\) is rejected: there is evidence that the defect rate exceeds the guaranteed 5%. The 95% Wilson interval for the real rate runs from 5.3% to 10.5%.
In the calculator: p₀ = 0.05, p̂ = 0.075, n = 400 and "Right-tailed (>)".
How to interpret the result
Rejecting \(H_0\) (p-value < α) means that, if the proportion really were \(p_0\), it would be very unlikely to obtain a sample proportion as far away as the one observed. But significant is not the same as important: with very large samples, differences of one percentage point become significant. Always look at how far \(\hat{p}\) is from \(p_0\), in percentage points, and at its confidence interval.
Not rejecting \(H_0\) (p-value ≥ α) does not prove that the proportion equals \(p_0\): the data are compatible with that value and often also with quite different ones, as in example 1.
In the calculator, the result shows the decision with the p-value, the z statistic and a sentence stating the conclusion. On the chart, the green area is the non-rejection region, the red areas are the critical regions and the amber line marks the observed statistic. Under "Calculation details" you will find the sample proportion, the observed difference in points, the standard error, the critical value and the Wilson interval.
Power and minimum detectable difference
Below the conclusion, the calculator shows the minimum detectable difference: the smallest real difference from \(p_0\) that, with your sample size, the test would detect with 80% probability. If it is larger than the change that would matter to you, the study has low power and a non-significant result says little. The link opens the sample size calculator for the one-proportion test with your \(p_0\), your α and the type of test, so you can work out how many observations you would need for the difference you care about.
Relationship with the confidence interval
The other link in the result opens the confidence interval for a proportion with your data. In the two-tailed test, \(H_0\) is rejected when \(p_0\) lies outside the interval. The correspondence is exact with the Wilson interval, which uses the same standard error as the test; with the Wald interval it can fail in borderline cases. The interval also tells you which values of the proportion are compatible with the data.
Common mistakes
- Entering percentages instead of proportions: 65% is written 0.65.
- Using the z-test with very few expected successes or failures, without checking \(n p_0 \geq 10\).
- Concluding that the proportion has not changed because the test is not significant.
- Choosing the tail after seeing the data.
- Forgetting how the sample was obtained: with a voluntary survey, the sample proportion can be biased even if the calculation is correct.
- Comparing two sample proportions with this test, treating one of them as if it were \(p_0\). For two groups, use the two-proportion test.
Frequently asked questions
- What does it test? Whether the proportion of a population that meets a condition equals a reference value p₀, based on the proportion observed in a sample.
- Why does the standard error use p₀ and not p̂? Because the test evaluates the variability you would expect if the null hypothesis were true, that is, if the proportion were p₀.
- When is the normal approximation valid? When enough successes and failures are expected under H₀: as a rule of thumb, n·p₀ ≥ 10 and n·(1 − p₀) ≥ 10. If not, use an exact binomial test.
- Can I use percentages? Yes, but enter them as proportions between 0 and 1: 65% is 0.65.
- Two-tailed or one-tailed? Two-tailed if you care about any difference from p₀; one-tailed only if, before seeing the data, you are interested in just one direction.
- Is significant the same as important? No. With large samples, small differences are significant. Judge the difference in percentage points and its confidence interval.
- What is the minimum detectable difference? The smallest real difference from p₀ that the test would detect with 80% probability given your sample size.
- What sample size do I need? It depends on the difference you want to detect, on p₀ and on the desired power. Work it out with the sample size calculator for the one-proportion test.
- What if I want to compare two groups? Use the two-proportion test; if the data are paired, McNemar's test.
Reference: Statistical hypothesis test — Wikipedia