# Sample size and power calculator

> Sample size calculator for surveys and studies: n for a margin of error on a proportion or mean, and the per-group n for a target power.

Interactive version: https://www.calcopenly.com/statistics/sample-size-calculator
Subject: Statistics and probability calculators

For a survey proportion the sample size is n₀ = z²p(1 − p)/E², where z is the critical value for the confidence level and E the margin of error; for a mean it is (zσ/E)². A known population size N reduces this through the finite population correction, n = n₀/(1 + (n₀ − 1)/N). To compare two means, each group needs 2(z₁₋α/₂ + z₁₋β)²/d², where d is the difference to detect divided by σ.

Survey planners and researchers use it before collecting data. The default, 95% confidence and ±5 points with p = 50%, needs 384.1 respondents, rounded up to 385; for a population of 10,000 the correction lowers that to 370.

Results are always rounded up. The formulas assume simple random sampling; cluster samples, weighting and non-response all call for a larger sample.

## Inputs

- **Plan for** (options: Estimating a proportion (survey), Estimating a mean, Comparing two means (power))
- **Confidence level**
- **Expected proportion**: Use 50% when you have no prior estimate — it gives the largest, safest sample.
- **Margin of error**: In percentage points: 5 means ±5%.
- **Standard deviation σ (estimate)**: From a pilot study or earlier data.
- **Margin of error (same units as σ)**
- **Population size**: Applies the finite population correction.
- **Difference to detect δ**: The smallest difference between the group means worth detecting.
- **Significance level α**
- **Power**
- **Test** (options: Two-sided, One-sided)

## Results

- Sample size needed — main result
- Before rounding up
- Without population correction
- Total across both groups
- Effect size d = δ/σ
- z for the confidence level or α

## Formula

$$
n_0 = \frac{z^2\,p(1-p)}{E^2},\quad n_0 = \left(\frac{z\sigma}{E}\right)^2,\quad n = \frac{n_0}{1 + (n_0-1)/N},\quad n_{\text{group}} = \frac{2(z_{1-\alpha/2} + z_{1-\beta})^2\sigma^2}{\delta^2}
$$

## Worked examples

### Survey at 95%, ±5%, p = 50% (defaults)

- Plan for: Estimating a proportion (survey)
- Confidence level: 95%
- Expected proportion: 50%
- Margin of error: 5%
- **Sample size needed: 385**
- **Before rounding up: 384.1459**
- Checked against: Cochran's formula 1.959964² × 0.25 / 0.05² = 384.146 (Python NormalDist); the widely published figure is 385

### Same survey, population of 10,000

- Plan for: Estimating a proportion (survey)
- Confidence level: 95%
- Expected proportion: 50%
- Margin of error: 5%
- Population size: 10,000
- **Sample size needed: 370**
- **Before rounding up: 369.9706**
- Checked against: Finite population correction n₀/(1 + (n₀ − 1)/N) in Python

### Small population of 100

- Plan for: Estimating a proportion (survey)
- Confidence level: 95%
- Expected proportion: 50%
- Margin of error: 5%
- Population size: 100
- **Sample size needed: 80**
- **Before rounding up: 79.5093**
- Checked against: Finite population correction in Python: 384.146/(1 + 383.146/100)

### Mean within ±3 when σ = 15

- Plan for: Estimating a mean
- Confidence level: 95%
- Standard deviation σ (estimate): 15
- Margin of error (same units as σ): 3
- **Sample size needed: 97**
- **Before rounding up: 96.0365**
- Checked against: (1.959964 × 15 / 3)² = 96.04 in Python

### Power 80% for d = 0.5, two-sided α = 0.05

- Plan for: Comparing two means (power)
- Standard deviation σ (estimate): 15
- Difference to detect δ: 7.5
- Significance level α: 0.05
- Power: 80%
- Test: Two-sided
- **Sample size needed: 63**
- **Before rounding up: 62.791**
- **Total across both groups: 126**
- **Effect size d = δ/σ: 0.5**
- Checked against: Normal approximation 2(1.959964 + 0.841621)²/0.25 in Python; Cohen's t-based table gives 64 per group

### 99% confidence, ±1%

- Plan for: Estimating a proportion (survey)
- Confidence level: 99%
- Expected proportion: 50%
- Margin of error: 1%
- **Sample size needed: 16,588**
- **Before rounding up: 16,587.2**
- Checked against: 2.575829² × 0.25 / 0.0001 = 16587.24 (Python NormalDist)

## Questions

### Why is 385 the standard survey sample size?

It is what Cochran's formula gives for 95% confidence, a ±5-point margin and p = 50%: 1.96² × 0.25 / 0.05² = 384.1, rounded up to 385. Because p = 50% is the worst case, 385 is enough for any true proportion in a large population. A population of 1,000 needs only 278, because each respondent is a larger share of it.

### Does population size matter for sample size?

Only when the sample is a noticeable fraction of the population. The finite population correction turns the 385 needed for ±5 points at 95% into 370 for a population of 10,000 and 80 for a population of 100, while any population above 100,000 needs 383 to 385. A sample of 1,000 gives about ±3.1 points whether the population is 100,000 or 300 million.

### What expected proportion should I use?

Use 50% unless you have a reliable prior estimate. p(1 − p) is largest at p = 0.5, so that sample is big enough whatever the true value turns out to be. A prior estimate lowers the requirement: at 95% confidence and ±5 points, an expected 20% needs 246 respondents instead of 385. If the guess is wrong, the achieved margin will be wider than planned.

### How does sample size change with the margin of error?

The margin shrinks with the square root of n, so halving it needs four times the sample. At 95% confidence and p = 50%, ±5 points needs 385 respondents, ±3 points 1,068, ±2 points 2,401 and ±1 point 9,604. Choosing 90% confidence instead of 95% lowers the ±5-point figure to 271.

### What does statistical power mean?

Power is the probability that a test detects an effect of a stated size when that effect is real; 1 − power is the Type II error rate β. Cohen (1988) proposed 80% as a conventional minimum. Detecting a difference of 7.5 when σ = 15 (d = 0.5) with a two-sided test at α = 0.05 needs 63 per group for 80% power by the normal approximation; Cohen's t-based table gives 64.

### How accurate is the sample size and power calculator?

Accuracy depends on your inputs and the method's assumptions. Decimal arithmetic uses 50 significant digits, but estimates, numerical methods and source data can be less precise; the displayed rounding does not remove those limits. It is checked against 6 worked examples whose answers come from independent sources; for example, “Survey at 95%, ±5%, p = 50% (defaults)” is checked against Cochran's formula 1.959964² × 0.25 / 0.05² = 384.146 (Python NormalDist); the widely published figure is 385.

### Where does the method come from?

NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.2.2 Sample sizes required; Cochran, W. G. (1977). Sampling Techniques, 3rd ed., §4.4 (sample size for proportions and the finite population correction); Cohen, J. (1988). Statistical Power Analysis for the Behavioral Sciences, 2nd ed., Table 2.4.1.

## Sources

- [NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.2.2 Sample sizes required](https://www.itl.nist.gov/div898/handbook/prc/section2/prc222.htm)
- Cochran, W. G. (1977). Sampling Techniques, 3rd ed., §4.4 (sample size for proportions and the finite population correction)
- Cohen, J. (1988). Statistical Power Analysis for the Behavioral Sciences, 2nd ed., Table 2.4.1
