How it works
When you survey part of a group to learn about all of it, the answer you get carries some uncertainty: survey a different random sample and you’d get a slightly different result. The margin of error says how far off the result is likely to be, and the confidence level says how sure you can be of that.
This calculator works out how many people you need to survey to get a margin of error you choose, for a question with a yes or no answer (the share who agree, who’d buy, who voted). It can also work the other way: tell it how many people you surveyed, and it gives the margin of error.
If you know the size of the whole group (say, the 2,000 staff at a company), enter it, and the calculator adjusts for it. Otherwise leave it at 0: for a very large population the size barely matters.
The formula
For a very large or unknown population:
n₀ = z² × p × (1 − p) ÷ e²
- z is the z-score for the confidence level: 1.645 for 90%, 1.960 for 95%, and 2.576 for 99%. The calculator uses a more precise value (1.959964 for 95%).
- p is the proportion you expect, as a decimal. If you don’t know, use 0.5: it gives the biggest sample, so you’re covered whatever the answer turns out to be.
- e is the margin of error, as a decimal: ±5 percentage points is 0.05.
For a known population of N people, the finite population correction makes it smaller:
n = n₀ ÷ (1 + (n₀ − 1) ÷ N)
Then round up to the next whole person. Rounding down would leave the margin of error slightly bigger than you asked for.
Turned around, the margin of error for a sample of n people is e = z × √(p(1 − p) ÷ n), times √((N − n) ÷ (N − 1)) for a known population.
Worked example
Want this with your own numbers? See Show the work above.
You want 95% confidence and a margin of error of ±5 percentage points, and you have no idea what the answer will be, so p = 0.5.
- For 95% confidence, z = 1.959964.
- n₀ = 1.959964² × 0.5 × 0.5 ÷ 0.05² = 384.15.
- Rounded up, that’s 385 people for a very large population.
- If the population is 2,000: 384.15 ÷ (1 + 383.15 ÷ 2,000) = 322.39, so 323 people.
The other way: a survey of 400 people out of 2,000 at 95% confidence has a margin of error of 1.959964 × √(0.25 ÷ 400) × √(1,600 ÷ 1,999) = 0.0438, or ±4.38 percentage points.
FAQ
Why does 385 come up so often?
It’s the answer for a common set of choices: 95% confidence, a ±5 point margin of error, and p = 50%, for a very large or unknown population. Above about 1.01 million, the answer is 385. Smaller populations need fewer people (383 for 100,000, 323 for 2,000), because the correction matters more the bigger a share of the group the sample is.
Why use 50% for the expected proportion?
p × (1 − p) is biggest at p = 0.5, where it’s 0.25, so 50% always gives the largest sample. If you expect the answer to be lopsided, say about 10% yes, you can use that instead and survey fewer people: 139 instead of 385 at 95% and ±5 points.
Is the margin of error in percent or percentage points?
Percentage points. If 60% of your sample says yes with a margin of error of ±5, the true share is likely between 55% and 65%. The confidence level is how often a margin worked out this way catches the true value.
What if not everyone answers?
The sample size is the number of answers you need. If you expect only some people to reply, divide by the share you expect to answer: for 385 answers with a 25% response rate, invite 385 ÷ 0.25 = 1,540 people. The math also assumes the people who answer are a random sample. If some kinds of people are more likely to reply, a bigger sample won’t fix that.
When does the formula work well?
It relies on the normal approximation, which works when the sample has enough of both answers. A common rule of thumb is that n × p and n × (1 − p) should both be more than 5. For a very small sample, or a proportion very close to 0% or 100%, treat the margin of error as rough.
What about averages, like an average height or spend?
This calculator is for proportions, the share of yes or no answers. A sample size for an average uses a different formula, n = (z × σ ÷ e)², which needs an estimate of the standard deviation σ.
Sources
- The sample size formula for a proportion, using 0.5 when it’s unknown, rounding up, the margin of error (error bound) formula, and the rule that np’ and nq’ should both be more than 5, with a worked example (90% confidence within 3 points: 752): OpenStax, Introductory Statistics 2e, section 8.3, “A Population Proportion”
- The formula with a worked example (95% confidence, an interval 2 points wide: 9,604): Wikipedia, “Sample size determination”
- Cochran’s formula and the correction for a known population: Hasan and Kumar, “Determining Adequate Sample Size for Social Survey Research”, Journal of the Bangladesh Agricultural University 22(2):146-157 (2024)
- The finite population correction, √((N − n) ÷ (N − 1)): Wikipedia, “Standard error”
- The z-scores for each confidence level: NIST/SEMATECH e-Handbook of Statistical Methods, 1.3.6.7.1, “Cumulative Distribution Function of the Standard Normal Distribution”
Cite this page
APA (7th edition)
Mathlark. (2026, October 4). Sample size calculator. https://mathlark.com/statistics/sample-size-calculator/
MLA (9th edition)
"Sample Size Calculator." Mathlark, 4 Oct. 2026, mathlark.com/statistics/sample-size-calculator/.