Why Sample Size Matters
Sample size sets how precise an estimate is and how likely a test is to detect a real effect. A survey of 100 people has a margin of error of ±9.8%, while a survey of 1,000 has ±3.1%. A test with too few subjects misses real effects, and a test with far too many wastes money and time. The sample size calculator covers both cases: surveys (margin of error method) and hypothesis tests (power method). Run the finished analysis with the Z Test Calculator.
Sample Size for Surveys (Margin of Error Method)
The margin of error method finds the n that gives a target ± range at a chosen confidence level.
Formula for a Proportion
For 95% confidence (z* = 1.96), p = 0.5 and E = 0.05: n₀ = 3.8416 × 0.25 / 0.0025 = 384.16, so 385 respondents. For a mean, use n₀ = (z* × σ / E)².
Adjusting for Population Size
The finite population correction lowers n when the population (N) is small. For N = 2,000, the 385 respondents fall to 323.
Sample Size for Hypothesis Tests (Power Method)
The power method finds the n per group that detects a chosen effect with a chosen probability (power), usually 80%.
Comparing Two Means
To detect a difference of δ = 5 points with σ = 15, α = 0.05 (two-sided) and 80% power: n = 2 × (1.960 + 0.842)² × 225 / 25 = 141.3, so 142 per group.
Comparing Two Proportions (A/B Tests)
p̄ is the average of p₁ and p₂. Detecting a rise from 10% to 12% at α = 0.05 with 80% power needs 3,841 visitors per variant.
Inputs Explained: Confidence, Power, Effect Size
A sample size calculation uses 4 inputs:
- Confidence level (or α): 95% (α = 0.05) is standard; higher confidence needs a larger n.
- Power (1 − β): the chance of detecting a real effect; 80% is the usual minimum, and Jacob Cohen proposed it as a convention in 1988.
- Effect size: the smallest difference worth detecting, such as δ = 5 points or 10% → 12%.
- Variability: σ for means, or p for proportions.
How to Use the Sample Size Calculator
To use the sample size calculator, follow 3 steps:
- Choose the study type: a survey proportion, a survey mean, a test of two means or a test of two proportions.
- Enter the margin of error and p (or σ) for surveys, or the effect to detect and the power for tests.
- Set the confidence level or α, and add the population size N for surveys when it is small.
The bar chart shows the required n at each confidence level (or α), and the dot grid shows how many people that is.
Survey Sample Size Table (common population sizes at 95% ± 5%)
| Population size | Sample size |
|---|---|
| 100 | 80 |
| 500 | 218 |
| 1,000 | 278 |
| 2,000 | 323 |
| 5,000 | 357 |
| 10,000 | 370 |
| 100,000 | 383 |
| 1,000,000 or more | 385 |
Sample Size Examples
There are 2 worked examples below.
Example 1: Customer Survey
A company with 2,000 customers wants a ±5% margin at 95% confidence.
- Unadjusted nn₀ = 1.96² × 0.25 / 0.05² = 384.16
- Population correctionn = 384.16 / (1 + 383.16 / 2000) = 322.4
- Sample size323 customers (plan for more if response rates are low)
Example 2: A/B Test With a 2% Minimum Detectable Effect
A checkout converts 10%. Detect a rise to 12% (2 points) at α = 0.05 with 80% power.
- Critical valueszα/2 = 1.960, zβ = 0.842
- Pooled p̄(0.10 + 0.12) / 2 = 0.11
- Sample size3,841 visitors per variant, 7,682 in total
Choosing an Effect Size
Choose the effect size from the smallest difference that matters in practice, not from the effect you hope for. Cohen's benchmarks for d are 0.2 (small), 0.5 (medium) and 0.8 (large); a small effect needs about 393 people per group for 80% power at α = 0.05, a large one about 25. Convert means and SDs into d with the effect size calculator.
FAQs
Is a sample of 30 always enough?
No, 30 is a rule of thumb for the Central Limit Theorem, not a sample size target. A survey of 30 has a margin of error of about ±18%, and a test with 30 per group detects only large effects (d ≈ 0.72 at 80% power). Calculate the n your question needs.
What should I do if I can't reach the required sample size?
Report the precision you can reach, and treat the study as exploratory. A smaller sample widens the margin of error and lowers power. Present confidence intervals instead of only p-values, and consider pooling data across time or sites.
How do I allow for non-response?
Divide the required sample by the expected response rate. For 323 completed surveys and a 25% response rate, invite 323 / 0.25 = 1,292 people.
Why does a very large population barely change the sample size?
A very large population barely changes the sample size, since precision depends on n, not on the share of the population sampled. 385 respondents give ±5% for a city of 100,000 or a country of 300 million. The finite population correction matters only when the sample is a sizeable share of N.
What is post-hoc power, and should I use it?
Post-hoc power is power calculated from the observed effect after a study, and it adds no information beyond the p-value. A non-significant result always has low post-hoc power. Plan power before the study, and report confidence intervals afterwards. Test the resulting data with the two sample z test calculator or the two proportion z test calculator, and check survey precision with the margin of error calculator.