Statistics

One sample test for a proportion

For years one kiwifruit in ten has been too small to export. After a dry summer, a sample of 400 fruit has 52 undersized. Is that real evidence the share has gone up, or ordinary sampling luck?

Where you are 5 in Inference for proportions

When you reach for it

Someone states a value for the share of a population with some feature, and a sample is meant to test it. Tamatea grows kiwifruit in New Zealand. In past seasons 10\% of the orchard’s fruit has been too small for export (all numbers in this lesson are made-up data). After a dry summer he suspects the share is higher this year. He picks a random sample of 400 fruit from across the orchard and finds 52 undersized, a sample proportion of 0.13.

Thirteen percent is more than ten, but a sample never lands exactly on the population value, so the question is whether 0.13 is further from 0.10 than chance alone would plausibly carry it. The one-sample z test for a proportion answers that. It brings together pieces from earlier lessons: hypotheses (Null and alternative hypotheses), the three conditions (random, independent, large counts checked with the null value), the Test statistic (how many standard deviations the sample sits from the claim, as the geothermal spa’s 89 of 250 massage bookings showed), the p-value, and the decision of Deciding and concluding from a p-value.

The lesson runs over two days. Part 1 carries out a full one-sided test. Part 2 adds two-sided tests, a test that fails to reject, technology output, and what to do when a condition fails.

The procedure

The parameter and the hypotheses. The test is about a population, so it begins by naming the parameter in context: p is the proportion of all fruit on Tamatea’s orchard this season that is too small for export. The null hypothesis gives the claimed value p_0, and the alternative says what the investigator suspects, chosen before looking at the data:

H_0\colon p = 0.10 \qquad H_a\colon p > 0.10

Hypotheses are always about p, never about \hat{p}: the sample’s value is already known, and nothing needs testing about it. The alternative may be p > p_0, p < p_0 or p \neq p_0.

The significance level. The cutoff \alpha is chosen before the data are seen, so the data cannot move it. Here \alpha = 0.05.

The conditions. The calculation that follows treats \hat{p} as approximately normal with a known standard deviation. That is true only if the data come from a random sample or randomized experiment, the observations are independent (sampling without replacement from a population at least ten times the sample, the The ten percent condition), and the expected counts of successes and failures are both at least 10. Because the test asks what would happen if H_0 were true, the expected counts use p_0:

np_0 \ge 10 \quad\text{and}\quad n(1 - p_0) \ge 10

The test statistic. Inside H_0 the parameter is known, so the spread of \hat{p} is known exactly, and the test statistic counts how many of those standard deviations separate \hat{p} from p_0:

z = \frac{\hat{p} - p_0}{\sqrt{\dfrac{p_0(1 - p_0)}{n}}}

When H_0 is true and the conditions hold, z has approximately the The standard normal distribution.

The p-value. The p-value is the probability, if H_0 were true, of a z at least as far out as the observed one in the direction H_a names: the upper tail for p > p_0, the lower tail for p < p_0, and both tails for p \neq p_0.

Decision and conclusion. If the p-value is at most \alpha, reject H_0; otherwise fail to reject it. The conclusion is then said in words about the parameter, in the setting of the problem, naming \alpha and the p-value.

Worked examples

Examples 1 to 3 belong to Part 1: a one-sided test carried out in full. Examples 4 to 6 belong to Part 2: a two-sided test, a test that fails to reject read from technology output, and a condition that fails.

Example 1

Tamatea’s undersized fruit

Carry out Tamatea’s test: H_0\colon p = 0.10, H_a\colon p > 0.10, \alpha = 0.05, with 52 undersized fruit in a random sample of 400.

Solution

The parameter is p, the proportion of all this season’s fruit on the orchard that is too small for export.

Conditions. The fruit were chosen at random from across the orchard. An orchard grows far more than 10 \times 400 = 4{,}000 fruit, so the sample is under 10\% of the population and the observations are close enough to independent. Large counts, using p_0 because the test reasons inside H_0: 400 \times 0.10 = 40 and 400 \times 0.90 = 360, both at least 10. The normal model applies.

