Tool for measuring the margin of error (confidence interval) associated to a survey (and assess its repeatability).
Margin of Error - dCode
Tag(s) : Statistics
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
A margin of error is an estimate of a confidence interval statistically limiting the errors in the raw results of a sampling/survey. The margin of error is based on a level of confidence (usually 95% or 99%) to define the value of the quality of the survey (degree of credibility, associated degree of uncertainty, excluding any selection bias).
The formula for the margin of error is $$ ME = z \times \frac{\sigma}{\sqrt{N}} $$ with $ z $ the confidence level, $ \sigma $ the deviation- population type, $ N $ the sample size.
For a survey with $ N $ respondents, a result having received $ f $ responses, (i.e. a probability $ p = f/N $), then the margin of error (standard error) with a confidence level of 95% is $$ \pm 1.96\frac{\sqrt{p(1-p)}}{\sqrt{N}} $$
The value of 1.96 is that of the 2.5 percentile of the normal distribution (for a 99% confidence level, replace with 2.58).
Example: A survey with a sample of 50 people, 30 of whom said they voted NO. The probability of the NO vote is $ 30/50 = 0.6 $. The margin of error (at 95%) is $ \pm 1.96\frac{\sqrt{0.6(1-0.6)}}{\sqrt{50}} = \pm 6.8 $ (or 13.6%). The interpretation is therefore a margin of error of 13.6% relative to the result of 60%. So, there is a 95% chance that the result NO will indeed be between 46.4% and 73.6%.
To reduce / improve the margin of error, increase the number of survey participants.
The margin of error formula shows that the margin of error decreases as the sample size increases.
The confidence level is a probability that indicates the reliability of a result.
A common confidence level is 95%, which means that if the study is repeated several times, the results obtained will fall within the calculated margin of error 95% of the time.
For a confidence level of 95%, use the value $ z = 1.96 $.
For a confidence level of 99%, use the value $ z = 2.58 $.
The margin of error is an estimate of the error associated with a result ($ \pm x $ errors or $ \pm x \% $ error).
The confidence interval is the range of values within which the true population value is likely to lie.
The confidence interval is calculated by adding and subtracting the margin of error from the sample result.
Example: If the sample result is 50% with a margin of error of 3%, the confidence interval is the range [47%, 53%].
dCode retains ownership of the "Margin of Error" source code. Any algorithm for the "Margin of Error" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Margin of Error" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Margin of Error" or any other element are not public (except explicit open source licence like Creative Commons). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.
The content of the page "Margin of Error" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source.
Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).
To cite dCode.fr on another website, use the link:
In a scientific article or book, the recommended bibliographic citation is: Margin of Error on dCode.fr [online website], retrieved on 2025-04-16,