🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
💼 Servicesℹ️ About✉️ ContactView Pricing Plansfrom $10

One-Proportion Z-Test — Testing Population Proportions

Hypothesis TestingParametric Tests🟢 Free Lesson

One-Proportion Z-Test

Hypothesis Testing

Testing Claims About Proportions

The one-proportion z-test evaluates whether a population proportion differs from a claimed value, essential for analyzing binary outcomes. It bridges the gap between categorical data and inferential statistics.

  • Political Polling — Testing whether support for a candidate exceeds 50%
  • Quality Control — Verifying defect rates meet contractual specifications
  • Public Health — Assessing whether vaccination rates reach target levels

When outcomes are yes/no, the proportion z-test is your tool of choice.


What You'll Learn

  • 1State the hypotheses and the success-failure conditions for a one-proportion z-test
  • 2Compute the statistic by hand and distinguish the pooled test standard error from the interval standard error
  • 3Compare the Wald, Wilson and exact binomial intervals and know when each is trustworthy
  • 4Report Cohen's h as an effect size and recognise when an exact test must replace the normal approximation

Tests whether a population proportion π equals a hypothesized value π₀. The data are binary, the sample gives one count of successes, and everything else follows from the sampling distribution of .

The denominator uses the hypothesised proportion rather than the observed one, because under the true value of π is known to be and that is the only quantity that generates the correct null distribution.

Conditions for Validity

Check the counts before computing anything, and check them against rather than against . The reasoning is that the null distribution is built from , so the counts that determine normality are the ones the null implies. For a claim of 5 percent conversions in a sample of 350, the expected counts are 17.5 successes and 332.5 failures, both comfortably above 10. For a claim of 1 percent in a sample of 400, the expected success count is 4 and the normal approximation is unreliable — a rare event that the z-test will systematically misjudge.

The independence condition has two forms. Sampling with replacement always qualifies. Sampling without replacement from a finite population of size N qualifies when the sample fraction stays below about 10 percent; beyond that the finite population correction shrinks the true standard error and the z-test becomes conservative.

Two Worked Examples, Computed by Hand

Example 1 — is this coin fair? A coin lands heads 63 times in 100 flips.

  1. Hypotheses: against . Expected counts: successes and 50 failures, so the conditions hold.
  2. Standard error: .
  3. Statistic: .
  4. P-value: .

At we reject the claim of fairness. The 95 percent Wald interval, , runs from 0.535 to 0.725, so proportions from about 54 to 72 percent remain compatible with the data — an interval wide enough to remind us that 100 flips is a modest experiment.

Example 2 — does this page beat a 5 percent conversion claim? A campaign claims a 5 percent conversion rate; 23 of 350 visitors convert.

  1. ; expected counts and 332.5, conditions hold.
  2. .
  3. .
  4. For , the one-sided p-value is .

The observed rate is higher than claimed but not by enough to rule out sampling noise at the 5 percent level. Note how much the direction of the alternative mattered: the two-sided p-value here would be 0.177. Choosing one- or two-sided must happen before seeing the data.

Which Confidence Interval Should You Report?

The test and the interval answer different questions, and the interval you reach for by default is often the worst one.

IntervalFormula ideaBehaviour at the edgesUse when
WaldCan leave 0 and 1Quick check on large samples only
Wilson scoreCentred on a shrunken proportionAlways stays inside 0 and 1Default for a single proportion
Agresti-CoullWald on 2 extra successes and 2 extra failuresStays inside 0 and 1Simple approximation to Wilson
Clopper-PearsonInverts the exact binomial testConservative, guaranteed coverageRegulatory or legal reporting
BootstrapPercentiles of resampled proportionsDistribution-freeComplex sampling designs

The Wald interval fails in two visible ways: at small n its coverage falls below the nominal level, and when is 0 or 1 its width collapses to zero, which is obviously wrong. The Wilson interval keeps roughly 95 percent coverage across the whole range and reduces to the Wald interval as n grows. Clopper-Pearson never undercovers but often exceeds 95 percent coverage, which is why regulators accept it and researchers usually prefer Wilson.

