A news channel says that 52 percent of voters back a party, with a margin of error of 3 points. Many viewers hear this as a small footnote. It is actually the most important part of the claim, because it tells you whether 52 is really ahead of 48 or only looks ahead.
Every survey and every A and B test works with a sample, not the whole population. The margin of error measures how far the sample result may sit from the truth because of chance alone. It is the number after the plus or minus sign, and it is the half width of a confidence interval.
This tutorial explains the definition, the formula, a worked example with the answer, how sample size and confidence level change the margin, how to find the sample size you need, and what a margin of error does not cover. It ends with Python code and practice questions.
The margin of error is the range of values above and below a sample estimate, within which the true population value is likely to lie. A result of 52 percent with a margin of error of 3 points gives an interval of 49 to 55 percent.
An interval estimate is a range of values built around a sample estimate. The live page calls it a pair of percentages, which is not accurate. The range can be in any unit, such as hours, rupees or percent.

The live page says researchers choose members so that the margin is as small as possible. In practice, you cannot shrink it by hand picking people. You reduce it with a bigger random sample.
A sample result is a guess. Another sample would give a slightly different number. The margin of error shows how big that wobble is, so you can tell a real difference from noise.
For a mean, when the population standard deviation is known:
For a proportion, such as a poll percentage:
The live page stops at Margin of Error = z. That is not the formula.
| Confidence level | Z score | Used when |
|---|---|---|
| 90 percent | 1.645 | Quick checks |
| 95 percent | 1.960 | The usual default |
| 99 percent | 2.576 | High stakes, wider margin |
Always state the level with the margin. A margin of 3 points at 95 percent and at 99 percent are different claims.

The live page gives n = 160,000, sigma = 8.47 and z = 2.58, and no answer.
Meaning: at a 99 percent level (2.58 is the rounded z, the exact value is 2.576), the sample mean is likely within 0.0546 of the true mean. The margin is tiny because the sample is huge.
A poll of 1,000 voters finds 52 percent support for a party. The numbers are made up for teaching.
The interval includes 50 percent, so this poll cannot say that the party is truly ahead of the rest. A lead of 2 points is smaller than the margin.
| Sample size | Margin at 95 percent | Compared with n = 100 |
|---|---|---|
| 100 | 9.8 points | Base |
| 400 | 4.9 points | Half |
| 1,000 | 3.1 points | About a third |
| 2,400 | 2.0 points | About a fifth |
| 10,000 | 0.98 points | About a tenth |
These use the worst case, p = 0.5. Four times the data halves the margin, because of the square root of n. This is why polls stop near 1,000 to 2,500 people: the gain from going further is small compared with the cost.
With n = 1,000, a result near 50 percent has a margin of 3.1 points. A result of 30 percent has 2.84 points, and 10 percent has 1.86 points. Results near 0 or 100 percent are more certain.
Rearrange the formula. For a proportion at 95 percent, using p = 0.5 when you do not know the result:
| Target margin | Sample size needed | Note |
|---|---|---|
| 5 points | 385 | Rough surveys |
| 3 points | 1,068 | Common for polls |
| 2 points | 2,401 | Better precision |
| 1 point | 9,604 | Costly |
The margin of error covers random sampling error only. The live page says that the true value is usually near the estimate but might be a bit higher or lower, and cites Statistics Solutions with no link. I kept the idea, and wrote it in my own words.
They are two views of the same thing. The confidence interval is the estimate plus and minus the margin of error. For example, 52 percent with a margin of 3.1 points gives the interval 48.9 to 55.1 percent. If you know one, you know the other.
I ran the code below, and the output is real.
| Mistake | Fix |
|---|---|
| Giving a margin without a confidence level | State the level, usually 95 percent |
| Using the formula for a non random sample | The margin only holds for probability samples |
| Assuming a lead bigger than the margin is certain | Compare the gap with about twice the margin for two candidates |
| Forgetting that the margin shrinks slowly with n | Four times the sample halves the margin |
| Using the full poll margin for a subgroup | A subgroup has a larger margin |
| Using the rounded z without saying so | State the level, such as 95 percent with z 1.96 |
| Believing the margin covers all errors | It covers random sampling error only |
Answers: 1) 1.96 times 5 divided by 10 = 0.98. 2) 1.96 times the square root of (0.25 divided by 400) = 0.049, so 4.9 points. 3) 385. 4) No. The intervals overlap, so the race may be tied. These are my own answers, so please recheck them before publishing.
The margin of error is the honest half of any survey result. Always show it with the confidence level, use a random sample so it means something, and remember that it shrinks only with the square root of the sample size. A small gap between two numbers is often just noise.