Epidemiopedia ES
Calculators

Sample size calculator

Work out how many people a study needs to estimate a prevalence with the precision you want, or to detect a difference between two groups with enough power. Formulas, worked examples, drop-out, design effect and common mistakes.

Educational information with sources. It does not replace advice from a health professional or the instructions of public health authorities. For difficulty breathing, a stiff neck with fever or a rash that does not fade when pressed, call emergency services.

Sample tubes in a clinical laboratory
Sample size is decided before the study starts, not at the end. Image: Frankincense Diala · CC0 · Wikimedia Commons

What it is for

A study that is too small cannot answer its question and exposes participants without benefit; one that is too large wastes resources. That is why the CONSORT 2025 and SPIRIT 2025 guidelines ask every randomised trial and its protocol to explain how the sample size was determined, and STROBE asks observational studies to justify it.

Formulas

Most commonly used Z values: 95% confidence → Zα = 1.96 (two-sided); 80% power → Zβ = 0.84; 90% power → Zβ = 1.28.

Aim Formula (plain text)
Estimate a proportion (prevalence) n = Zα² × p × (1 − p) / e²
Finite population correction (N) adjusted n = n / [1 + (n − 1) / N]
Compare two proportions (per group) n = [Zα × √(2 p̄ (1 − p̄)) + Zβ × √(p1(1 − p1) + p2(1 − p2))]² / (p1 − p2)², with p̄ = (p1 + p2)/2
Compare two means (per group) n = 2 × (Zα + Zβ)² × σ² / Δ²
Adjust for losses (L) final n = n / (1 − L)
Cluster sampling final n = n × design effect

p is the expected proportion, e the margin of error (half the width of the interval), σ the standard deviation and Δ the smallest relevant difference.

What you need

  • Expected proportion or standard deviation: from earlier studies, a pilot or surveillance data. If you have no idea of a proportion, p = 0.5 gives the largest size.
  • Desired precision (in a descriptive study) or minimum clinically relevant difference (in a comparative one).
  • α error (usually 0.05) and power (1 − β, usually 0.80 or 0.90).
  • Expected drop-out or non-response and, if there are clusters (schools, GP practices), the design effect.

Worked examples

Example 1 (invented data): estimating a prevalence. A survey wants to estimate smoking prevalence among teenagers, expected to be around 30%, with a margin of ±5 points and 95% confidence.

  1. n = 1.96² × 0.30 × 0.70 / 0.05² = 3.8416 × 0.21 / 0.0025 = 323.
  2. If the school has only 2,000 pupils: 323 / [1 + 322 / 2,000] = 278.
  3. If 20% non-response is expected: 323 / 0.80 = 404.
  4. If whole classes are sampled with a design effect of 2: 323 × 2 = 646.

Example 2 (invented data): comparing two proportions. A trial expects to reduce an event from 20% to 10%, with two-sided α = 0.05 and 80% power.

  1. p̄ = 0.15; √(2 × 0.15 × 0.85) = 0.505; √(0.16 + 0.09) = 0.50.
  2. n = (1.96 × 0.505 + 0.84 × 0.50)² / 0.10² = (0.990 + 0.421)² / 0.01 = 199 per group.
  3. With 90% power (Zβ = 1.28): 266 per group.

Example 3 (invented data): comparing two means. The aim is to detect a 5 mmHg difference in blood pressure with σ = 10 mmHg, α = 0.05 and 80% power: n = 2 × 2.80² × 100 / 25 = 63 per group.

How to read the result

If you change… The sample size…
Halve the margin of error Is multiplied by 4
Halve the difference to detect Is multiplied by 4
Power from 80% to 90% Rises by about a third
Confidence from 95% to 99% Rises by about 50-75%
p towards 0.5 Rises (maximum at p = 0.5)

Important. A small study that finds no difference is inconclusive, not negative: absence of evidence is not evidence of absence. Look at the confidence interval, which is usually very wide, and calculate it with the confidence interval calculator.

Limitations

  • The formulas are normal approximations; very small proportions, rare events or survival analysis (hazard ratio) need specific methods.
  • They do not cover case-control studies or cohort studies planned with different formulas (based on the expected OR or RR), nor non-inferiority trials.
  • If many subgroups or outcomes are analysed, each has less power.
  • Tweaking the expected difference until an affordable size "comes out" is a common mistake that produces underpowered studies.
  • Size does not correct bias: a huge but badly selected sample gives a precise and wrong answer.

In a prevalence survey (a cross-sectional study), precision matters more than power; in a trial, the reverse.

Sources

  1. Chan AW, Boutron I, Hopewell S, et al. SPIRIT 2025 statement: updated guideline for protocols of randomised trials. BMJ. 2025;389:e081477.
  2. Hopewell S, Chan AW, Collins GS, et al. CONSORT 2025 statement: updated guideline for reporting randomised trials. BMJ. 2025;389:e081123.
  3. Celentano DD, Szklo M, Farag YMK. Gordis Epidemiology. 7th ed. Philadelphia: Elsevier; 2024.
  4. Lwanga SK, Lemeshow S. Sample size determination in health studies: a practical manual. Geneva: WHO; 1991.
  5. Fleiss JL, Levin B, Paik MC. Statistical Methods for Rates and Proportions. 3rd ed. Hoboken: Wiley; 2003.
  6. Altman DG, Bland JM. Absence of evidence is not evidence of absence. BMJ. 1995;311(7003):485.

Spotted a mistake? Write to partenopides@gmail.com