The sample proportion is \displaystyle \hat{p} = \frac{52}{400} = 0.13. Under H_0,

\sigma_{\hat{p}} = \sqrt{\frac{0.10 \times 0.90}{400}} = \sqrt{0.000225} = 0.015
z = \frac{0.13 - 0.10}{0.015} = 2.00

The alternative is p > 0.10, so the p-value is the upper tail, shaded in Figure 1:

\text{p-value} = P(Z \ge 2.00) \approx 0.023
0.055 0.070 0.085 0.100 0.115 0.130 0.145 sample proportion −3 −2 −1 0 1 2 3 z Tamatea's sample, 0.13 p-value ≈ 0.023 if p = 0.10 is true: center 0.10, SD 0.015
Figure 1If 10\% of all the fruit were undersized, samples of 400 would give sample proportions spread like this (made-up data). The shaded tail, results at least as high as Tamatea’s 0.13, is the p-value, about 0.023.

Decision: 0.023 \le 0.05, so Tamatea rejects H_0. Conclusion in context: if 10\% of the fruit were still undersized, a random sample of 400 would show 13\% or more undersized only about 2.3\% of the time. At the \alpha = 0.05 level there is convincing evidence that more than 10\% of this season’s fruit is too small for export.

Example 2

A test in the lower direction

Wind rub has marked the skin of 25\% of the orchard’s fruit in past seasons. Wikitoria planted a new windbreak and suspects the share is now lower. In a random sample of 300 fruit, 57 show wind rub. Test at \alpha = 0.05.

Solution

Let p be the proportion of all this season’s fruit with wind rub. Her suspicion is the alternative:

H_0\colon p = 0.25 \qquad H_a\colon p < 0.25

Conditions: a random sample; 300 fruit is far less than 10\% of the crop; 300 \times 0.25 = 75 and 300 \times 0.75 = 225, both at least 10.

The sample gives \displaystyle \hat{p} = \frac{57}{300} = 0.19. Under H_0,

\sigma_{\hat{p}} = \sqrt{\frac{0.25 \times 0.75}{300}} = \sqrt{0.000625} = 0.025
z = \frac{0.19 - 0.25}{0.025} = -2.40

The alternative points down, so the p-value is the lower tail: P(Z \le -2.40) \approx 0.0082. Since 0.0082 \le 0.05, Wikitoria rejects H_0. If wind rub still marked 25\% of the fruit, a sample of 300 with 19\% or fewer marked would happen less than 1\% of the time. There is convincing evidence that less than a quarter of this season’s fruit has wind rub. The test says nothing about why: it was not an experiment, so the windbreak cannot be credited with the change from these data alone.

Example 3

How many undersized fruit would have been enough?

With Tamatea’s design (n = 400, H_0\colon p = 0.10, H_a\colon p > 0.10, \alpha = 0.05), what is the smallest number of undersized fruit that leads to rejecting H_0?

Solution

The p-value P(Z \ge z) is at most 0.05 exactly when z \ge 1.645, since P(Z \ge 1.645) \approx 0.05. Undo the division by the positive number 0.015, which keeps the inequality:

\hat{p} \ge 0.10 + 1.645 \times 0.015 = 0.124675

The count is 400\hat{p}, so it must be at least 400 \times 0.124675 = 49.87. Counts are whole numbers, so the smallest is 50. Check both sides of the line: 50 undersized gives \hat{p} = 0.125, z \approx 1.67 and a p-value of about 0.048, which rejects; 49 gives \hat{p} = 0.1225, z = 1.50 and a p-value of about 0.067, which does not. Tamatea’s 52 cleared the line by two fruit.

Example 4

A two-sided test

The packhouse’s grading machine has always sent 40\% of the orchard’s fruit to the top size grade. After it was recalibrated, Huia wants to know whether that share has changed, in either direction. In a random sample of 600 graded fruit, 267 went to the top grade. Test at \alpha = 0.05.

Solution

Let p be the proportion of all fruit the recalibrated machine sends to the top grade. Huia has no direction in mind, so

