Sample Size for a Mean or Proportion, Explained
After reading this you can compute the minimum number of observations needed to estimate a mean or a proportion within a stated margin of error, and you can defend that number when someone asks where it came from.
What the calculator answers
You want to estimate something: the average delivery time in minutes, or the fraction of customers who renew. You cannot measure everyone, so you take a sample. The question is how large that sample must be so your estimate lands close to the truth.
"Close" means two things at once. First, a margin of error: how far the estimate may sit from the true value, for example \pm 2 minutes. Second, a confidence level: how often that promise holds across repeated samples, usually 95%. Give both, plus a rough guess about the spread of the data, and the required sample size follows from a short formula.
Here is the hook. To halve the margin of error you do not need twice the data. You need four times the data. Margin shrinks with the square root of n, so cutting it in half costs a factor of four. That single fact drives most of the surprises in survey and experiment budgets.
When to use it, and when not
Use this calculator when your goal is estimation: you want a number with an interval around it, and you are deciding how much data to collect before you start. It covers the two most common targets, a population mean and a population proportion.
Do not use it when your goal is a test, such as "is the new page's conversion higher than the old one?" That is a question about power and effect size, not margin of error. For a difference between two group means, go to Power & Sample Size for t-Tests. If you already have data and want the interval itself, use the Confidence Interval Calculator.
The formulas assume simple random sampling from a population large enough that one draw does not change the next. If you sample more than about 5% of a finite population, or if you cluster or stratify, the plain formula overstates the required n. Apply a finite population correction or a design effect.
The formula and the intuition
Start with the mean. A confidence interval for a mean has half-width
Here E is the margin of error, \sigma is the standard deviation of the data, n is the sample size, and z is the standard normal critical value for your confidence level (1.96 at 95%). Solve for n:
Read the three levers. A larger \sigma (noisier data) raises n. A smaller E (a tighter promise) raises n fast, because it sits squared in the denominator. A higher confidence level raises z, so it raises n too, but more gently.
For a proportion, the spread is not a separate input. A proportion p has variance p(1-p) built in, so
Because p(1-p) is largest at p = 0.5 (where it equals 0.25), using 0.5 gives the biggest, safest sample size when you have no prior estimate. If you know p is near 0.1, plug that in and the required n drops sharply.
A worked example for a mean
Estimating average handling time within two minutes
A support team wants the average call handling time to within \pm 2 minutes at 95% confidence. A pilot of past calls suggests a standard deviation of about 15 minutes. These are the demo values: margin = 2, sd = 15.
- Pick the critical value. At 95% confidence, z = 1.96.
- Form the ratio inside the square: \frac{z \cdot \sigma}{E} = \frac{1.96 \times 15}{2} = 14.7.
- Square it: 14.7^2 = 216.09.
- Round up, always, because you cannot sample a fraction of a person:
n = 217.
So 217 calls give you an average accurate to within two minutes, 19 times out of 20. Now stress-test it. If the true spread turns out to be 20 minutes instead of 15, redo step 2 with \sigma = 20: (1.96 \times 20 / 2)^2 = 384.2, so n = 385. A one-third error in \sigma nearly doubles the sample. That is why a good pilot estimate matters.
A worked example for a proportion
A survey with a three point margin
You want to estimate the share of users who would recommend a product, to within \pm 0.03 (three percentage points) at 95% confidence, with no prior guess for p.
- Use the conservative p = 0.5, so p(1-p) = 0.25.
- Numerator: z^2 \, p(1-p) = 1.96^2 \times 0.25 = 0.9604.
- Divide by E^2 = 0.03^2 = 0.0009: 0.9604 / 0.0009 = 1067.1.
- Round up:
n = 1068.
Now suppose you knew from an earlier survey that p is close to 0.1. Then p(1-p) = 0.09, the numerator becomes 1.96^2 \times 0.09 = 0.3457, and n = 0.3457 / 0.0009 = 385. Knowing that the proportion is far from 0.5 cut the sample from 1068 to 385.
Reading and interpreting the result
The output is a floor, not a target with slack. If the calculator returns 217, then 217 completed, usable observations are the minimum. Plan for nonresponse and dropout on top of that. If you expect 80% of contacted people to answer, contact 217 / 0.8 \approx 272.
The confidence level describes the procedure, not any single interval. "95% confidence" means that if you repeated the whole study many times, about 95% of the intervals you build would cover the true value. The interval you actually got either covers it or does not; the 95% is the long-run hit rate of the method.
Sample size scales with the square of the confidence multiplier. Going from 95% (z = 1.96) to 99% (z = 2.576) multiplies n by (2.576/1.96)^2 \approx 1.73. In the mean example that pushes 217 up to 375. Decide whether the extra certainty is worth 73% more data.
Common mistakes
- Confusing the margin with a percentage
- For a proportion, a margin of "3 percent" means
E = 0.03, notE = 3. Feeding in 3 asks for an impossible precision and returnsn = 1or less. - Guessing sigma too low
- Because \sigma enters squared, an optimistic guess quietly undersizes the study. Use the upper end of a plausible range, or the standard deviation from a pilot.
- Rounding down
- Always round
nup. 216.09 becomes 217, never 216. Rounding down leaves the margin slightly wider than promised. - Using the mean formula for a proportion
- A proportion carries its own variance p(1-p). Do not invent a separate \sigma for it; switch the mode instead.
- Ignoring a small population
- If the target population is only 400 people and the formula asks for 385, you barely gain from sampling; apply the finite population correction, which here drops the needed
nto about 196.
Related tools
Once you have collected the data, build the interval itself with the Confidence Interval Calculator, which offers z and t intervals for a mean and Wald and Wilson intervals for a proportion. If you are comparing two groups rather than estimating one quantity, size the study with Power & Sample Size for t-Tests, express the target difference as a standardized effect with the Cohen's d Effect Size Calculator, and translate between effect measures using the Effect Size Converter.
Frequently asked questions
Why does the answer not depend on the population size?
For large populations it barely does. The precision of a mean depends on how many observations you take, not on how many exist. Only when your sample is a big fraction of the population (over 5%) does the finite population correction start to matter.
What value of p should I use if I have no idea?
Use 0.5. It maximizes p(1-p) at 0.25 and therefore gives the largest, safest sample size. Any other value needs fewer observations, so 0.5 never leaves you short.
How do I get an estimate of sigma before collecting data?
Use a small pilot sample, a previous study, or a rough range rule: for roughly bell-shaped data, \sigma \approx (\text{max} - \text{min}) / 4. Lean toward the larger estimate so you do not undersize.
Can I use this for the margin reported on a poll?
Yes, in reverse. A national poll reporting \pm 3 points at 95% with n near 1068 is exactly the proportion example above with p = 0.5.
Why 1.96 and not 2?
1.96 is the exact standard normal value that puts 2.5% in each tail, leaving 95% in the middle. People round it to 2 for mental math, which inflates n by about 4%: (2/1.96)^2 \approx 1.04.