How to use the sample size calculator
- Choose what you are estimating. “Percentage (survey)” is for yes-or-no answers. “Mean” is for measurements.
- Pick a confidence level and a margin of error. For a survey, the margin is in percentage points: ±5% means the result should land within 5 points of the true share. For a mean, enter the margin in the data’s own units, such as ±2 years.
- Enter what you expect. For a percentage, your estimate of the answer; leave it at 50% if you have no idea. For a mean, the standard deviation from a pilot study or earlier data.
The defaults, 95% confidence, ±5% and 50%, give the familiar answer of 385 responses. The cards also show the sample needed at other confidence levels, the sample for half the margin of error, and the margin you would get from 1,000 responses.
Sample size for a percentage
The margin of error for a proportion is z × √(p′(1 − p′) ÷ n), as on the confidence interval page. Solving it for n gives the formula in OpenStax’s Introductory Statistics 2e, section 8.3:
Here z is the critical value for the confidence level (1.645 for 90%, 1.96 for 95%, 2.576 for 99%), p′ is the expected proportion, and E is the margin of error as a decimal.
In Example 8.14, a phone company wants to be 90% confident that its estimate of the share of customers aged 50+ who text is within three percentage points. With no prior estimate it uses p′ = 0.5: n = 1.645² × 0.25 ÷ 0.03² = 751.67, so it should survey 752 customers. Enter 90%, ±3% and 50% to check.
With 95% confidence and ±5%, n = 1.96² × 0.25 ÷ 0.05² = 384.16, which rounds up to 385.
Why 50% is the safe guess
The product p′(1 − p′) is largest when p′ = 0.5: 0.5 × 0.5 = 0.25, while 0.6 × 0.4 = 0.24 and 0.3 × 0.7 = 0.21. The textbook notes that using 0.5 when you don’t know the proportion gives the largest sample, so the survey is large enough whatever the true answer turns out to be.
If you have good reason to expect a result far from 50%, say about 10% from last year’s survey, entering it reduces the sample. At 95% and ±5%, an expected 10% needs 139 responses instead of 385. If the real share turns out closer to 50%, though, the margin of error will be wider than planned.
Sample size for a mean
For a mean, solving the error bound z × σ ÷ √n for n gives (section 8.1):
Example 8.7 asks how many students to survey to be 95% confident that the sample mean age is within two years of the true mean, given a population standard deviation of 15 years. n = 1.96² × 15² ÷ 2² = 216.09, so the answer is 217.
You need an estimate of σ before collecting the data. The usual sources are a small pilot study, a previous study of the same kind, or published figures. If the estimate is too low, the final margin of error will be wider than the target, so a cautious, slightly larger guess is sensible.
Round up, not to the nearest
The formula rarely gives a whole number. The textbook’s rule is to round the answer up to the next whole number, even when the decimal is small: 216.09 becomes 217, not 216. Rounding down would leave the sample slightly too small to meet the margin of error you asked for. The calculator shows the unrounded value under the result so you can see the rounding.
Margin, confidence and cost
The margin of error enters the formula squared, so it has the biggest effect on the sample:
| Margin (95%, p′ = 50%) | Responses needed |
|---|---|
| ±10% | 97 |
| ±5% | 385 |
| ±3% | 1,068 |
| ±2% | 2,401 |
Halving the margin needs about four times the sample. Raising confidence from 95% to 99% at ±5% takes the sample from 385 to 664. The NIST/SEMATECH e-Handbook of Statistical Methods gives the same mean formula for planning measurements, N ≥ (1.96 ÷ δ)² × σ² at 95%, and notes that without a known standard deviation you need a good estimate, perhaps from a previous experiment.
This is also why national polls often settle around 1,000 responses: the “Margin with 1,000” card shows about ±3.1% at 95% confidence, and going much further costs a lot more for a small gain.
What the formula assumes
The formulas assume a simple random sample from a large population. They don’t correct for small populations; when you would be sampling a large fraction of a small group, such as most of a 300-person company, a statistician can apply a finite-population adjustment that lowers the count. They also count completed responses, not invitations. If you expect one person in four to answer, invite about four times as many as the calculator shows. And a big sample doesn’t fix a biased one: a survey that only reaches certain people will be precisely wrong.
Step by step at 99% confidence
Say you want ±5% at 99% confidence and have no prior estimate.
- Critical value: 99% leaves 0.5% in each tail, so z ≈ 2.576.
- Expected proportion: p′ = 0.5, so p′(1 − p′) = 0.25.
- Margin as a decimal: E = 0.05, so E² = 0.0025.
- Formula: n = 2.576² × 0.25 ÷ 0.0025 ≈ 663.6.
- Round up: 664 responses.
The extra confidence costs 279 more responses than the 95% plan, about 72% more work for the same margin of error.
Planning a measurement study
A coffee shop wants to estimate the average wait from order to pickup within ±30 seconds at 95% confidence. A one-day pilot of 20 orders had a standard deviation of about 2 minutes, or 120 seconds. Switch to “Mean”, enter 120 for σ and 30 for the margin: n = 1.96² × 120² ÷ 30² = 61.5, so the shop should time 62 orders. Keep the units consistent: if σ is in seconds, the margin must be in seconds too.
Halving the margin to ±15 seconds needs 246 orders, again about four times as many. If the pilot was small, its standard deviation is itself uncertain, so it is reasonable to round σ up a little before planning. Spread the timed orders across different days and hours as well; a sample taken only during the morning rush would measure the morning rush, not the shop’s typical wait.
Sources & assumptions
How this calculator gets its numbers. Full method: our methodology.
- Percentage: n = z² p(1 − p) ÷ E², with p = 50% giving the largest n when the true value is unknown.
- Mean: n = z² σ² ÷ E², with σ from earlier data or a pilot study.
- n is rounded up to the next whole number; the population is assumed large relative to the sample.
Sources
- OpenStax (Rice University), Introductory Statistics 2e, 8.1 A Single Population Mean Using the Normal Distribution. Error bound z·σ/√n (Example 8.2: 90% → (67.18, 68.82); Example 8.4: 95% → (67.02, 68.98)) and sample size n = z²σ²/EBM² (Example 8.7: 216.09 → 217).
- OpenStax (Rice University), Introductory Statistics 2e, 8.3 A Population Proportion. Proportion interval p′ ± z√(p′q′/n) (Example 8.10: 421 of 500; Example 8.11: 300 of 500 at 90% → (0.564, 0.636)), the plus-four method (Example 8.12) and sample size with p′ = 0.5 (Example 8.14: 752).
- National Institute of Standards and Technology, NIST/SEMATECH e-Handbook of Statistical Methods, 7.2.2.2 Sample sizes required. Minimum sample size for limiting the error in an estimated mean, given the confidence level and standard deviation.
Last reviewed . These are sample sizes for estimating, not for detecting a difference with a given power.
Frequently asked questions
How many survey responses do I need?
For a 95% confidence level and a ±5% margin of error, 385 responses, assuming no prior idea of the answer. For ±3%, about 1,068.
What is the sample size formula?
For a percentage, n = z² × p′(1 − p′) ÷ E². For a mean, n = z² × σ² ÷ E². Round the result up to the next whole number.
Why use 50% as the expected percentage?
It gives the largest required sample, so the survey is big enough whatever the real answer is.
Does the population size matter?
Very little for large populations; 385 responses give about ±5% for a city or a country. It matters only when you would sample a large share of a small group.
Should I round the sample size up or down?
Up. Rounding down leaves the margin of error slightly larger than your target.
How do I get the standard deviation before I collect data?
Use a pilot study, past data or published figures for similar measurements, and lean toward a larger value if unsure.