Sample Size Calculator
Work out how many responses a survey needs, the margin of error your sample gives, or how many subjects per group a study needs to detect a difference with enough power.
Sample size formula for a survey
To estimate a percentage (how many people agree, prefer, own something) within a margin of error E:
n₀ = z² × p(1 − p) ÷ E²
| Symbol | Meaning |
|---|---|
| z | z-score for your confidence level (1.96 for 95%) |
| p | expected proportion; use 0.5 if you don’t know, which gives the largest n |
| E | margin of error as a decimal (5% = 0.05) |
Example at 95% confidence and ±5%: 1.96² × 0.5 × 0.5 ÷ 0.05² = 384.1, so you need 385 completed responses. Always round up.
| Margin of error (95% confidence) | Sample size |
|---|---|
| ±10% | 97 |
| ±5% | 385 |
| ±4% | 601 |
| ±3% | 1,068 |
| ±2% | 2,401 |
| ±1% | 9,604 |
Halving the margin of error takes four times the sample.
| Confidence level | z | Sample size at ±5% |
|---|---|---|
| 80% | 1.282 | 165 |
| 90% | 1.645 | 271 |
| 95% | 1.960 | 385 |
| 99% | 2.576 | 664 |
Small populations: the finite population correction
When you’re surveying a large share of a small group, you need fewer responses:
n = n₀ ÷ (1 + (n₀ − 1) ÷ N)
| Population (N) | Sample size (95%, ±5%) |
|---|---|
| 100 | 80 |
| 500 | 218 |
| 1,000 | 278 |
| 10,000 | 370 |
| 100,000 | 383 |
| Very large | 385 |
Beyond about 100,000 the population size barely matters, which is why national polls of about 1,000 people can describe a whole country. This is the same method online survey calculators use.
These are completed responses. If you expect 20% of invitations to be answered, invite five times as many people. A big sample doesn’t fix a biased one: who responds matters more than how many.
How to calculate the margin of error
E = z × √(p(1 − p) ÷ n)
A poll of 1,000 people at 95% confidence has a margin of error of 1.96 × √(0.25 ÷ 1,000) = ±3.1 percentage points. If 52% say yes, the true figure is likely between 48.9% and 55.1%.
Sample size to estimate a mean
n = (z × σ ÷ E)², where σ is the standard deviation (from a pilot study or earlier data) and E the margin of error in the same units. To estimate a mean test score within ±3 points when σ = 15, at 95% confidence: (1.96 × 15 ÷ 3)² = 96.04, so 97 people.
Power analysis: comparing two groups
For an experiment, choose the significance level (α, usually 0.05), the power (the chance of detecting a real effect, usually 80%) and the smallest effect worth detecting.
Two means: the effect size is Cohen’s d = difference ÷ standard deviation. Per group, roughly n = 2(z_α/2 + z_β)² ÷ d²; the calculator then refines it with the t distribution.
| Effect size (d) | Per group, 80% power | Per group, 90% power |
|---|---|---|
| 0.2 (small) | 394 | 527 |
| 0.5 (medium) | 64 | 86 |
| 0.8 (large) | 26 | 34 |
These are for a two-sided test at α = 0.05 and match G*Power’s exact results. The small, medium and large labels are Cohen’s conventions.
Two proportions: detecting a change from 50% to 60% at α = 0.05 with 80% power takes 388 per group (without a continuity correction).
Frequently asked questions
Why use 50% for the expected proportion?
p(1 − p) is largest at 0.5, so it gives the most conservative (largest) sample. If you know the answer is near 10% or 90%, you can use that and need fewer responses.
What’s the difference between confidence level and margin of error?
The margin of error is how wide the range around your result is; the confidence level is how often that range would contain the true value if you repeated the survey. 95% and ±5% is a common pairing.
How do I test the results afterward?
For differences between groups, use the p-value calculator, which runs t-tests and chi-square tests.