Inference for One Proportion

Type the number of successes x, the sample size n and the claimed proportion pβ‚€, then choose the alternative, the confidence level and Ξ±. The upper picture is the sampling distribution of pΜ‚ if pβ‚€ were true, with the p-value shaded; under it, on the same scale, is the confidence interval.

Standard deviation of pΜ‚ Οƒp^=p(1βˆ’p)n\sigma_{\hat p}=\sqrt{\frac{p(1-p)}{n}}
Confidence interval p^Β±zβˆ—p^(1βˆ’p^)n\hat p\pm z^*\sqrt{\frac{\hat p(1-\hat p)}{n}}
Test statistic z=p^βˆ’p0p0(1βˆ’p0)/nz=\frac{\hat p-p_0}{\sqrt{p_0(1-p_0)/n}}
Loading interactive simulation...

Lesson

The theory β€” Inference for One Proportion

Inference for a proportion uses the sample proportion pΜ‚ = x/n to estimate the population proportion p with a confidence interval, or to judge a claimed value pβ‚€ with a significance test.

Where the formula comes from

  1. The sampling distribution of pΜ‚. Over repeated random samples, pΜ‚ has mean p and standard deviation √(p(1 βˆ’ p)/n), and its distribution is close to normal when np and n(1 βˆ’ p) are both at least 10.
    ΞΌp^=p,Οƒp^=p(1βˆ’p)n\mu_{\hat p}=p,\qquad\sigma_{\hat p}=\sqrt{\frac{p(1-p)}{n}}
  2. Check the conditions. Random: a random sample, or random assignment in an experiment. 10%: when sampling without replacement, n is at most a tenth of the population. Large counts: for an interval, at least 10 successes and 10 failures; for a test, n pβ‚€ and n(1 βˆ’ pβ‚€) at least 10.
    n≀0.1 Nnp^β‰₯10,n(1βˆ’p^)β‰₯10np0β‰₯10,n(1βˆ’p0)β‰₯10\begin{aligned}&n\le0.1\,N\\&n\hat p\ge10,\quad n(1-\hat p)\ge10\\&np_0\ge10,\quad n(1-p_0)\ge10\end{aligned}
  3. The interval. pΜ‚ Β± z* times the standard error, which uses pΜ‚ because p is unknown. z* comes from the confidence level: 1.645 for 90%, 1.96 for 95%, 2.576 for 99%. Interpret it in context: we are 95% confident that the interval captures the population proportion, where 95% is how often the method succeeds over repeated samples.
    p^Β±zβˆ—p^(1βˆ’p^)n,zβˆ—=1.645,Β 1.96,Β 2.576\hat p\pm z^*\sqrt{\frac{\hat p(1-\hat p)}{n}},\qquad z^*=1.645,\ 1.96,\ 2.576
  4. The test. State Hβ‚€: p = pβ‚€ and the alternative. Assume Hβ‚€ is true, so the standard deviation of pΜ‚ uses pβ‚€. z says how many standard deviations pΜ‚ lies from pβ‚€, and the p-value is the chance, if Hβ‚€ is true, of a pΜ‚ at least that far in the direction of Hₐ.
    H0:Β p=p0Β β‡’Β Οƒp^=p0(1βˆ’p0)n,z=p^βˆ’p0Οƒp^H_0:\ p=p_0\ \Rightarrow\ \sigma_{\hat p}=\sqrt{\frac{p_0(1-p_0)}{n}},\qquad z=\frac{\hat p-p_0}{\sigma_{\hat p}}
  5. Conclude in context. If the p-value is below Ξ±, reject Hβ‚€: there is convincing evidence for Hₐ. Otherwise fail to reject Hβ‚€: the evidence is not convincing, which is not evidence that Hβ‚€ is true. Rejecting a true Hβ‚€ is a Type I error, and the test is built to make its chance Ξ±; with a count that is only roughly normal it is only roughly Ξ±, and at n = 100 and pβ‚€ = 0.1 a 5% test rejects a true Hβ‚€ 6.4% of the time. Failing to reject a false Hβ‚€ is a Type II error.
Assumes
The normal model is an approximation to the binomial count. When large counts fail, the page prints the exact binomial p-value beside the normal one; its two-sided version doubles the smaller tail.

Problems solved in full

  1. The sampling distribution of pΜ‚ 2 steps

    Suppose 10% of a school’s students walk to school. Describe the sampling distribution of pΜ‚ for random samples of 100 students.

    Open this problem in the tool

    1. Its centre and spread follow from p and n:

      ΞΌp^=p=0.1,Οƒp^=0.1 (0.9)100=0.03\mu_{\hat p}=p=0.1,\qquad\sigma_{\hat p}=\sqrt{\frac{0.1\,(0.9)}{100}}=0.03
    2. Its shape is approximately normal, because both expected counts reach 10:

      np=100 (0.1)=10β‰₯10,n(1βˆ’p)=100 (0.9)=90β‰₯10np=100\,(0.1)=10\ge10,\qquad n(1-p)=100\,(0.9)=90\ge10

    Answer

    Approximately normal, with mean 0.1 and standard deviation 0.03.

    p^Β βˆΌΛ™Β N(0.1,Β 0.03)\hat p\ \dot\sim\ N(0.1,\ 0.03)
  2. The 10% condition 2 steps

    The sample of 100 students is drawn without replacement from a school of only 400. Check the conditions for inference about the proportion who walk.

    Open this problem in the tool

    Show solution
    1. Large counts hold, as in the first problem. The 10% condition does not:

      n=100>0.1Γ—400=40n=100>0.1\times400=40
    2. Without replacement from a small population, pΜ‚ varies less than the formula says. The finite-population factor measures by how much:

      Nβˆ’nNβˆ’1=300399β‰ˆ0.867,0.03Γ—0.867β‰ˆ0.026\sqrt{\frac{N-n}{N-1}}=\sqrt{\frac{300}{399}}\approx0.867,\qquad0.03\times0.867\approx0.026

    Answer

    The 10% condition fails (100 > 40). The formula’s 0.03 overstates the spread of pΜ‚; corrected for the small population it is about 0.026.

    100>40,Οƒp^β‰ˆ0.026<0.03100>40,\qquad\sigma_{\hat p}\approx0.026<0.03
  3. Constructing a confidence interval 2 steps

    In a random sample of 1,000 of a city’s 300,000 voters, 520 back a candidate. Construct and interpret a 95% confidence interval for the proportion of all the city’s voters who back her.

    Open this problem in the tool

    Show solution
    1. Conditions: a random sample; 1,000 is less than a tenth of 300,000; 520 successes and 480 failures. The sample proportion and its standard error:

      p^=5201000=0.52,SE=0.52 (0.48)1000β‰ˆ0.0158\hat p=\frac{520}{1000}=0.52,\qquad SE=\sqrt{\frac{0.52\,(0.48)}{1000}}\approx0.0158
    2. Multiply by z* = 1.96 and add and subtract:

      0.52Β±1.96 (0.0158)=0.52Β±0.0310.52\pm1.96\,(0.0158)=0.52\pm0.031

    Answer

    (0.489, 0.551). We are 95% confident that between 48.9% and 55.1% of the city’s voters back the candidate.

    (0.489,Β 0.551)(0.489,\ 0.551)
  4. Using an interval to judge a claim 2 steps

    In a random sample of 100 students, 10 walk to school. A newspaper claims that 17% of the school’s students walk. Use a 95% confidence interval to judge the claim.

    Open this problem in the tool

    Show solution
    1. The interval, from 10 successes and 90 failures:

      p^=10100=0.1,0.1Β±1.960.1 (0.9)100=0.1Β±0.059=(0.041,Β 0.159)\hat p=\frac{10}{100}=0.1,\qquad0.1\pm1.96\sqrt{\frac{0.1\,(0.9)}{100}}=0.1\pm0.059=(0.041,\ 0.159)
    2. Compare the claimed value with the interval:

      0.17>0.1590.17>0.159

    Answer

    The interval (0.041, 0.159) does not contain 0.17, so 17% is not a plausible value for the proportion who walk.

    0.17βˆ‰(0.041,Β 0.159)0.17\notin(0.041,\ 0.159)
  5. A two-sided significance test 2 steps

    A school of 1,200 students claims that 10% of them walk to school; in a random sample of 100, 17 do. Test the claim at the 5% level.

    Open this problem in the tool

    Show solution
    1. Hypotheses: Hβ‚€: p = 0.1, Hₐ: p β‰  0.1. Conditions: a random sample; 100 is less than a tenth of 1,200; n pβ‚€ = 10 and n(1 βˆ’ pβ‚€) = 90. The test statistic, with the standard deviation from pβ‚€:

      z=0.17βˆ’0.10.1 (0.9)/100=0.070.03β‰ˆ2.33z=\frac{0.17-0.1}{\sqrt{0.1\,(0.9)/100}}=\frac{0.07}{0.03}\approx2.33
    2. The two-sided p-value:

      P=2 P(Zβ‰₯2.33)β‰ˆ0.020P=2\,P(Z\ge2.33)\approx0.020

    Answer

    p = 0.020 < 0.05, so reject Hβ‚€: there is convincing evidence that the proportion of students who walk is not 10%.

    Pβ‰ˆ0.020<0.05P\approx0.020<0.05
  6. A one-sided test that fails to reject 2 steps

    With 520 of 1,000 randomly sampled voters backing the candidate, is there convincing evidence that a majority of all the city’s voters back her? Use Ξ± = 0.05.

    Open this problem in the tool

    Show solution
    1. Hypotheses: Hβ‚€: p = 0.5, Hₐ: p > 0.5. Large counts: 500 and 500. The test statistic:

      z=0.52βˆ’0.50.5 (0.5)/1000=0.020.0158β‰ˆ1.265z=\frac{0.52-0.5}{\sqrt{0.5\,(0.5)/1000}}=\frac{0.02}{0.0158}\approx1.265
    2. The one-sided p-value:

      P=P(Zβ‰₯1.265)β‰ˆ0.103P=P(Z\ge1.265)\approx0.103

    Answer

    p = 0.103 β‰₯ 0.05, so fail to reject Hβ‚€: there is not convincing evidence of a majority. That is not evidence against one, either.

    Pβ‰ˆ0.103β‰₯0.05P\approx0.103\ge0.05
  7. When large counts fail, and the errors at stake 3 steps

    A supplier claims 2% of its parts are defective. In a random sample of 100, 5 are. Is the z-test appropriate? Find the exact p-value for Hₐ: p > 0.02, and say what a Type I and a Type II error would mean here.

    Open this problem in the tool

    Show solution
    1. Large counts for the test fail:

      np0=100 (0.02)=2<10np_0=100\,(0.02)=2<10
    2. Use the binomial distribution itself. If p = 0.02, the number of defects X is binomial with n = 100:

      P(Xβ‰₯5)=1βˆ’βˆ‘k=04(100k)(0.02)k(0.98)100βˆ’kβ‰ˆ0.051P(X\ge5)=1-\sum_{k=0}^{4}\binom{100}{k}(0.02)^k(0.98)^{100-k}\approx0.051
    3. A Type I error would be concluding that the supplier’s defect rate is above 2% when it is not; a Type II error would be missing a defect rate that really is above 2%.

    Answer

    No: n pβ‚€ = 2 < 10. The exact p-value is 0.051, against 0.016 from the normal curve, so at the 5% level the evidence falls just short.

    Pexactβ‰ˆ0.051,Pnormalβ‰ˆ0.016P_{\mathrm{exact}}\approx0.051,\qquad P_{\mathrm{normal}}\approx0.016
  8. Choosing the sample size 2 steps

    How large a random sample gives a 95% confidence interval with a margin of error of at most 3 percentage points, whatever the true proportion?

    Show solution
    1. pΜ‚(1 βˆ’ pΜ‚) is largest at pΜ‚ = 0.5, so plan with that:

      n=(zβˆ—m)2pβˆ—(1βˆ’pβˆ—)=(1.960.03)2(0.5)(0.5)β‰ˆ1067.1n=\left(\frac{z^*}{m}\right)^{2}p^*(1-p^*)=\left(\frac{1.96}{0.03}\right)^{2}(0.5)(0.5)\approx1067.1
    2. Round up, because 1,067 would give a margin slightly over 3 points:

      1.960.251067β‰ˆ0.0300016>0.031.96\sqrt{\frac{0.25}{1067}}\approx0.0300016>0.03

    Answer

    n = 1,068.

    n=1068n=1068

Supplementary problems, answers only

  1. In a random sample of 60, 45 have a property. Find a 90% confidence interval for the population proportion.

    Show answer

    (0.658, 0.842)

    0.75Β±1.6450.75 (0.25)60=0.75Β±0.092=(0.658,Β 0.842)0.75\pm1.645\sqrt{\frac{0.75\,(0.25)}{60}}=0.75\pm0.092=(0.658,\ 0.842)
  2. Test whether Kerrich’s coin, 5,067 heads in 10,000 tosses, was fair, at Ξ± = 0.05.

    Show answer

    z = 1.34, p = 0.18: fail to reject; no convincing evidence the coin was biased.

    z=0.5067βˆ’0.50.005=1.34,P=2 P(Zβ‰₯1.34)β‰ˆ0.18z=\frac{0.5067-0.5}{0.005}=1.34,\qquad P=2\,P(Z\ge1.34)\approx0.18
  3. Find a 95% confidence interval for the proportion of heads from Kerrich’s 10,000 tosses.

    Show answer

    (0.497, 0.516), which contains 0.5

    0.5067Β±1.96 (0.0050)=(0.497,Β 0.516)0.5067\pm1.96\,(0.0050)=(0.497,\ 0.516)
  4. How large a sample gives a 90% interval with a margin of error of at most 4 percentage points, whatever the true proportion?

    Show answer

    n = 423

    n=(1.6450.04)2(0.25)β‰ˆ422.8Β β‡’Β n=423n=\left(\frac{1.645}{0.04}\right)^{2}(0.25)\approx422.8\ \Rightarrow\ n=423
  5. A coin lands heads 40 times in 100 tosses. Test Hβ‚€: p = 0.5 against Hₐ: p < 0.5 at Ξ± = 0.05.

    Show answer

    z = βˆ’2, p = 0.023: reject Hβ‚€; there is convincing evidence that the coin lands heads less than half the time.

    z=0.4βˆ’0.50.05=βˆ’2,P=P(Zβ‰€βˆ’2)β‰ˆ0.023<0.05z=\frac{0.4-0.5}{0.05}=-2,\qquad P=P(Z\le-2)\approx0.023<0.05
  6. In the voter poll of 520 out of 1,000, what does β€œ95% confident” mean?

    Show answer

    If many random samples of 1,000 voters were taken and an interval built from each in the same way, about 95% of those intervals would capture the true proportion. It is not the chance that this one interval, (0.489, 0.551), contains it: that either happened or did not.

  7. A test is run at Ξ± = 0.01. If Hβ‚€ is in fact true, about how likely is the test to reject it, and what is that mistake called?

    Show answer

    About 0.01, exactly 0.01 only if the sampling distribution were exactly normal; rejecting a true Hβ‚€ is a Type I error. Once a test has rejected, 0.01 is not the chance that this particular rejection is a mistake.

    P(rejectΒ H0∣H0)β‰ˆΞ±=0.01P(\mathrm{reject}\ H_0\mid H_0)\approx\alpha=0.01

17 of 100 rejects 10%, and the interval keeps it

Press 17 of 100, claim 10%. The test gives z = 2.33 and p = 0.0196, so it rejects p = 0.1 at the 5% level, yet the 95% interval, 0.096 to 0.244, contains 0.1. Now press 10 of 100, claim 17%, the same two proportions with their roles swapped: the interval, 0.041 to 0.159, leaves 0.17 out, while the test keeps it with p = 0.062. Neither calculation is wrong, and the exact binomial p-value sides with the test both times, so this is not the normal curve failing. The test measures the distance from pΜ‚ to pβ‚€ with a standard deviation computed from pβ‚€, because it assumes Hβ‚€; the interval uses a standard error computed from pΜ‚, because it assumes nothing about p. At 0.1 that ruler is 0.03 and at 0.17 it is 0.0376, and a gap of 0.07 lies between 1.96 of one and 1.96 of the other. When a question asks for a test, run the test; when it asks whether a value is plausible, use the interval.

Two defects expected, five found: 1.6% by the curve, 5.1% by the count

Press 5 defects in 100. The supplier claims 2%, so 2 defects are expected and 5 turned up. The z-test gives z = 2.14 and a one-sided p-value of 0.016, comfortably under 0.05. But n pβ‚€ = 2, far below the 10 the large-counts condition asks for, and the bars behind the curve show what goes wrong: the count of defects cannot fall below 0, so its distribution is lopsided, with a long right tail the bell curve does not have. The exact chance of 5 or more defects from a 2% supplier is 0.051, three times the normal answer and just above 0.05. The large-counts condition marks where the curve stops describing the bars.

Kerrich's coin came up 67 heads over, and that is ordinary

Interned in Denmark in 1941, the mathematician John Kerrich tossed a coin 10,000 times and counted 5,067 heads. Press Kerrich's coin: z = 1.34 and p = 0.18, so a fair coin strays at least this far, one way or the other, in about one run in five or six. The 67 extra heads are not a debt the coin will repay. For a fair coin the gap between the number of heads and half the tosses has a standard deviation of √n/2, so it grows: 5 after 100 tosses, 50 after 10,000, 500 after a million. What shrinks is that gap as a share of the tosses, from 5% to 0.5% to 0.05%. The law of large numbers is a statement about the proportion, and nothing pulls the count back to even, which is why a long run of tails does not make heads due.

Learning path

Statistics: from data to proportions

References (2)