The duality between test and interval holds only for the matching pair: the two-sided z-test rejects exactly when falls outside the corresponding Wald interval. Switching to an exact test or a Wilson interval breaks the exact correspondence, and the two can disagree near the boundary.

Effect Size: Cohen's h

A p-value answers whether the proportion differs from the claim; it says nothing about whether the difference is worth acting on. Cohen's h measures the gap on a scale where equal steps correspond to equal perceptual differences:

For the coin example, . Cohen's thresholds are 0.2 for a small effect, 0.5 for medium and 0.8 for large, so a six-point departure from 50 percent is a small-to-medium effect. The arcsine transform stabilises the variance of the proportion, which is exactly why it is also useful for powering the study.

Implementation in Python and R

python
import numpy as np
from scipy import stats

def proportion_z_test(successes, n, pi_0, alternative='two-sided', alpha=0.05):
    p_hat = successes / n

    if n * pi_0 < 10 or n * (1 - pi_0) < 10:      # conditions on pi_0
        print("WARNING: expected counts below 10 - use the exact binomial test")

    se = np.sqrt(pi_0 * (1 - pi_0) / n)            # null standard error
    z = (p_hat - pi_0) / se

    if alternative == 'two-sided':
        p_val = 2 * stats.norm.sf(abs(z))
    elif alternative == 'less':
        p_val = stats.norm.cdf(z)
    else:
        p_val = stats.norm.sf(z)

    z_crit = stats.norm.ppf(1 - alpha/2)
    se_ci = np.sqrt(p_hat * (1 - p_hat) / n)       # observed standard error
    wald = (p_hat - z_crit*se_ci, p_hat + z_crit*se_ci)

    # Wilson score interval
    denom = 1 + z_crit**2 / n
    centre = (p_hat + z_crit**2 / (2*n)) / denom
    half = z_crit / denom * np.sqrt(p_hat*(1-p_hat)/n + z_crit**2/(4*n**2))
    wilson = (centre - half, centre + half)

    h = 2*np.arcsin(np.sqrt(p_hat)) - 2*np.arcsin(np.sqrt(pi_0))

    print(f"H0: pi = {pi_0}   Ha: {alternative} {pi_0}")
    print(f"p-hat = {successes}/{n} = {p_hat:.4f}")
    print(f"z = {z:.4f}, p-value = {p_val:.6f}")
    print(f"95% Wald   CI: ({wald[0]:.4f}, {wald[1]:.4f})")
    print(f"95% Wilson CI: ({wilson[0]:.4f}, {wilson[1]:.4f})")
    print(f"Cohen's h = {h:.4f}")
    print(f"Decision: {'Reject H0' if p_val < alpha else 'Fail to reject H0'}")
    return z, p_val

proportion_z_test(63, 100, 0.50, alternative='two-sided')
proportion_z_test(23, 350, 0.05, alternative='greater')

# Exact test for when the normal approximation fails: 2 successes in 20 trials
exact = stats.binomtest(2, 20, 0.05, alternative='greater')
print(f"exact binomial p = {exact.pvalue:.6f}")
print("95% exact CI:", tuple(round(v, 4) for v in exact.proportion_ci()))
# One-proportion z-test with the score statistic and a continuity correction option
prop.test(x = 63, n = 100, p = 0.50, correct = FALSE)

# Exact binomial test and its interval - the small-sample safe choice
binom.test(63, 100, p = 0.50)
binom.test(2, 20, p = 0.05, alternative = "greater")

# Wilson interval directly
library(DescTools)
BinomCI(63, 100, method = "wilson")

# Effect size and power on the arcsine scale
ES.h <- function(p1, p2) 2*asin(sqrt(p1)) - 2*asin(sqrt(p2))
ES.h(0.63, 0.50)
power.prop.test(p1 = 0.50, p2 = 0.63, power = 0.80, sig.level = 0.05)

💡The exact test is free insurance

When the expected counts are large, the exact binomial p-value and the z-test p-value agree to two or three decimal places, so running binomtest costs nothing. When the counts are small, the exact test is correct and the z-test is not. There is no situation where the exact test is the worse choice, only one where it is marginally slower.

