Find a course

Module 3: Estimation and Hypothesis TestingLesson 5 of 1114 min

Confidence Intervals and Margins of Error

Build confidence intervals for proportions and means, interpret them correctly, size a survey for a target margin of error, and know what intervals ignore.

Step 1 of 13Learn

42% plus or minus what?

A product team surveys 1,200 randomly chosen users and finds that 42% want a dark mode. A month later, another random survey of 1,200 users finds 45%. One manager declares that demand is growing; another says nothing has changed. Who is right?

Neither can tell from the two numbers alone. Each survey result is an estimate: if you had picked a different random 1,200 users, you would have gotten a slightly different percentage. The question is how much a result could move by chance alone.

A confidence interval answers that. It surrounds an estimate with a range that reflects sampling noise, for example "42%, with a 95% confidence interval from 39.2% to 44.8%". The half-width of the interval, here about 2.8 percentage points, is the margin of error you see in published polls.

With intervals, the dark mode question becomes clearer. The first survey's interval runs from about 39% to 45%, and the second's from about 42% to 48%. They overlap heavily, so the data is consistent with no change at all. A real increase is possible, but these surveys can't establish it. In this lesson you will learn to compute such intervals, interpret them correctly and decide how big a sample you need for the precision you want.

Step 2 of 13Learn

Building a confidence interval

Most confidence intervals have the same structure:

estimate ± critical value × standard error

The standard error comes from the previous lesson. The critical value depends on how confident you want to be. For intervals based on the normal distribution:

confidence levelcritical value z*
90%1.645
95%1.96
99%2.576

For a proportion, the 95% interval is p ± 1.96 × √(p(1 − p)/n). For the dark mode survey: SE = √(0.42 × 0.58 / 1,200) ≈ 0.01425, and 1.96 × 0.01425 ≈ 0.028. The interval is 42% ± 2.8 points, or 39.2% to 44.8%.

For a mean, the interval is x̄ ± t* × s / √n, where t* comes from the t distribution. The t distribution looks like the normal curve with fatter tails, which accounts for the extra uncertainty of estimating the SD from the sample itself. For large samples t* is essentially 1.96. For small ones it is larger: with 10 observations, the 95% t* is about 2.26. Spreadsheet functions like CONFIDENCE.T and every statistics library handle this for you.

Higher confidence means a wider interval: to be more certain of capturing the true value, you must cast a wider net.

Step 3 of 13Try the calculator

Confidence interval for a proportion

Enter the observed percentage and sample size. Use 1.645 for 90%, 1.96 for 95% or 2.576 for 99% confidence.

Margin of error
2.79 percentage points
Lower bound
39.2 %
Upper bound
44.8 %

Step 4 of 13Practice · Work it out

A random sample of 900 customers shows that 30% used a coupon. What is the 95% margin of error, in percentage points? Round to one decimal place.

Step 5 of 13Learn

What a confidence interval does and does not say

The formal meaning of a 95% confidence interval is about the method: if you repeated the sampling many times and built an interval each time, about 95% of those intervals would contain the true value. For practical work, it's reasonable to read an interval as "the range of values that are plausible given the data".

Common misreadings to avoid:

  • "95% of individual values fall in the interval." No. The interval is about the mean or the proportion, not about individuals. A 95% interval for average order value of $48 to $52 doesn't mean most orders cost $48 to $52; individual orders might range from $5 to $500.
  • "Values in the middle are certain, values at the edges impossible." The true value could be just outside the interval; the edges are not cliffs.
  • "If two intervals overlap, the groups are not different." Two intervals can overlap slightly while the difference between the groups is still statistically significant. To compare two groups, compute an interval for the difference directly, which you will do in the next lessons.

Intervals communicate better than single numbers. "Conversion rose by 0.6 points, with a 95% interval from 0.1 to 1.1 points" tells readers both the best estimate and how far off it might be, and it makes small samples look appropriately uncertain.

Step 6 of 13Practice · True or false

A 95% confidence interval for the mean delivery time of 2.8 to 3.2 days means that about 95% of individual deliveries take between 2.8 and 3.2 days.

Step 7 of 13Learn

How big a sample do you need?

You can turn the margin of error formula around to plan a study. For a proportion, the sample size needed for a margin of error E at 95% confidence is

n = 1.96² × p(1 − p) / E²

If you have no idea what p will be, use p = 0.5, which gives the largest, and therefore safest, sample size. For a margin of ±3 points: n = 3.8416 × 0.25 / 0.0009 ≈ 1,067. That is why so many national polls interview about 1,000 people.

The square-root law strikes again. Halving the margin to ±1.5 points requires four times the sample, about 4,300 people. A margin of ±1 point needs about 9,600. Before commissioning an expensive survey, ask what precision the decision really needs. If the choice is the same whether support is 40% or 46%, ±3 points is plenty.

Two cautions. First, these formulas assume a random sample. A sample of 10,000 people who chose to answer a pop-up survey can be far less accurate than 1,000 randomly selected people, because the people who answer pop-ups differ from those who don't. Second, if you plan to report results for subgroups, such as each of five regions, each subgroup needs enough people on its own; a margin of ±3 points nationally can become ±7 points within a region.

Step 8 of 13Practice · Work it out

You want to estimate a proportion with a margin of error of ±3 percentage points at 95% confidence and have no prior idea of its value. What is the minimum sample size? (Round up to a whole person.)

Step 9 of 13Explore

Margin of error vs. sample size

95% margin of error for a proportion, in percentage points. Watch how slowly it shrinks once the sample is large: quadrupling n only halves it.

0246810 1,0002,0003,000
Margin at n = 400
4.9 points
Margin at n = 1,600
2.5 points

Step 10 of 13Note

Step 11 of 13Practice · What would you do?

What would you do?

Two random surveys of 1,200 users each found that 42% and then 45% want a feature. Each has a 95% margin of error of about ±2.8 points. The head of product wants to announce that demand has grown. What is the most accurate summary?

Step 12 of 13Diagram

Two surveys, two overlapping intervals

Each estimate comes with a ±2.8-point margin. The ranges overlap almost completely.

Two surveys, two overlapping intervalsScale: Survey 1: 42%, Survey 2: 45%.Survey 1 onlyBoth intervalsSurvey 2 only38404244464842%Survey 1: 42%45%Survey 2: 45%

Tap a shape with to see more.

Survey 1: 42%

95% interval roughly 39.2% to 44.8%.

Survey 2: 45%

95% interval roughly 42.2% to 47.8%.

Step 13 of 13Practice · Choose one

An analyst changes a confidence interval from 95% to 99% confidence while keeping the same data. What happens?