# What sample size do I need?

Computes the sample size for a survey proportion or a mean at a margin of error and confidence level, with a finite population, or per group to compare two means or two proportions with a given power.

- Page: https://www.acalculator.org/statistics/sample-size-calculator
- JSON spec: https://www.acalculator.org/statistics/sample-size-calculator.json
- Version: 9c20e9f735ec

## Default answer

Example with the default inputs (I want to Survey a proportion, Confidence level 95%, Margin of error 5%, Expected proportion 50%): You need a sample size of 385 in total.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| goal | I want to | Estimate a proportion (a survey) or a mean to a margin of error, or compare two groups’ means or proportions with a test. |
| cl | Confidence level | How confident the margin of error is, in percent: 95 for 95%. |
| moe | Margin of error | The largest acceptable difference between the sample result and the truth, in percentage points: 5 for ±5%. |
| p | Expected proportion | Your best guess of the proportion, in percent. Use 50 when unsure: it gives the largest sample. |
| sigma | Standard deviation (σ) | The expected standard deviation of the measurement, from a pilot study or past data. |
| e | Margin of error | The largest acceptable difference between the sample mean and the true mean, in the same units as σ. |
| pop | Population size | How many are in the whole population. Leave empty for a very large or unknown population. |
| delta | Difference to detect (Δ) | The smallest difference between the two means worth detecting, in the same units as σ. |
| p1 | Proportion in group 1 | The expected proportion in the first group, in percent. |
| p2 | Proportion in group 2 | The expected proportion in the second group, in percent. |
| alpha | Significance level (α) | The two-sided significance level of the test, for example 0.05. |
| power | Power | The chance of detecting the difference when it is real, in percent: 80 is common. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| n | Sample size | The number to sample, rounded up: in total for an estimate, or in each group for a comparison. |
| scope | Sample size is | Whether the sample size is in total or in each of the two groups. |
| total | Total for both groups | Twice the sample size per group. Shown for comparisons. |
| exact | Before rounding up | The sample size from the formula, before it is rounded up to a whole number. |
| infinite | For a very large population | The sample size before the finite population correction, rounded up. Shown when a population size is given and it is at most 10¹⁵. |
| z | z for the confidence level | The standard normal value with an upper tail of (1 − confidence) ÷ 2, or of α ÷ 2 for a comparison. |
| zPower | z for the power | The standard normal value with an upper tail of 1 − power. Shown for comparisons. |

## Method

Proportion: n₀ = z² p(1 − p) ÷ E². Mean: n₀ = (z σ ÷ E)². Finite population: n = n₀ ÷ (1 + (n₀ − 1) ÷ N). Two means: n = 2 (z(α/2) + z(β))² σ² ÷ Δ² per group. Two proportions: n = (z(α/2) + z(β))² (p₁q₁ + p₂q₂) ÷ (p₁ − p₂)² per group. Round up.

## Assumptions

- Simple random sampling. The z values are exact standard normal quantiles (1.959964, not 1.96).
- The comparisons use a two-sided test at level α and groups of equal size.
- Every sample size is rounded up to the next whole number.

## Worked examples

1. goal = proportion, cl = 95%, moe = 5%, p = 50% gives n = 385, exact = 384.145882, z = 1.959964. Source: Israel, Determining Sample Size, University of Florida IFAS Extension PEOD6, 1992 (Cochran’s formulas). https://ask.ifas.ufl.edu/publication/PD006 (n₀ = 1.96² × 0.5 × 0.5 ÷ 0.05² = 385).
2. goal = proportion, cl = 95%, moe = 5%, p = 50%, pop = 2,000 gives n = 323, infinite = 385, exact = 322.385537. Source: Israel, Determining Sample Size, University of Florida IFAS Extension PEOD6, 1992 (Cochran’s formulas). https://ask.ifas.ufl.edu/publication/PD006 (385 ÷ (1 + 384 ÷ 2000) = 323).
3. goal = mean, cl = 95%, sigma = 15, e = 3 gives n = 97, exact = 96.036471. Source: Israel, Determining Sample Size, University of Florida IFAS Extension PEOD6, 1992 (Cochran’s formulas). https://ask.ifas.ufl.edu/publication/PD006.
4. goal = twoMeans, sigma = 10, delta = 5, alpha = 0.05, power = 80% gives n = 63, total = 126, exact = 62.791038, zPower = 0.841621. Source: Noordzij et al., Sample size calculations: basic principles and common pitfalls, Nephrology Dialysis Transplantation, 2010. https://doi.org/10.1093/ndt/gfp732.
5. goal = twoProportions, p1 = 60%, p2 = 45%, alpha = 0.05, power = 80% gives n = 171, total = 342, exact = 170.059061. Source: Noordzij et al., Sample size calculations: basic principles and common pitfalls, Nephrology Dialysis Transplantation, 2010. https://doi.org/10.1093/ndt/gfp732.
6. goal = mean, cl = 95%, sigma = 1, e = 1 gives n = 4. Source: 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.

## FAQ

### How many people do I need to survey?

For a margin of error of ±5% at 95% confidence, with no idea of the answer (use 50%), you need 385 responses. Cochran’s formula gives n = 1.96² × 0.5 × 0.5 ÷ 0.05² = 384.1, rounded up to 385.

### Why use 50% for the expected proportion?

The formula depends on p × (1 − p), which is largest at p = 50%. If you do not know the proportion in advance, 50% gives a sample big enough for any answer. If you expect something like 10%, the sample needed is smaller.

### Does the population size matter?

Only when the sample would be a sizeable share of it. The finite population correction n = n₀ ÷ (1 + (n₀ − 1) ÷ N) cuts 385 to 323 for a population of 2,000, but barely changes it for a population of 1,000,000. Leave the population empty when it is very large or unknown.

### What is statistical power?

Power is the chance that a study detects a difference that really exists. 80% is the usual minimum; 90% is common in clinical trials. Higher power, a smaller difference to detect, or a stricter α all need a larger sample.

### How do I choose the difference to detect?

Choose the smallest difference that would matter in practice, such as a 5-point change in a test score. Detecting half the difference needs about four times the sample, because the sample size grows with 1 ÷ Δ².

### Why is the answer rounded up?

You cannot sample part of a person, and rounding down would give slightly less precision or power than you asked for. The calculator always rounds up and shows the unrounded value too.

## Sources

- Israel, Determining Sample Size, University of Florida IFAS Extension PEOD6, 1992. https://ask.ifas.ufl.edu/publication/PD006
- 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
- Noordzij et al., Sample size calculations: basic principles and common pitfalls, Nephrology Dialysis Transplantation, 2010. https://doi.org/10.1093/ndt/gfp732
