TL;DR: The margin of error formula for a proportion is MoE = z × √(p × (1 − p) / n). The z-score comes from your confidence level (1.96 for 95%), p is the survey result as a decimal, and n is the sample size. A sample of 400 at 95% confidence gives a margin of error of about ±4.9%. Check any numbers with our free Margin of Error Calculator.
Every poll result comes with a hidden question: how far could the true answer be from this number? The margin of error formula answers it. It takes three inputs — a confidence level, a survey result and a sample size — and turns them into the familiar “plus or minus” figure you see after every poll. This guide explains the formula piece by piece, works through it with real numbers, and shows the version you need when your result is an average rather than a percentage.
If you only need the plain meaning of margin of error before the maths, start with our guide on margin of error explained. Here, the focus is the formula itself.
What is the margin of error formula?
For a survey result expressed as a proportion or percentage — a share of voters, customers or students who gave a particular answer — the formula is:
MoE = z × √(p × (1 − p) / n)
The formula has a clear logic. The part under the square root, p × (1 − p) / n, measures how much a sample result is expected to wobble by chance: it grows when the result is near a 50/50 split and shrinks as the sample grows. The square root turns that wobble into the standard error — the typical size of the random error in one sample. The z-score then stretches that typical error into an interval wide enough to capture the true value with the confidence you chose: about 95 times out of 100 for a z-score of 1.96.
That is all the formula does. It does not judge whether your sample was fair, whether your questions were well worded, or whether people answered honestly. It only measures random sampling error — the luck of which people happened to be picked.
What does each symbol in the formula mean?
Each symbol stands for one concrete number, and getting them right is most of the work.
| Symbol | Meaning | Example |
|---|---|---|
| z | z-score for the confidence level you want | 1.96 for 95% confidence |
| p | Sample proportion as a decimal | 0.52 for a result of 52% |
| n | Sample size — how many people answered | 400 respondents |
| MoE | Margin of error, as a decimal (multiply by 100 for %) | 0.049, or ±4.9% |
The z-score is the only symbol that does not come from your data. It is a fixed number set by the confidence level you choose. The three values used in almost all survey work are 1.645 for 90% confidence, 1.96 for 95% confidence and 2.576 for 99% confidence. A higher confidence level means a larger z-score and a wider margin of error — extra certainty is bought with extra width, and there is no way around that trade-off.
The proportion, p, is the survey result written as a decimal: 52% becomes 0.52, 30% becomes 0.30. The term p × (1 − p) is at its largest when p is 0.5, which is why pollsters often quote the margin of error for a 50/50 split. It is the worst case: if you do not know the result yet, or you want one margin of error that covers every question in a survey, p = 0.5 gives the largest — and therefore the safest — answer. Any other value of p gives a slightly smaller margin of error.
Worked example: a sample of 400 at 95% confidence
Suppose a survey asks 400 people a yes/no question and exactly half say yes, so p = 0.5. What is the margin of error at 95% confidence? Work through the formula with z = 1.96, p = 0.5 and n = 400.
- Find p × (1 − p). 0.5 × 0.5 = 0.25.
- Divide by the sample size. 0.25 / 400 = 0.000625.
- Take the square root. √0.000625 = 0.025. This is the standard error.
- Multiply by the z-score. 1.96 × 0.025 = 0.049, or ±4.9%.
So the result is reported as 50% ± 4.9%, meaning the true value is probably between 45.1% and 54.9%. Notice how tidy the arithmetic is at p = 0.5: the square root comes out to exactly 0.025, which is 1 / 20, and 1.96 / 20 is 0.098 / 2, or 0.049. That neatness is no accident — it is why textbook examples so often use a sample of 400.
A second example shows what changes when the result is not a 50/50 split. Suppose a survey of 1,000 customers finds that 60% are satisfied, and the confidence level is again 95%. Then p = 0.6, so p × (1 − p) = 0.6 × 0.4 = 0.24. Dividing by 1,000 gives 0.00024, and the square root is about 0.0155. Multiply by 1.96 and the margin of error is about 0.030, or ±3.0%. The result is 60% ± 3.0%, so the true satisfaction rate is probably between 57% and 63%. Compare that with a sample of 1,000 at p = 0.5, which gives ±3.1% — the 60% result is a little more precise, because it is further from the 50/50 split where the wobble is largest. Try both numbers in the margin of error calculator to confirm.
How the confidence level changes the answer
The z-score is the only part of the formula that depends on how sure you want to be, and it moves the answer directly. Take the same sample of 400 with p = 0.5 and see what happens at each confidence level.
| Confidence level | z-score | Margin of error (n = 400, p = 0.5) |
|---|---|---|
| 90% | 1.645 | ±4.1% |
| 95% | 1.96 | ±4.9% |
| 99% | 2.576 | ±6.4% |
Going from 95% to 99% confidence widens the margin of error from 4.9% to 6.4% — about a third wider — while going down to 90% narrows it to 4.1%. The standard error (0.025 here) does not change at all; only the multiplier does. This is why 95% became the default: it is a reasonable balance between a narrow interval and a high level of confidence, and it is the level almost every published margin of error is based on. If a margin of error is quoted without a confidence level, assume 95%.
Margin of error formula for a mean
Not every survey result is a percentage. Sometimes the result is an average — the average amount spent, the average time on a page, the average test score. For a mean, the formula has the same shape but uses the standard deviation instead of a proportion:
MoE = z × σ / √n
Here σ (sigma) is the standard deviation of the measurements, and n is again the sample size. Suppose a shop measures spending from 100 customers, the average is $42, the standard deviation is $12, and the confidence level is 95%. The square root of 100 is 10, so σ / √n = 12 / 10 = 1.2. Multiply by 1.96 and the margin of error is 2.35 — so the result is $42 ± $2.35, and the true average spend is probably between $39.65 and $44.35. If you need the standard deviation first, our standard deviation calculator works it out step by step.
The structure is the same in both versions: a z-score times a measure of spread, divided by the square root of the sample size. That square root is the reason quadrupling the sample only halves the margin of error — a pattern that holds for percentages and averages alike, and one worth remembering when you plan a survey. If you are working in the other direction, starting from the margin of error you want and finding the sample size it needs, use the sample size calculator, or Slovin’s formula when you know the size of the whole population.
Frequently Asked Questions
What is the margin of error formula?
For a proportion, the margin of error formula is MoE = z x square root of (p x (1 - p) / n), where z is the z-score for the confidence level, p is the sample proportion as a decimal, and n is the sample size.
What is the margin of error for a sample of 400 at 95% confidence?
About plus or minus 4.9%, assuming a proportion of 0.5. The calculation is 1.96 x square root of (0.25 / 400) = 1.96 x 0.025 = 0.049, or 4.9%.
What z-score should I use for 95% confidence?
Use 1.96 for 95% confidence. The other common values are 1.645 for 90% confidence and 2.576 for 99% confidence.
What is the margin of error formula for a mean?
For an average, the formula is MoE = z x standard deviation / square root of n. For example, with a standard deviation of 12, a sample of 100 and 95% confidence, the margin of error is 1.96 x 12 / 10 = 2.35.
Why is p = 0.5 used in the margin of error formula?
The term p x (1 - p) is at its largest when p is 0.5, so using 0.5 gives the largest — and therefore the safest — margin of error. Pollsters use it when the true proportion is unknown, because the real margin of error can only be smaller.