H_0\colon p = 0.40 \qquad H_a\colon p \neq 0.40

Conditions: a random sample of graded fruit; 600 is under 10\% of the fruit the machine grades in a season; 600 \times 0.40 = 240 and 600 \times 0.60 = 360.

Here \displaystyle \hat{p} = \frac{267}{600} = 0.445, and

\sigma_{\hat{p}} = \sqrt{\frac{0.40 \times 0.60}{600}} = \sqrt{0.0004} = 0.020
z = \frac{0.445 - 0.40}{0.020} = 2.25

A share as far below 0.40 as 0.445 is above it, 0.355, would be just as much evidence of a change, so both tails count (Figure 2). The normal curve is symmetric, so the two tails are equal:

\text{p-value} = 2P(Z \ge 2.25) \approx 2(0.0122) \approx 0.024
0.34 0.36 0.38 0.40 0.42 0.44 0.46 sample proportion −3 −2 −1 0 1 2 3 z Huia's sample, 0.445 0.012 as far below, 0.355 0.012 if p = 0.40 is true: center 0.40, SD 0.020
Figure 2In a two-sided test both tails count, because a share far below 0.40 would be as much evidence of a change as one far above (made-up data). The p-value is the two tails together, about 0.024.

Since 0.024 \le 0.05, Huia rejects H_0: there is convincing evidence that the recalibrated machine sends a share other than 40\% to the top grade. Because the sample fell above 0.40, the data point to a higher share. Had Huia chosen H_a\colon p > 0.40 before sampling, the p-value would have been the single tail, about 0.012; choosing the side after seeing which way the data fell would halve the p-value for no honest reason.

Example 5

A test that fails to reject, with technology output

Wikitoria tests the irrigated block separately. Its fruit has also been 10\% undersized, and she asks whether that share is higher this season. A random sample of 200 of the block’s fruit has 24 undersized. A calculator’s 1-PropZTest, given p_0 = 0.1, x = 24, n = 200 and the alternative p > p_0, shows the lines in the table. Check the output, then decide at \alpha = 0.05 and conclude.

Screen lineWhat it is
\text{prop} > .1the alternative, H_a\colon p > 0.10
z = .942809the test statistic, z \approx 0.94
p = .172889the p-value, about 0.173
\hat{p} = .12the sample proportion, \hat{p} = 0.12
n = 200the sample size
Solution

The hypotheses are H_0\colon p = 0.10 and H_a\colon p > 0.10, where p is the proportion of all this season’s fruit in the irrigated block that is undersized. The calculator does not check conditions, so they are checked by hand: a random sample, 200 fruit is a small part of the block’s crop, and 200 \times 0.10 = 20 and 200 \times 0.90 = 180 are both at least 10.

The output agrees with the formula: \displaystyle \hat{p} = \frac{24}{200} = 0.12, \displaystyle \sigma_{\hat{p}} = \sqrt{0.09/200} = \sqrt{0.00045} \approx 0.0212, and \displaystyle z = \frac{0.02}{0.0212} \approx 0.94. A spreadsheet gives the same tail from `=1-NORM.S.DIST(0.9428,TRUE)`, which returns about 0.1729.

Decision: 0.173 > 0.05, so Wikitoria fails to reject H_0. Conclusion in context: at the \alpha = 0.05 level the data do not give convincing evidence that more than 10\% of the irrigated block’s fruit is undersized. That is not the same as showing the share is 10\%. A sample share of 0.12 from 200 fruit is quite likely if p = 0.10, but it is also likely if p = 0.12 or 0.13; the test cannot tell those apart. Saying “the block’s undersized share is still 10\%” would claim far more than the data show.

Example 6

When the large counts fail

Stem-end rot has appeared in 3\% of the orchard’s fruit after storage. Huia suspects more this season and tests H_a\colon p > 0.03 with a random sample of 200 stored fruit, of which 11 have rot. Can she use the z test?

Solution

Check the large counts with p_0: 200 \times 0.03 = 6, which is under 10. The condition fails. The observed 11 rotten fruit do not rescue it: the test reasons inside H_0, and in that world only 6 rotten fruit are expected in a sample of 200, too few for the sampling distribution of \hat{p} to be close to normal. The distribution of \hat{p} is then skewed to the right.

The formula can still be evaluated, and doing so shows what goes wrong: \hat{p} = 0.055, \displaystyle z = \frac{0.055 - 0.03}{\sqrt{0.03 \times 0.97/200}} \approx 2.07 and a normal p-value of about 0.019. The exact binomial probability of 11 or more rotten fruit when p = 0.03 is about 0.040, twice as large. Here both fall under 0.05, but the normal model overstates the evidence, and with \alpha = 0.025 the two would give opposite decisions.

Two honest routes remain. Huia can use the binomial distribution directly (the Shape of a binomial and the normal approximation lesson shows why the normal curve fails when the counts are small), or she can take a larger sample: n \times 0.03 \ge 10 needs n \ge 333.3, so at least 334 fruit.

Boundaries

  • The test needs data from a random sample or a randomized experiment. Fruit picked from the rows nearest the packhouse, or the first fruit off the top of a bin, may differ from the orchard as a whole, and no calculation corrects for how a sample was chosen.
  • Independence: sampling without replacement needs the population to be at least ten times the sample. A block with only 1{,}000 fruit left on the vines cannot be sampled 200 at a time with this formula.
  • Large counts are checked with p_0, not with \hat{p}: np_0 \ge 10 and n(1 - p_0) \ge 10. When they fail, use exact binomial probabilities or a larger sample.
  • The alternative and \alpha are fixed before the data are seen. A one-sided alternative chosen after looking halves the p-value without any new evidence.
  • Rejecting H_0 says the data are hard to explain by chance if H_0 were true. It does not say the difference is large or important (Cautions about significance), and it does not say what caused it unless the data come from a randomized experiment.
  • Failing to reject is never evidence that H_0 is true; it says only that the data are consistent with it.
  • Either decision can be wrong. Rejecting a true H_0 is a Type I error, and failing to reject a false one is a Type II error; both are taught in Type I and Type II errors. How often a test catches a false H_0 is its power. Those are later lessons.

Where this goes next

The same reasoning compares two groups in the Test for a difference of proportions, with the null value of the difference set at 0 and a pooled proportion in the standard deviation. For a mean, the parameter is unknown in the standard deviation too, so a standard error stands in and the statistic follows a t distribution, in One sample test for a mean. Deciding which of these fits a given study is Choosing the right procedure. A test answers “is the claimed value believable?”; the companion question, “which values are believable?”, is answered by the One sample interval for a proportion and sample size.

Exercises

Part 1: carrying out a one-sided test

  1. In past seasons 20\% of the orchard’s fruit carried hail marks. After a hailstorm Huia suspects more. In a random sample of 400 fruit, 94 have hail marks. Test at \alpha = 0.05, naming the parameter, checking the conditions and concluding in context.
  2. Before a change in pruning, 36\% of the fruit grew touching another fruit. Tamatea suspects the new pruning lowered that share. In a random sample of 225 fruit, 63 are touching. Carry out the test at \alpha = 0.05.
  3. The packhouse says 6\% of the orchard’s fruit is bruised in handling. Wikitoria suspects more. Of a random sample of 300 fruit from the day’s intake, 27 are bruised. Carry out the test at \alpha = 0.05.
  4. Had Tamatea chosen \alpha = 0.01, would his test in Example 1 reject H_0? What is the smallest number of undersized fruit out of 400 that would reject at that level?
  5. A test of H_0\colon p = 0.10 against H_a\colon p > 0.10 for a neighboring orchard’s undersized fruit gives a p-value of 0.003 at \alpha = 0.05. Write the decision and the conclusion in context.
  6. Huia writes the hypotheses for Example 1 as H_0\colon \hat{p} = 0.10, H_a\colon \hat{p} = 0.13. Explain what is wrong with each, and write them correctly.

