MathsStatistics & Probability

Sample Size
calculator.

Work out how many survey replies you need, or the margin your replies give you.

How it's worked out

You decide how close the answer must be, called the margin of error EE, and how sure you want to be, called the confidence level. The confidence level sets zz, a value from the normal curve: 1.645 at 90%, 1.96 at 95%, and 2.326 at 98%. For a share of people, such as those who would recommend you, the size comes from this formula, where pp is the share you expect.

n0\displaystyle n_0=z2p(1−p)E2\displaystyle {}= \frac{z^2 \, p(1 - p)}{E^2}

For a mean, such as average weight, the spread takes the place of the share. σ\sigma is the standard deviation, which you take from a pilot study, past data or a published figure. NIST notes that this formula needs σ\sigma to be known, so an earlier estimate has to stand in for it.

n0\displaystyle n_0=(zσE)2\displaystyle {}= \left(\frac{z \sigma}{E}\right)^2

If you know the population is small, such as 800 staff, the finite population correction reduces the size, because each reply covers more of the group. NN is the population.

n\displaystyle n=n01+n0−1N\displaystyle {}= \frac{n_0}{1 + \frac{n_0 - 1}{N}}

The last step is to round up, always, so the margin is met. This tool keeps n0n_0 unrounded until then, because rounding it early can add a reply you do not need.

Run the other way, the same algebra gives the margin for a sample you already have. The second root is the correction, and you leave it out when the population is very large.

E\displaystyle E=zp(1−p)nN−nN−1\displaystyle {}= z \sqrt{\frac{p(1 - p)}{n}} \sqrt{\frac{N - n}{N - 1}}

Worked examples

A national poll that wants ±3 points

With no earlier figure to go on, the pollster uses p=0.5p = 0.5. At 95% confidence, the formula gives 1,067.07 before rounding, so the poll needs 1,068 completed replies. Put that back in the margin formula and you get ±2.999%, just inside the ±3% target.

At 90% confidence the same ±3 points takes only 752, the figure OpenStax reaches in its phone company example. The poll is paying about 316 extra replies for the higher confidence.

Open this example in the tool

Rosa surveys a company of 800

Rosa wants ±5 points at 95% confidence. For a very large group, that takes 385 replies. Her group has 800 people, so the correction brings it down to 260, or 33% of the staff.

She expects 30% to reply, so she has to invite 867. That is more than the 800 she has, so even asking everyone will not get her there. She needs a higher reply rate or a wider margin, and it is better to learn that before sending anything.

Open this example in the tool

Average weight to within 1 kg

Past data put the standard deviation at about 8 kg, and the target is ±1 kg at 95% confidence. The formula gives 245.85, which rounds up to 246 people. If the spread turns out larger than 8 kg, the real margin will be wider than 1 kg, so a cautious planner rounds the 8 up.

Open this example in the tool

Reading your result

The size grows with the square of the precision. Halving the margin from ±5% to ±2.5% takes the size from 385 to 1,537, about four times as many. The reverse holds as well: 400 replies give ±4.9%, and 1,000 replies only narrow that to ±3.1%.

Confidence costs less than precision. Going from 95% to 99% takes ±5 points from 385 to 664 replies, because zz rises from about 1.96 to 2.58 and is squared.

The margin applies to the whole sample. Pew Research Center gives the example of a 1,067-person poll, good for about ±3 points, with a subgroup of about 160 at about ±8. This tool gives ±3% and ±7.7% for those sizes. Pew adds that the margin for the gap between two candidates is about twice the margin for one.

Population size stops mattering quickly. At ±5% and 95% confidence, a population of 500 needs 218, 1,000 needs 278, 10,000 needs 370, 100,000 needs 383. Above a few tens of thousands, the size barely moves.

This tool sizes a sample for a precise estimate of one figure. To detect a difference between two groups, use the power analysis calculator, which also takes the power you want.

Common mistakes

  • Counting invitations as replies. Every formula here counts completed replies. Divide by the share you expect to answer, and do it at the planning stage.
  • Assuming a large sample fixes bias. The formulas assume a random sample. A thousand volunteers from one website can still be badly unrepresentative, and no margin of error covers that.
  • Ignoring a clustered or weighted design. Pew points out that weighting makes the margin larger. A design effect of 1.25 means a sample of 1,000 is only as precise as a simple random sample of 800, so at 1.5 the 385 becomes 578.
  • Trusting the formula at an extreme share. With an expected share of 2%, the ±5% formula asks for only 31 replies, and a margin of 5 points is larger than the share itself. Ask for a much smaller margin when the share is small.

Questions people ask

The term p(1 − p) is largest at a share of 50%, so that choice gives the largest sample and is safe whatever the truth turns out to be. If an earlier survey found about 10%, using it brings the size down from 385 to 139. Be sure of that figure first, as a wrong guess leaves your margin wider than planned.

Sources