Reading the Result Correctly

Three habits keep proportion tests honest. First, report the count as well as the rate — "23 of 350 (6.6 percent)" carries information that "6.6 percent" alone does not. Second, pair the p-value with an interval, because a non-significant result with a wide interval is an underpowered study rather than evidence of compliance. Third, pre-specify the alternative; the difference between a one-sided p of 0.089 and a two-sided p of 0.177 is entirely a matter of when the direction was decided.

Common Mistakes

Using p-hat instead of pi-0 in the test standard error

Fix: The null distribution is generated by pi-0, so the test uses sqrt(pi_0(1-pi_0)/n); the interval uses p-hat.

Reporting the Wald interval for rare events

Fix: Use Wilson for routine work and Clopper-Pearson when guaranteed coverage is required; Wald loses coverage and can collapse to zero width.

Running the z-test when expected counts are below 10

Fix: Switch to the exact binomial test, which is valid at any sample size.

Choosing a one-sided alternative after seeing the data

Fix: Declare the direction from the research question before collecting observations; otherwise report the two-sided p-value.

Best Practices

  • Report successes, sample size, proportion, interval and p-value together
  • Check expected counts against pi-0 before trusting the normal approximation
  • Default to the Wilson interval and an exact test when in doubt
  • Use Cohen's h when the size of a proportion difference needs to be communicated

Key Takeaways

  • The test standard error uses pi-0 because the null fixes the true proportion
  • Conditions are n times pi-0 and n times 1 minus pi-0, each at least 10, plus randomness and independence
  • Wilson intervals stay inside 0 and 1 and keep nominal coverage where Wald intervals fail
  • Cohen's h standardises the proportion difference on the arcsine scale: 0.2 small, 0.5 medium, 0.8 large
  • The exact binomial test is always valid and matches the z-test closely when counts are large

Interview Questions

Q1: Why does the denominator use pi-0 rather than p-hat?

Because the null hypothesis fixes the true proportion at pi-0, so the standard deviation of p-hat under H0 is sqrt(pi_0(1-pi_0)/n). Using p-hat would produce a statistic that is not pivotal and would not follow the standard normal distribution under the null.

Q2: When does the normal approximation break down?

When the expected counts are small: n times pi-0 or n times 1 minus pi-0 below about 10. The binomial distribution is then visibly skewed and discrete, so the continuous normal reference misstates the tail probability. Use the exact binomial test.

Q3: Which confidence interval should you report for a single proportion?

The Wilson score interval by default. It keeps coverage near the nominal level across the whole range, never leaves 0 and 1, and agrees with the Wald interval on large samples. Clopper-Pearson is the conservative choice when guaranteed coverage is mandated.

Q4: How does this test relate to the chi-square goodness-of-fit test?

For two categories they are equivalent: squaring the z statistic gives the chi-square statistic with 1 degree of freedom and the same two-sided p-value. The z form makes one-sided alternatives and intervals natural.

Frequently Asked Questions

What do I do if the sample proportion is exactly 0 or 1?

The Wald interval collapses to zero width and the z-test gives a misleading standard error. Use the exact binomial test for inference, and report the rule of three for the upper bound: with zero events in n trials the 95 percent upper limit on the true rate is approximately .

Is a continuity-corrected z-test better?

The continuity correction pulls the statistic toward zero and restores some accuracy for small, discrete samples. It is conservative, sometimes overly so, and it no longer matches the uncorrected interval. Most modern practice drops the correction and relies on the exact test when counts are low.

Can I use this test for a survey with weights?

Not directly. The standard error assumes simple random sampling, so a weighted survey proportion needs the design effect or a replicate-weight variance estimator. Ignoring the design effect understates the standard error, often by a factor of 1.5 or more in household surveys.

How do I compare two independent proportions?

Use the two-proportion z-test, which pools the proportion for the test statistic and keeps the two sample proportions separate for the interval. The one-proportion form appears only when the comparison value is fixed in advance by specification, contract, or regulation.

CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-14

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Need Expert Statistics Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement