
construct a confidence interval for a population proportion, check its conditions, interpret the interval and the confidence level, and find the sample size for a desired margin of error.
Instruction
In RLP Statistics A you simulated a margin of error. Now the sampling distribution lets you compute one from a single sample.
The logic. For random samples, p̂ is approximately normal with mean p and standard deviation √(p(1 − p)/n). So in about 95% of samples, p̂ lands within 1.96 standard deviations of p. Turn that around: in about 95% of samples, p lies within 1.96 SDs of p̂. We don’t know p, so we estimate the SD with the standard error SE = √(p̂(1 − p̂)/n). The interval is
p̂ ± z*·√(p̂(1 − p̂)/n)
where z* = 1.645 for 90% confidence, 1.96 for 95% and 2.576 for 99%. The part after ± is the margin of error.
Worked example. The population is every day at St. Louis Lambert International Airport from 2000 to 2024 (NOAA GHCN-Daily, 9,132 days). A random sample of 200 days, drawn with a random number generator, contained 66 rainy days (at least 0.01 in).
- Parameter: p = the proportion of all days in 2000-2024 with measurable rain at St. Louis.
- Conditions: Random: a simple random sample. 10%: 200 is less than 10% of 9,132, so the observations are nearly independent. Large counts: 66 successes and 134 failures, both at least 10, so p̂ is approximately normal.
- Compute: p̂ = 66/200 = 0.330. SE = √(0.330 × 0.670/200) ≈ 0.0332. Margin = 1.96 × 0.0332 ≈ 0.065. Interval: 0.265 to 0.395.
- Interpret: We are 95% confident that between 26.5% and 39.5% of days at St. Louis in 2000-2024 had measurable rain.
Here we can check: the true p is 2,846/9,132 ≈ 0.3117, which is inside the interval. In real studies you never get to check. That is why the method’s track record matters.
What “95% confident” means. The confidence level describes the method, not this one interval. If we took many random samples and built an interval from each, about 95% of the intervals would capture p. A simulation of 10,000 samples of 200 St. Louis days did exactly this: 94.5% of the intervals captured 0.3117. Any single interval either captures p or does not. We just don’t know which, so we say “95% confident”, not “95% probability”.
What changes the width. Higher confidence means a larger z* and a wider interval. A larger n means a narrower interval, but only in proportion to 1/√n.
Choosing a sample size (PS.17). To get margin of error E, solve E = z*√(p*(1 − p*)/n) for n:
n = (z*/E)2 · p*(1 − p*)
If you have no prior guess, use p* = 0.5, which gives the largest n and so guarantees the margin. For a 95% margin of ±3 percentage points: n = (1.96/0.03)2(0.25) ≈ 1,067.1, so 1,068. Always round up. For ±5 points: 384.2, so 385. Halving the margin requires four times the sample, which is why national polls rarely go below ±3 points.
Plus-four note. When counts are small, a better interval adds 2 successes and 2 failures before computing (OpenStax covers this as the “plus-four” method). For this course, check the large-counts condition, and say so if it fails.
📖 Read for this lesson
The reading opens over the lesson; close it to come back to exactly where you were. The checks below draw on it.
Formative check
Work through these before moving on. They are not graded — they tell you whether the standard below has landed yet.
With 66 rainy days in 200, p̂ = , SE ≈ 0.0332, and the 95% interval is 0.330 ± .
Which is a correct interpretation of the 95% confidence level?
Simulation & tools
How often do 95% intervals capture p?
Data: NOAA NCEI GHCN-Daily, St. Louis Lambert International Airport (USW00013994), 2000-2024 (same import URL as Unit 1, with attribute rainy = if(PRCP>=0.01,1,0)). The true p = 0.3117.
- Use the Sampler to draw 100 samples of 200 days, collecting the mean of rainy (p̂).
- In the collected table, add attributes lower = p̂ − 1.96·sqrt(p̂(1−p̂)/200), upper likewise, and hit = if(lower<=0.3117 and upper>=0.3117, 1, 0).
- Record the fraction of hits. Repeat the run ten times, or add the recorded run in this lesson’s reading, to reach at least 1,000 intervals. Compare with 95%.
- Change 1.96 to 1.645 and record the new capture rate and the average width.
Spreadsheet route: simulate samples with =RAND()<0.3117 in 200 cells per row (a binomial sample), compute each row’s interval and hit, and fill down 500 rows.
Open in a new tab ↗ · CODAP, Concord Consortium · MIT open source
A county agency wants to estimate the proportion of households with broadband internet to within ±4 percentage points with 95% confidence. (a) Find the sample size with p* = 0.5. (b) An earlier survey suggests p is about 0.85; find n again and explain why it is smaller. (c) Name one source of error that no sample size will remove.
How confident are you that you can build and correctly interpret a confidence interval for a proportion, and find the sample size for a margin of error?
Practice
Work these on paper or in your notebook, then open Check your answer. Aim for all of Fluency and Application; try at least one Challenge.
Printable version: this unit’s practice workbook (PDF)
Fluency
Build speed and accuracy with the core skill.
- In a random sample of 1000, 422 said yes. Construct a 90% confidence interval for the population proportion.
Check your answer
Answer: p̂ = 0.422; margin ≈ 0.026; interval ≈ (0.396, 0.448). We are 90% confident that the proportion of the whole population who would say yes is between 0.396 and 0.448.z* ≈ 1.645. Conditions: a random sample; the sample is less than 10% of the population; successes and failures (422 and 578) are both at least 10. - In a random sample of 800, 223 said yes. Construct a 95% confidence interval for the population proportion.
Check your answer
Answer: p̂ = 0.279; margin ≈ 0.031; interval ≈ (0.248, 0.310). We are 95% confident that the proportion of the whole population who would say yes is between 0.248 and 0.310.z* ≈ 1.960. Conditions: a random sample; the sample is less than 10% of the population; successes and failures (223 and 577) are both at least 10. - In a random sample of 200, 53 said yes. Construct a 90% confidence interval for the population proportion.
Check your answer
Answer: p̂ = 0.265; margin ≈ 0.051; interval ≈ (0.214, 0.316). We are 90% confident that the proportion of the whole population who would say yes is between 0.214 and 0.316.z* ≈ 1.645. Conditions: a random sample; the sample is less than 10% of the population; successes and failures (53 and 147) are both at least 10. - In a random sample of 400, 222 said yes. Construct a 95% confidence interval for the population proportion.
Check your answer
Answer: p̂ = 0.555; margin ≈ 0.049; interval ≈ (0.506, 0.604). We are 95% confident that the proportion of the whole population who would say yes is between 0.506 and 0.604.z* ≈ 1.960. Conditions: a random sample; the sample is less than 10% of the population; successes and failures (222 and 178) are both at least 10. - In a random sample of 500, 419 said yes. Construct a 95% confidence interval for the population proportion.
Check your answer
Answer: p̂ = 0.838; margin ≈ 0.032; interval ≈ (0.806, 0.870). We are 95% confident that the proportion of the whole population who would say yes is between 0.806 and 0.870.z* ≈ 1.960. Conditions: a random sample; the sample is less than 10% of the population; successes and failures (419 and 81) are both at least 10. - In a random sample of 800, 548 said yes. Construct a 90% confidence interval for the population proportion.
Check your answer
Answer: p̂ = 0.685; margin ≈ 0.027; interval ≈ (0.658, 0.712). We are 90% confident that the proportion of the whole population who would say yes is between 0.658 and 0.712.z* ≈ 1.645. Conditions: a random sample; the sample is less than 10% of the population; successes and failures (548 and 252) are both at least 10. - Find z* for 90%, 95% and 99% confidence.
Check your answer
Answer: 1.645, 1.960 and 2.576. - How large a sample gives a 95% margin of error of ±4 points for a proportion, with no prior estimate?
Check your answer
Answer: n = (1.96/0.04)² × 0.25 = 600.25, so 601.Round up.
Application
Use the skill in context. Show your reasoning.
- A random sample of 150 days from Springfield’s 2000-2024 daily record (NOAA) contains 55 days with measurable rain. Check the conditions, construct a 95% confidence interval for the proportion of rainy days, and interpret it.
Check your answer
Answer: Random sample; 150 < 10% of the 9,132 days; 55 successes and 95 failures (both ≥ 10). p̂ = 0.367, SE ≈ 0.0393, interval ≈ (0.290, 0.444). We are 95% confident that between 29.0% and 44.4% of days at Springfield in 2000-2024 had measurable rain.In fact the population value is 0.2945: the interval captured it. - Explain what ‘95% confident’ means for the Springfield interval, without using the word ‘probability’ about the parameter.
Check your answer
Answer: If we took many random samples of 150 days and built an interval from each in the same way, about 95% of those intervals would contain the true proportion of rainy days. - Before sampling, a planner guesses that about 13% of days have at least 0.25 inch of rain. How many days are needed for a 95% margin of error of ±0.03 for that proportion? Compare with the answer using p* = 0.5.
Check your answer
Answer: With p* = 0.13: n = (1.96/0.03)² × 0.13 × 0.87 ≈ 482.8, so 483. With p* = 0.5: 1,068. A good prior guess far from 0.5 cuts the required sample by more than half.
Challenge
Stretch problems. Expect to think before you write.
- A random sample of 40 days contains 3 days with at least 1.5 inches of rain. Why is the usual z-interval not appropriate, and what could you do?
Check your answer
Answer: Only 3 successes (fewer than 10), so p̂ is not approximately normal and the interval would be unreliable (it would even extend below 0). Take a larger sample, or use an adjusted method such as the plus-four interval: (3 + 2)/(40 + 4) ≈ 0.114 with SE based on n = 44.
Review
Keep earlier skills sharp.
- X is normal with mean 100 and standard deviation 15. Find P(90 < X < 119).
Check your answer
Answer: 0.6449Standardize both ends, then subtract the cumulative areas. - X ~ Binomial(n = 7, p = 0.4). Find P(X = 3), P(X ≤ 3), and the mean and standard deviation of X.
Check your answer
Answer: P(X = 3) ≈ 0.2903; P(X ≤ 3) ≈ 0.7102; mean 2.80; SD ≈ 1.296P(X = k) = C(7, k) pk(1 − p)n−k.
Forty Intervals and Where They Landed: A Capture Record from a Known Population
Population: NOAA NCEI GHCN-Daily, station USW00013994 (St. Louis Lambert International Airport), PRCP, 2000-2024, N = 9,132 days; intervals generated for this course with Python’s random module, seed 2026; ACS 2023 broadband figure for Missouri from U.S. Census Bureau table B28002; retrieved 2026-11-10 · SLS original, with public domain NOAA and Census data
Why this reading. The lesson says that about 95% of simulated intervals captured the true proportion, and the lab asks you to build a few hundred such intervals in CODAP. A run you did not see, or a run only you have, is not something you can check. This one is. Forty intervals are printed with every intermediate number, from a stated seed on the stated population, so the arithmetic and the hits can be verified one row at a time; the same code run to 1,000 gives the totals at the end.
The population and the method
Population: the 9,132 days at St. Louis Lambert International Airport, 2000–2024 (NOAA GHCN-Daily PRCP, the same file as Lessons 1.4 and 2.1). A day is rainy if PRCP ≥ 0.01 in. True proportion p = 2,846/9,132 = 0.3117. Each sample: 200 days drawn with random.Random(2026).choices(population, k=200), the 40 samples taken in sequence from that one generator. For each sample, p̂ = x/200, SE = √(p̂(1 − p̂)/200), interval p̂ ± 1.96 SE. The last column reruns the same sample with 1.645.
Record: forty 95% intervals
| Sample | Rainy days x | p̂ | SE | Lower | Upper | Captures 0.3117? | 90% interval captures? |
|---|---|---|---|---|---|---|---|
| 1 | 61 | 0.305 | 0.0326 | 0.241 | 0.369 | yes | yes |
| 2 | 53 | 0.265 | 0.0312 | 0.204 | 0.326 | yes | yes |
| 3 | 58 | 0.290 | 0.0321 | 0.227 | 0.353 | yes | yes |
| 4 | 56 | 0.280 | 0.0317 | 0.218 | 0.342 | yes | yes |
| 5 | 47 | 0.235 | 0.0300 | 0.176 | 0.294 | no | no |
| 6 | 57 | 0.285 | 0.0319 | 0.222 | 0.348 | yes | yes |
| 7 | 49 | 0.245 | 0.0304 | 0.185 | 0.305 | no | no |
| 8 | 71 | 0.355 | 0.0338 | 0.289 | 0.421 | yes | yes |
| 9 | 60 | 0.300 | 0.0324 | 0.236 | 0.364 | yes | yes |
| 10 | 58 | 0.290 | 0.0321 | 0.227 | 0.353 | yes | yes |
| 11 | 62 | 0.310 | 0.0327 | 0.246 | 0.374 | yes | yes |
| 12 | 77 | 0.385 | 0.0344 | 0.318 | 0.452 | no | no |
| 13 | 68 | 0.340 | 0.0335 | 0.274 | 0.406 | yes | yes |
| 14 | 71 | 0.355 | 0.0338 | 0.289 | 0.421 | yes | yes |
| 15 | 64 | 0.320 | 0.0330 | 0.255 | 0.385 | yes | yes |
| 16 | 56 | 0.280 | 0.0317 | 0.218 | 0.342 | yes | yes |
| 17 | 65 | 0.325 | 0.0331 | 0.260 | 0.390 | yes | yes |
| 18 | 65 | 0.325 | 0.0331 | 0.260 | 0.390 | yes | yes |
| 19 | 66 | 0.330 | 0.0332 | 0.265 | 0.395 | yes | yes |
| 20 | 52 | 0.260 | 0.0310 | 0.199 | 0.321 | yes | no |
| 21 | 54 | 0.270 | 0.0314 | 0.208 | 0.332 | yes | yes |
| 22 | 60 | 0.300 | 0.0324 | 0.236 | 0.364 | yes | yes |
| 23 | 70 | 0.350 | 0.0337 | 0.284 | 0.416 | yes | yes |
| 24 | 62 | 0.310 | 0.0327 | 0.246 | 0.374 | yes | yes |
| 25 | 70 | 0.350 | 0.0337 | 0.284 | 0.416 | yes | yes |
| 26 | 64 | 0.320 | 0.0330 | 0.255 | 0.385 | yes | yes |
| 27 | 54 | 0.270 | 0.0314 | 0.208 | 0.332 | yes | yes |
| 28 | 67 | 0.335 | 0.0334 | 0.270 | 0.400 | yes | yes |
| 29 | 68 | 0.340 | 0.0335 | 0.274 | 0.406 | yes | yes |
| 30 | 61 | 0.305 | 0.0326 | 0.241 | 0.369 | yes | yes |
| 31 | 61 | 0.305 | 0.0326 | 0.241 | 0.369 | yes | yes |
| 32 | 72 | 0.360 | 0.0339 | 0.293 | 0.427 | yes | yes |
| 33 | 67 | 0.335 | 0.0334 | 0.270 | 0.400 | yes | yes |
| 34 | 62 | 0.310 | 0.0327 | 0.246 | 0.374 | yes | yes |
| 35 | 50 | 0.250 | 0.0306 | 0.190 | 0.310 | no | no |
| 36 | 62 | 0.310 | 0.0327 | 0.246 | 0.374 | yes | yes |
| 37 | 68 | 0.340 | 0.0335 | 0.274 | 0.406 | yes | yes |
| 38 | 60 | 0.300 | 0.0324 | 0.236 | 0.364 | yes | yes |
| 39 | 56 | 0.280 | 0.0317 | 0.218 | 0.342 | yes | yes |
| 40 | 62 | 0.310 | 0.0327 | 0.246 | 0.374 | yes | yes |
Check a row. Sample 5 had 47 rainy days: p̂ = 0.235, SE = √(0.235 × 0.765/200) = 0.0300, interval 0.176 to 0.294. Sample 12 had 77: interval 0.318 to 0.452. Both are random samples from one population, and the method is the same for each; the intervals differ because the samples differ. A row that says no was not computed wrongly. The method misses about one time in twenty, and those rows are the times.
Totals. 36 of 40 intervals captured 0.3117 (90.0%); the misses are samples 5, 7, 12, 35. At 90% confidence, 35 of 40 (87.5%). Average width: 0.128 at 95%, 0.107 at 90%, a ratio of 1.645/1.96 = 0.84, as the formula says. Forty is too few to pin down a capture rate: the standard error of a proportion near 0.95 from 40 trials is √(0.95 × 0.05/40) = 0.034, so 90.0% is within about 1.5 standard errors of 95%. Run the same code for 1,000 samples and the totals are 950 of 1,000 at 95% (95.0%) and 895 of 1,000 at 90% (89.5%). The lesson’s run of 10,000 gave 94.5%.
What to notice in the record
The intervals are not all the same width. SE depends on p̂, so a sample with 47 rainy days makes a narrower interval than one with 77. Every miss is a sample whose p̂ was far from p; narrow or wide, the interval is centered on the sample, and that is what fails.
“95% confident” is a statement about the column of yes/no answers, not about any one row. Before you look at the last column, each row has a 95% chance of saying yes. After you look, it says yes or no.
Every sample here passes the large-counts check: the smallest x is 47 and the largest is 77, so successes and failures are both at least 10 in all forty.
For the sample-size question
The open question asks for n at ±4 points with p* = 0.5 and with p* = 0.85. A real planning value for broadband: the Census Bureau’s 2023 American Community Survey estimates that 90.7% of Missouri households have a broadband subscription of some kind (2,319,607 of 2,556,271 households; table B28002; the Lesson 2.3 reading prints it county by county). With p* = 0.907, n = (1.96/0.04)2(0.907)(0.093) = 2,401 × 0.0840 = 201.7, so 202 households. For p* = 0.5 the same margin needs 601, and for p* = 0.85, 307. A good planning value for a proportion far from one half saves a great deal of work; a bad one gives a margin you did not promise.
Sources: NOAA NCEI, Daily Summaries (GHCN-Daily) data search (ncei.noaa.gov); NOAA NCEI Access Data Service (the query used here) (ncei.noaa.gov); Python documentation, the random module (docs.python.org); U.S. Census Bureau, ACS 2023 1-year summary file, table B28002 (www2.census.gov)