Margin of Error Formula Explained (With Worked Examples)
By Shihab Mia June 27, 2026 10 min read
Quick answer
For a proportion, margin of error = z x square root of (p(1 - p) / n). Here p is the sample proportion (use 0.5 for the largest, safest margin), n is the sample size, and z is the critical value (1.96 for 95 percent confidence). For a mean, swap in the standard deviation: margin of error = z x (standard deviation / square root of n). The margin shrinks as the square root of n grows, so to halve it you need roughly four times the sample.
When a poll says a candidate is at 52 percent "plus or minus 3 points," that 3 points is the margin of error (MOE). It is the cushion of uncertainty around a sample result, a way of admitting that you measured a slice of the population, not all of it. Get the formula right and you can read any survey honestly. Get it wrong and you will either overclaim precision you do not have or panic over differences that are pure noise.
This guide breaks the margin of error formula into plain pieces, walks through worked examples for both a proportion and a mean, shows when to reach for a t value instead of z, and explains exactly why bigger samples help less than people expect.
What the margin of error formula actually is
There are two versions you will meet most often, depending on what you are measuring. If you are measuring a percentage or proportion (the share of people who say yes, click, or prefer option A), use this:
Margin of error for a proportion
MOE = z x square root of ( p(1 - p) / n )
If you are measuring an average (mean height, mean spend, mean response time), use the version built on the standard deviation:
Margin of error for a mean
MOE = z x ( standard deviation / square root of n )
Both formulas share the same skeleton: a critical value z that sets your confidence level, multiplied by a measure of spread, divided by the square root of the sample size. That middle-and-right part, the spread divided by the square root of n, is the standard error, and z simply scales it up to your chosen confidence. The MOE is one half of the full confidence interval, so the interval runs from your estimate minus the MOE to your estimate plus the MOE. If you want the full picture of that range, see our companion guide on the confidence interval formula.
Breaking down each ingredient
z, the critical value
The z value comes from the normal distribution and encodes how confident you want to be. A higher confidence level means a wider margin, because you are casting a bigger net to be more certain the truth falls inside it. These are the values you will use almost every time:
Common confidence levels and their z critical values
| Confidence level | z value |
|---|---|
| 80 percent | 1.28 |
| 90 percent | 1.645 |
| 95 percent | 1.96 |
| 98 percent | 2.33 |
| 99 percent | 2.576 |
When in doubt, use 1.96 for 95 percent confidence. It is the industry default for polling and most reporting.
z versus t for small samples
The z values above assume either a large sample or a known population spread. When you estimate a mean from a small sample (a rule of thumb is fewer than about 30 responses) using only the sample standard deviation, the normal curve understates the true uncertainty. Swap z for a t critical value from the t-distribution with n - 1 degrees of freedom. The t value is always a little larger than z, widening the margin to cover the extra guesswork. At 95 percent confidence with 10 observations you would use t = 2.262 instead of 1.96. As the sample grows, t slides back toward z, so for hundreds of responses the two are practically identical and the simple z formula is fine.
p, the sample proportion
For the proportion formula, p is the share you measured, written as a decimal. If 240 of 400 people said yes, p is 0.6. The term p(1 - p) is the variability of a yes or no answer, and it is largest exactly when p equals 0.5. That is why pollsters often plug in p = 0.5: it gives the most conservative, widest margin, so the real margin can only be smaller. If you do not yet know p, 0.5 is the safe planning assumption.
n, the sample size
n is how many people or items you sampled. It sits under a square root, which is the single most important fact about margin of error: the margin shrinks in proportion to 1 / square root of n. Doubling your sample does not halve the margin. To cut the margin in half you need about four times the sample, and to cut it to a third you need about nine times. This is the law of diminishing returns that makes very tight polls expensive, and it is why we give the sample-size trade-off its own section below.
Worked example: a proportion
Suppose you survey 1,000 voters and 520 of them (52 percent) back a measure. You want a 95 percent margin of error.
- Write down the inputs: p = 0.52, n = 1000, and z = 1.96 for 95 percent confidence.
- Compute p(1 - p): 0.52 x 0.48 = 0.2496.
- Divide by n: 0.2496 / 1000 = 0.0002496.
- Take the square root: square root of 0.0002496 is about 0.0158.
- Multiply by z: 1.96 x 0.0158 = about 0.031, which is 3.1 percent.
- Report it: 52 percent plus or minus 3.1 points, so the true support is likely between about 48.9 and 55.1 percent.
Notice the interval crosses 50 percent, so even though your sample leans yes, you cannot confidently claim a majority. That is the kind of judgment the margin of error is designed to protect. It is also why careful analysts call a lead inside the margin a "statistical tie" rather than a real advantage.
Worked example: a mean
Now suppose you measure the average checkout time on a website. From 144 sessions you find a standard deviation of 30 seconds, and you want 95 percent confidence. Because the sample is well above 30, the z value is safe to use here. (If you are shaky on averages first, our guide on how to calculate an average covers the basics.)
- Inputs: standard deviation = 30, n = 144, z = 1.96.
- Square root of n: square root of 144 = 12.
- Standard error: 30 / 12 = 2.5 seconds.
- Multiply by z: 1.96 x 2.5 = 4.9 seconds.
- So your mean checkout time is accurate to about plus or minus 4.9 seconds at 95 percent confidence.
That middle quantity, standard deviation divided by the square root of n, is the standard error, the engine inside both formulas. We cover it in depth in our standard error guide. One warning: the standard deviation you plug in must describe the raw data, not an already-averaged figure, or your margin will come out far too small.
Why do bigger samples help less and less?
Bigger samples always shrink the margin, but the payoff fades because n sits under a square root, so returns diminish quickly. The table below holds p at 0.5 and confidence at 95 percent so you can watch the margin flatten out as the sample climbs.
Margin of error at 95 percent confidence, p = 0.5
| Sample size n | Approx. margin of error |
|---|---|
| 100 | 9.8 percent |
| 400 | 4.9 percent |
| 1,000 | 3.1 percent |
| 1,600 | 2.5 percent |
| 4,000 | 1.5 percent |
Going from 100 to 400 (four times the work) halves the margin from 9.8 to 4.9 percent. Going from 1,000 to 4,000 (also four times the work) only buys you a drop from 3.1 to 1.5 percent. That trade-off is exactly why most national polls settle around 1,000 to 1,500 respondents: it is the sweet spot before precision gets expensive. The Pew Research Center confirms the arithmetic, noting that a random sample of about 1,067 people carries a margin of roughly plus or minus 3 points, and that even a perfectly executed poll still carries this built-in sampling error.
How do you choose a sample size for a target margin?
To hit a target margin, rearrange the proportion formula to n = z squared x p(1 - p) / MOE squared, then round up. Use p = 0.5 for the safe, largest estimate, keep z at 1.96 for 95 percent confidence, and write the target margin as a decimal. Here is the calculation for a 3 percent target.
- Pick your target margin, say 3 percent, and write it as 0.03.
- Square z: 1.96 x 1.96 = 3.8416.
- Multiply by p(1 - p): 3.8416 x 0.25 = 0.9604.
- Square the margin: 0.03 x 0.03 = 0.0009.
- Divide: 0.9604 / 0.0009 = about 1,067, so you need roughly 1,100 responses.
The table below shows the sample size you need for common target margins at 95 percent confidence, using the conservative p = 0.5. It makes the diminishing returns concrete: chasing a 1 percent margin costs nearly ten times the sample of a 3 percent margin.
Sample size needed for a target margin of error (95 percent, p = 0.5)
| Target margin of error | Sample size n needed |
|---|---|
| 5 percent | about 385 |
| 4 percent | about 600 |
| 3 percent | about 1,067 |
| 2 percent | about 2,401 |
| 1 percent | about 9,604 |
Because you cannot survey a fraction of a person, always round the result up. If your best guess of the true proportion is far from 0.5 (say a rare 5 percent yes rate), you can plug that real p in instead and the required sample drops, but 0.5 keeps you safe when you are unsure. Plan for non-response too: if you expect only half your invitations answered, send out roughly twice the target n.
Common mistakes to avoid
- Treating the margin as the whole story. MOE only captures sampling error, the randomness of who you happened to ask. It says nothing about biased questions, bad sampling frames, or people who lied. Pew Research warns that once these other errors are added in, the real total error in a poll can be close to twice the reported margin, so treat the stated number as a floor, not a ceiling.
- Forgetting it is plus and minus. A 3 point margin means the interval spans 6 points total. When you compare two results, the gap has to clear the combined margins of both before you can call the difference real.
- Using the wrong critical value. A 90 percent and a 99 percent margin are not the same, and a small sample needs t, not z. Always state your confidence level alongside the number.
- Writing p as a percent in the formula. Use 0.52, not 52, or your math will blow up. Convert percentages to decimals first, the same way you would in any percentage calculation.
- Assuming a huge population needs a huge sample. For large populations, the margin depends on n, not on the population size. A good 1,200 person sample works for a city or a whole country.
Good to know: the finite population tweak
When your sample is a large fraction of a small population (say you survey 200 of 500 club members), the standard formula slightly overstates the margin. Statisticians multiply by a finite population correction factor to shrink it. For the surveys most people run, where the population dwarfs the sample, this correction is tiny and safely ignored. Reach for it only when your sample exceeds about 5 percent of the whole group.
๐ Try the free tool Margin of Error Calculator Free margin of error calculator for surveys and polls. Enter your sample size, confidence level, and proportion to get the MOE percent and confidence interval.The margin of error formula is short, but it carries a big idea: every sample-based number is really a range, and the honest thing to do is report that range. Know your critical value, plug in the spread and n, and you can read any poll or experiment without being fooled by noise or false precision. Use 1.96 and p = 0.5 when you want the safe, conservative answer, switch to a t value for small samples, and reach for the calculator above to skip the arithmetic.
Frequently asked questions
What is the margin of error formula in simple terms?
For a proportion it is z times the square root of p times (1 minus p) divided by n. In words, take your critical value for the confidence level, multiply it by the spread of the data, and divide by the square root of the sample size. The result is the plus or minus cushion around your estimate.
Why is 0.5 used for p in the margin of error formula?
The term p times (1 minus p) reaches its maximum value when p equals 0.5. Plugging in 0.5 therefore produces the largest possible margin of error for a given sample size. That makes it the safe, conservative choice when you do not yet know the true proportion or want a worst case estimate.
How does sample size affect the margin of error?
Sample size sits under a square root, so the margin shrinks in proportion to one over the square root of n. To cut the margin in half you need about four times the sample, and to cut it to a third you need about nine times. Bigger samples always help, but with steeply diminishing returns.
What z value should I use for 95 percent confidence?
Use 1.96 for 95 percent confidence. Other common values are 1.645 for 90 percent, 2.33 for 98 percent, and 2.576 for 99 percent confidence. The higher the confidence level, the larger the z value and the wider the resulting margin of error around your estimate.
When should I use t instead of z for the margin of error?
Use a t critical value when you estimate a mean from a small sample, roughly fewer than 30 observations, and you only have the sample standard deviation. The t value is slightly larger than z, which widens the margin to reflect the extra uncertainty. For large samples t and z are almost identical, so z is fine.
Is margin of error the same as the confidence interval?
Not quite. The margin of error is one half of the confidence interval. The full interval runs from your estimate minus the margin to your estimate plus the margin. So a result of 52 percent with a 3 point margin gives a confidence interval of roughly 49 to 55 percent.
How do I find the margin of error for a mean instead of a proportion?
Use margin of error equals z times the standard deviation divided by the square root of n. Multiply your critical value by the standard deviation of your data, then divide by the square root of the sample size. This version applies whenever you are estimating an average rather than a percentage.
Does margin of error apply to online opt-in or non-random samples?
Strictly, no. The margin of error formula assumes a random probability sample. For opt-in web panels, social media polls, or convenience samples, a reported margin can be misleading because selection bias, not just sampling randomness, drives the error. Treat any margin on a non-random sample as a rough guide at best.