The formula, and where each piece comes from
n = z² × p × (1 - p) / e²
- z — the z-score corresponding to your desired confidence level (1.96 for 95%, 2.576 for 99%), derived from the normal distribution's quantile function.
- p — the estimated proportion you're measuring (use 50% if genuinely unknown).
- e — your desired margin of error, expressed as a decimal (5% margin = 0.05).
This formula comes directly from the normal approximation to a proportion's sampling distribution — it's asking "how large does my sample need to be so that, at my chosen confidence level, my estimate lands within e of the true value?"
This is Cochran's formula for a proportion, the one survey researchers mean by "the sample size formula".
| Confidence | z |
|---|---|
| 90% | 1.645 |
| 95% | 1.960 |
| 99% | 2.576 |
Worked example
A school with 2,000 students wants to estimate the share who use the library weekly, within ±5 percentage points at 95% confidence. Nobody knows the share, so use p = 0.5.
1. Infinite-population size. n₀ = 1.96² × 0.5 × 0.5 ÷ 0.05² = 3.8416 × 0.25 ÷ 0.0025 = 384.2, which rounds up to 385. (Always round up: 384 would fall just short of the margin you asked for.)
2. Correct for the population of 2,000. n = 384.2 ÷ (1 + 383.2 ÷ 2000) = 384.2 ÷ 1.1916 = 322.4 → 323 students.
3. Allow for non-response. If only about 60% of students will answer, invite 323 ÷ 0.6 ≈ 539. The formula gives completed responses, so dividing by the expected response rate is a step people often forget.
If an earlier survey had found about 20% library users, p = 0.2 would cut n₀ to 246, but only use a prior estimate you trust.
Why 50% is the safest assumption for an unknown proportion
The term p × (1 - p) is maximized exactly at p = 50% (0.5 × 0.5 = 0.25, larger than any other combination like 0.3 × 0.7 = 0.21 or 0.1 × 0.9 = 0.09). Since this term directly drives the required sample size upward, assuming 50% when the true proportion is unknown gives the largest, most conservative sample size estimate — guaranteeing your margin of error holds even in the worst case, rather than under-sampling based on an optimistic guess.
Why the margin of error matters more than people expect
Because e appears squared in the denominator, halving your desired margin of error doesn't double the required sample size — it quadruples it. Going from a 5% margin to a 2.5% margin requires 4× the sample size, not 2×. This nonlinear relationship is exactly why tightening precision requirements gets expensive fast, and why researchers often accept a slightly wider margin of error rather than pay the steep sample-size cost of a marginally tighter one.
5% margin, 95% confidence, p=50%: n ≈ 385
2.5% margin, same confidence/p: n ≈ 1,537 (roughly 4×, not 2×)
The finite population correction
The base formula assumes an effectively infinite (or very large) population. If your actual population is small enough that your sample would represent a meaningful fraction of it, the finite population correction reduces the required sample size:
n_adjusted = n / (1 + (n - 1) / N)
where N is the population size. This correction matters increasingly as your sample size approaches a significant fraction of the population — for a population much larger than your calculated sample size, the correction's effect becomes negligible, which is why it's often skipped entirely for large or effectively unbounded populations.
Sample size by population size
95% confidence, ±5% margin, p = 0.5, with the finite population correction:
| Population N | Sample size n |
|---|---|
| 100 | 80 |
| 200 | 132 |
| 500 | 218 |
| 1,000 | 278 |
| 2,000 | 323 |
| 5,000 | 357 |
| 10,000 | 370 |
| 100,000 | 383 |
| 1,000,000 or more | 385 |
Past about 20,000 people, the population hardly matters: a national poll needs about the same sample as a city poll. What changes the answer is the margin and the confidence:
| Margin of error | 90% | 95% | 99% |
|---|---|---|---|
| ±5% | 271 | 385 | 664 |
| ±3% | 752 | 1,068 | 1,844 |
| ±1% | 6,764 | 9,604 | 16,588 |
Sample size for a mean
When you are estimating an average (minutes of screen time, a measurement) rather than a percentage, the formula uses the standard deviation σ instead of p(1 − p):
n = (z × σ / E)²
where E is the margin of error in the same units as the data. To estimate average daily screen time within ±2 minutes when σ is about 15 minutes, at 95%: n = (1.96 × 15 ÷ 2)² = 216.1 → 217. σ has to come from a pilot study, earlier data, or a rough rule such as range ÷ 4.
Slovin's formula
Many school and thesis guides use Slovin's formula, n = N ÷ (1 + N·e²). For N = 2,000 and e = 0.05 it gives 334, close to Cochran's 323. It is a simplification that quietly assumes 95% confidence and p = 0.5 and cannot be changed for either, so prefer Cochran's formula with the finite population correction unless your instructor asks for Slovin.
Common mistakes
- Using an optimistic (non-50%) proportion estimate without strong prior evidence. Unless you have genuine data supporting a different value, 50% is the safe, conservative default.
- Assuming halving the margin of error only doubles the sample size. It roughly quadruples it, since margin of error is squared in the denominator — a common and expensive miscalculation when planning a study's budget.
- Applying the finite population correction to a very large or unknown population. Its effect becomes negligible once the population is much larger than the sample, making it unnecessary overhead in that case.
FAQ
How do I calculate sample size from a population size?
First compute n₀ = z²p(1 − p)/e² (385 for 95% confidence and ±5%), then adjust: n = n₀ ÷ (1 + (n₀ − 1)/N). For a population of 1,000 that gives 278. The table above lists common population sizes.
What sample size do I need for a 95% confidence level and 5% margin of error?
385 for a large population, fewer for a small one (278 for 1,000 people, 80 for 100). Divide by your expected response rate to get how many people to invite.
Why does using 50% give the largest required sample size?
Because p×(1-p) is mathematically maximized at p=50%, and this term directly drives the sample size formula upward — assuming 50% is the safe, worst-case choice when the true proportion isn't known.
Does halving my margin of error double my required sample size?
No — it roughly quadruples it, since the margin of error is squared in the denominator of the sample size formula.
When does population size stop affecting the required sample size?
Once the population is much larger than the calculated sample size, the finite population correction's effect becomes negligible — this is why it's commonly omitted for large or effectively unlimited populations.
Calculate your exact required sample size, with or without a finite population correction, using the Sample Size Calculator — entirely in your browser.
Use the Statistics Calculator to summarize a dataset before interpreting it. For a related walkthrough, read What a p-value Actually Means.