Part 2: two-sided tests

  1. The packhouse expects 30\% of the fruit it receives from the orchard to be gold kiwifruit. Huia checks whether the share is different this season. In a random sample of 300 fruit, 72 are gold. Test at \alpha = 0.05.
  2. Tamatea expects half the fruit to weigh more than 100 grams and asks whether the share is different this season. In a random sample of 144 fruit, 80 weigh more than 100 grams. Test at \alpha = 0.05.
  3. For the data in Exercise 8, find the p-value had Tamatea chosen H_a\colon p > 0.5 before sampling. Does the decision change? Why must the choice be made before sampling?

Part 2: technology output

  1. A calculator’s 1-PropZTest for the share of fruit sold as second grade, against the packhouse’s figure of 25\%, shows \text{prop} \neq .25, z = -1.2, p = .230139, \hat{p} = .22, n = 300. State the hypotheses, find how many sampled fruit were second grade, check the large counts, recompute z, and conclude at \alpha = 0.05.
  2. A spreadsheet gives z = 1.85 in a two-sided test. Write a spreadsheet formula for the p-value, find it, and decide at \alpha = 0.05. What would the p-value be for H_a\colon p > p_0?

Part 2: when a condition fails

  1. A test of H_0\colon p = 0.02 for the share of fruit with a rare skin spot uses a random sample of 300 fruit. Check the large counts. What is the smallest sample that passes?
  2. Tamatea collects 400 fruit from the ten vines nearest his house and finds 13\% undersized. Which condition fails, and can the z test still be used?
  3. A late block has only 2{,}000 fruit left on the vines, and Wikitoria samples 400 of them at random without replacement. Check the independence condition.

Reasoning

  1. Explain why Wikitoria’s conclusion in Example 5 must not be “the irrigated block is still 10\% undersized.”
  2. Explain why the large counts for a test use p_0 rather than \hat{p}.
  3. Explain why the p-value of a two-sided z test is twice the one-sided p-value in the direction the data fell.
  4. Huia runs a two-sided test and gets a p-value of 0.08. She then switches to a one-sided alternative in the direction the data fell and reports 0.04 at \alpha = 0.05. Explain what is wrong.
  5. A packhouse sorts a random sample of 90{,}000 fruit from many orchards and finds 9{,}270 undersized. Test H_0\colon p = 0.10 against H_a\colon p > 0.10 at \alpha = 0.05, and comment on whether the result matters to a grower.
Answers
  1. p is the proportion of all this season’s fruit with hail marks; H_0\colon p = 0.20, H_a\colon p > 0.20. Random sample, 400 is under 10\% of the crop, and 400 \times 0.20 = 80 and 400 \times 0.80 = 320. \displaystyle \hat{p} = \frac{94}{400} = 0.235; \displaystyle \sigma_{\hat{p}} = \sqrt{0.16/400} = 0.02; \displaystyle z = \frac{0.035}{0.02} = 1.75; p-value = P(Z \ge 1.75) \approx 0.040. Since 0.040 \le 0.05, reject H_0: there is convincing evidence that more than 20\% of the fruit has hail marks.
  2. H_0\colon p = 0.36, H_a\colon p < 0.36, with p the proportion of all fruit growing touching another. Counts 81 and 144. \displaystyle \hat{p} = \frac{63}{225} = 0.28; \displaystyle \sigma_{\hat{p}} = \sqrt{0.36 \times 0.64/225} = 0.032; \displaystyle z = \frac{-0.08}{0.032} = -2.5; p-value \approx 0.0062. Reject H_0: convincing evidence that under 36\% of the fruit now grows touching.
  3. H_0\colon p = 0.06, H_a\colon p > 0.06. Counts 18 and 282. \displaystyle \hat{p} = \frac{27}{300} = 0.09; \displaystyle \sigma_{\hat{p}} = \sqrt{0.000188} \approx 0.0137; z \approx 2.19; p-value \approx 0.014. Reject H_0: convincing evidence that more than 6\% of the fruit is bruised.
  4. No: 0.023 > 0.01, so he would fail to reject. Rejecting needs z \ge 2.326, so \hat{p} \ge 0.10 + 2.326 \times 0.015 = 0.13489, a count of at least 53.96: 54 fruit (z \approx 2.33, p-value \approx 0.0098; 53 gives a p-value of about 0.015).
  5. Since 0.003 \le 0.05, reject H_0. If 10\% of the neighbor’s fruit were undersized, a sample proportion at least this high would happen only about 3 times in 1{,}000, so there is convincing evidence that more than 10\% of that orchard’s fruit is undersized.
  6. Both are written about \hat{p}, whose value is known from the sample and needs no test, and H_a names one value instead of a direction. Correct: H_0\colon p = 0.10, H_a\colon p > 0.10, with p the proportion of all this season’s fruit that is undersized.
  7. H_0\colon p = 0.30, H_a\colon p \neq 0.30. Counts 90 and 210. \displaystyle \hat{p} = \frac{72}{300} = 0.24; \displaystyle \sigma_{\hat{p}} = \sqrt{0.0007} \approx 0.0265; z \approx -2.27; p-value = 2P(Z \le -2.27) \approx 0.023. Reject H_0: convincing evidence the gold share is not 30\%; the sample points to less.
  8. H_0\colon p = 0.5, H_a\colon p \neq 0.5. Counts 72 and 72. \displaystyle \hat{p} = \frac{80}{144} \approx 0.556; \displaystyle \sigma_{\hat{p}} = \sqrt{0.25/144} \approx 0.0417; z \approx 1.33; p-value \approx 0.18. Fail to reject: no convincing evidence that the share of fruit over 100 grams differs from one half.
  9. The upper tail alone, about 0.091. Still above 0.05, so the decision does not change. The side must be fixed first because choosing it after seeing the data halves the p-value with no new evidence.
  10. H_0\colon p = 0.25, H_a\colon p \neq 0.25. The count is 300 \times 0.22 = 66. Large counts 75 and 225. \displaystyle \sigma_{\hat{p}} = \sqrt{0.25 \times 0.75/300} = 0.025, \displaystyle z = \frac{0.22 - 0.25}{0.025} = -1.2, matching the screen. Since 0.230 > 0.05, fail to reject: no convincing evidence that the second-grade share differs from 25\%.
  11. `=2*(1-NORM.S.DIST(1.85,TRUE))` gives about 0.0643. Since 0.0643 > 0.05, fail to reject. For H_a\colon p > p_0 the p-value is the one tail, about 0.032 (which would have rejected, had that side been chosen first).
  12. 300 \times 0.02 = 6, under 10, so the condition fails. n \times 0.02 \ge 10 needs n \ge 500.
  13. The random condition fails: fruit near the house may differ from the orchard as a whole. No: the z test measures only chance variation and cannot correct a biased way of choosing fruit.
  14. \displaystyle \frac{400}{2000} = 0.2, so the sample is 20\% of the population, more than 10\%. The independence condition fails, and the formula’s standard deviation would be too large.
  15. Failing to reject means the data are consistent with p = 0.10, but they are also consistent with values above it, such as 0.12. The test gives no evidence for H_0, only a lack of convincing evidence against it.
  16. The p-value is computed as if H_0 were true, and in that world p = p_0. Whether \hat{p} is close to normal depends on the expected counts in that world, np_0 and n(1 - p_0).
  17. A two-sided alternative counts results as far from p_0 on either side. The standard normal curve is symmetric, so the tail beyond -|z| equals the tail beyond |z|, and together they are twice one tail.
  18. The alternative was chosen after seeing which way the data fell, which halves the p-value without any new evidence. The honest result is the two-sided 0.08: fail to reject at \alpha = 0.05.
  19. \displaystyle \hat{p} = \frac{9270}{90000} = 0.103; \displaystyle \sigma_{\hat{p}} = \sqrt{0.09/90000} = 0.001; z = 3; p-value \approx 0.0013. Reject H_0: convincing evidence the share is above 10\%. But the share is only about 0.3 percentage points above, likely too small to matter to a grower; a huge sample detects tiny differences.
kg1128 · updated 2026-10-20 · CC-BY-SA-4.0