Skip to content
All articles

statistics

Sample Size Calculation Made Simple: Formulas, Worked Examples and Common Mistakes

A justified sample size is both an ethical and a statistical requirement, and it must be calculated before data collection. Every formula uses a few inputs: significance level, power, effect size, standard deviation or prevalence, and precision.

Resora Research Team · 14 Nov 2026 · 11 min read

"How many patients do I need?" is the first question every ethics committee, thesis guide and journal reviewer will ask — and the one most students find hardest to answer. This guide explains the logic of sample size calculation, gives the formulas you will actually use, and works through each one with a realistic example.

Why sample size matters

Sample size is not a formality. It is both a statistical and an ethical requirement.

  • Too small a sample cannot detect a real difference. The study ends "not significant" even when the treatment works — a Type II error. Participants were exposed to risk and inconvenience for a study that could never have answered its question.
  • Too large a sample wastes time and money, exposes more people than necessary to a possibly inferior treatment, and may find "significant" differences that are too small to matter clinically.
  • Reviewers and ethics committees expect to see a justified calculation, with every assumption and its source stated, in the synopsis or protocol.

The calculation always happens before data collection. A sample size worked out after the study to justify the number you managed to recruit is not acceptable.

Note: This article gives the standard formulas used in most medical and public health studies. For complex designs — cluster randomised trials, non-inferiority trials, survival outcomes, or multivariable models — consult a biostatistician.

The ingredients of every formula

Every sample size formula combines a few of the same inputs. Decide them first; the arithmetic is the easy part.

InputSymbolWhat it meansUsual value
Level of significanceαChance of a false-positive result (Type I error)0.05 (5%), two-sided
Power1 − βChance of detecting a real difference80% or 90%
Effect sized, δSmallest difference worth detectingFrom literature or clinical judgement
Standard deviationσ or SDSpread of a continuous outcomeFrom a previous study or pilot
Expected prevalence / proportionpExpected frequency of the outcomeFrom literature; use 50% if unknown
Absolute precisiond or EHow close your estimate should be to the truth (margin of error)5% absolute, or 10–20% relative
Non-response—Expected refusals, dropouts, lost records10–20%
Design effectDEFFExtra size needed for cluster sampling1.5–2

Z values you will need

The formulas use Z values from the standard normal distribution instead of α and power directly.

Significance (α, two-sided)Zα/2Power (1 − β)Zβ
0.051.9680%0.84
0.012.5890%1.28
0.101.6495%1.64

For most studies you will use Zα/2 = 1.96 and Zβ = 0.84.

Where do the assumptions come from?

The prevalence, SD or expected difference must come from somewhere defensible, in this order of preference:

  1. A previous study in a similar population — cite it.
  2. Your own pilot study.
  3. Clinical judgement about the smallest difference that would change practice (the minimum clinically important difference).
  4. If nothing is known about a proportion, use p = 50%, which gives the largest and therefore safest sample size.

Descriptive studies: estimating a prevalence or a mean

Use these when the aim is to estimate something in one population — a cross-sectional prevalence survey, a KAP study, or a mean value — rather than to compare groups.

Estimating a proportion (prevalence)

n = \frac{Z_{\alpha/2}^2 \; p \,(1 - p)}{d^2}

where p is the expected proportion and d is the absolute precision (margin of error). With Z = 1.96 this is often simplified to n = 4pq / d², where q = 1 − p.

Worked example. You want to estimate the prevalence of hypertension among adults in an urban slum. A previous study found 40%. You want your estimate within ±5% of the true value, at 95% confidence.

n = \frac{1.96^2 \times 0.40 \times 0.60}{0.05^2} = \frac{3.8416 \times 0.24}{0.0025} \approx 369

Watch the precision. Tighten d from 5% to 4% and the sample jumps to 576. Halve d and the sample quadruples. Precision is the single biggest driver of sample size in descriptive studies.

Absolute vs relative precision. ±5% absolute around a prevalence of 40% means 35–45%. For rare outcomes (prevalence 5%), ±5% absolute would be meaningless (0–10%), so use relative precision: d = a percentage of p, usually 10–20%. For p = 5% with 20% relative precision, d = 0.01.

Estimating a mean

n = \frac{Z_{\alpha/2}^2 \; \sigma^2}{d^2}

where σ is the expected SD and d is the precision in the same units as the measurement.

Worked example. You want to estimate mean haemoglobin in antenatal women within ±0.2 g/dL. Earlier studies report an SD of 1.5 g/dL.

n = \frac{1.96^2 \times 1.5^2}{0.2^2} = \frac{3.8416 \times 2.25}{0.04} \approx 216

Comparative studies: detecting a difference between groups

Use these for trials, cohort studies, case–control studies and any analytical design where you test a hypothesis. Power now enters the formula, so you need Zβ as well as Zα/2. The results below give the size of each group.

Comparing two means

n = \frac{2 \, (Z_{\alpha/2} + Z_{\beta})^2 \, \sigma^2}{\delta^2}

where δ is the smallest difference in means you want to detect and σ is the common SD.

Worked example. A trial compares a new antihypertensive with the standard drug. A fall in systolic BP of 5 mmHg more than the standard would be clinically important; the SD of BP change is about 10 mmHg. At α = 0.05 and 80% power:

n = \frac{2 \times (1.96 + 0.84)^2 \times 10^2}{5^2} = \frac{2 \times 7.84 \times 100}{25} \approx 63 \text{ per group}

Raising power to 90% (Zβ = 1.28) gives 84 per group. Note the standardised effect size δ/σ = 0.5 here; a smaller effect of 0.25 would need four times as many participants.

Comparing two proportions

n = \frac{\left[ Z_{\alpha/2}\sqrt{2\bar{p}(1-\bar{p})} + Z_{\beta}\sqrt{p_1(1-p_1) + p_2(1-p_2)} \right]^2}{(p_1 - p_2)^2}

where p₁ and p₂ are the expected proportions in the two groups and p̄ is their average.

Worked example. A cohort study expects 30% of smokers and 15% of non-smokers to develop a condition. With α = 0.05 and 80% power, the formula gives about 120 per group (240 in total).

A simpler, slightly conservative version often taught in PSM texts is:

n = \frac{(Z_{\alpha/2} + Z_{\beta})^2 \, [p_1(1-p_1) + p_2(1-p_2)]}{(p_1 - p_2)^2}

Case–control studies

You usually know the exposure prevalence among controls (p₀) and the odds ratio (OR) you want to detect. First convert the OR into the expected exposure among cases:

p_1 = \frac{OR \times p_0}{1 + p_0\,(OR - 1)}

then apply the two-proportion formula above.

Worked example. Exposure prevalence among controls is 20% and you want to detect an OR of 2. Then p₁ = (2 × 0.20) / (1 + 0.20) = 0.33. With α = 0.05 and 80% power this needs about 171 cases and 171 controls. Recruiting more controls per case (up to a ratio of 1:4) reduces the number of cases needed, useful when cases are rare.

Correlation studies

To detect a correlation coefficient r:

n = \left[ \frac{Z_{\alpha/2} + Z_{\beta}}{0.5 \ln\!\left(\frac{1+r}{1-r}\right)} \right]^2 + 3

Worked example. To detect a modest correlation of r = 0.3 between screen time and BMI at 80% power: about 85 participants.

Diagnostic accuracy studies

To estimate sensitivity with a given precision, use the single-proportion formula with p = expected sensitivity, then divide by the disease prevalence to get the total number to screen. For an expected sensitivity of 90% within ±5%, you need 139 diseased people; if prevalence is 20%, screen about 695 in total. Repeat for specificity and take the larger number.

Adjustments to the basic number

The formula gives the minimum number of analysable participants. Three adjustments are usually applied, in this order, and each should be shown in your synopsis.

1. Finite population correction

If you are sampling from a small, known population (all 2,000 residents of a village, all 300 nursing students in a college), the required sample shrinks:

n_{adj} = \frac{n}{1 + \dfrac{n - 1}{N}}

For the hypertension example (n = 369) in a population of N = 2,000: n_adj = 369 / (1 + 368/2000) ≈ 312. Skip this step when the population is large (over about 20 times the sample) — the correction becomes negligible.

2. Design effect (for cluster sampling)

People in the same cluster — a village, a school, a ward — resemble each other, so each person adds less new information than in simple random sampling. Multiply by the design effect (DEFF), usually 1.5 to 2 for community surveys:

n_{cluster} = n \times DEFF

A DEFF of 2 doubles the sample. Many WHO cluster surveys (such as the 30-cluster EPI immunisation survey) build this in.

3. Non-response and loss to follow-up

Add a margin for refusals, incomplete forms and dropouts — typically 10% for a cross-sectional survey and 15–20% for a study with follow-up:

n_{final} = \frac{n}{1 - \text{expected non-response}}

Divide, don't multiply. For 10% non-response, 369 / 0.9 = 410, not 369 × 1.1 = 406. The difference is small here but grows with higher attrition.

Putting it together

For the slum hypertension survey, done by cluster sampling with 10% non-response expected:

StepCalculationn
Base (p = 40%, d = 5%)1.96² × 0.4 × 0.6 / 0.05²369
Design effect 2369 × 2738
Non-response 10%738 / 0.9820

Always round up to the next whole number at the end, never down.

Software that does the arithmetic

You should understand the formula, but you don't have to compute it by hand.

ToolCostNotes
OpenEpi (openepi.com)Free, webQuick, widely accepted by Indian ethics committees; covers proportions, means, case–control, cohort
Epi Info (CDC)FreeStatCalc module for the common designs
G*PowerFreeBest for t-tests, ANOVA, correlation and regression; works with effect sizes
WHO sample size calculator / Lwanga & Lemeshow tablesFreeClassic reference tables many PSM departments still cite
R (pwr, epiR packages)FreeFully reproducible; good for unusual designs
nMaster, PASS, StataPaidComprehensive, including survival and non-inferiority designs

Whichever tool you use, state the tool and version in your methods, and make sure a reader could reproduce the number from the assumptions you list.

How to write it in your synopsis or paper

A complete sample size statement names the design, every assumption with its source, the formula or software, and the adjustments. For example:

The sample size was calculated using the formula for estimating a single proportion, n = Z²pq/d². Assuming a prevalence of hypertension of 40% based on Sharma et al. (2022), an absolute precision of 5%, and a 95% confidence level, the minimum sample size was 369. A design effect of 2 was applied for cluster sampling, and 10% was added for non-response, giving a final sample size of 820. Calculations were performed in OpenEpi version 3.01.

That single paragraph answers every question a reviewer will ask.

Common mistakes

  1. Copying a number from a similar thesis without recalculating for your own setting and precision.
  2. Using 50% prevalence when a better estimate exists — it inflates the sample and signals that the literature wasn't searched.
  3. Confusing absolute and relative precision, especially for rare outcomes.
  4. Using a descriptive formula for an analytical study. If your objective says "to compare" or "to find the association", you need a formula with power.
  5. Forgetting that comparative formulas give the size per group. Double it for the total.
  6. Multiplying instead of dividing for non-response.
  7. Ignoring the design effect in cluster or multistage sampling.
  8. Choosing an unrealistically large effect size to make the sample small. Reviewers will notice.
  9. Changing the sample size after data collection to fit what was recruited.
  10. Not stating the source of every assumption.

Quick reference

Study aimFormulaInputs needed
Estimate a prevalencen = Z² p(1−p) / d²Expected p, precision d
Estimate a meann = Z² σ² / d²SD, precision d
Compare two meansn = 2(Zα/2 + Zβ)² σ² / δ² per groupSD, difference δ, power
Compare two proportionsTwo-proportion formula per groupp₁, p₂, power
Case–controlConvert OR to p₁, then two-proportion formulap₀ in controls, OR, power
Correlation[(Zα/2 + Zβ) / (0.5 ln((1+r)/(1−r)))]² + 3Expected r, power
Small known populationn / (1 + (n−1)/N)Population size N
Cluster samplingn × DEFFDesign effect
Non-responsen / (1 − non-response rate)Expected loss

Conclusion

Sample size calculation is less about mathematics than about honest assumptions: what effect matters, how much uncertainty you can accept, and what the literature says to expect. Decide those first, choose the formula that matches your objective, apply the adjustments, and write every step down. Do that and the ethics committee's first question becomes the easiest one to answer.

SEO keywords and meta description

Focus keyword: sample size calculation

Meta title: Sample Size Calculation: Formulas, Examples & Common Mistakes

Meta description: Learn how to calculate sample size for prevalence studies, trials, cohort and case–control studies with formulas, worked examples, adjustments and free tools.

Primary keywords: sample size calculation, sample size formula, how to calculate sample size for research, sample size for cross-sectional study, sample size for thesis

Secondary and long-tail keywords: sample size formula for prevalence study, n = 4pq/d2 formula, sample size for comparing two means, sample size for case control study, sample size calculation for RCT, power and sample size, OpenEpi sample size, design effect in sample size, non-response adjustment sample size, finite population correction, sample size for MD thesis, sample size calculation in community medicine, Lwanga and Lemeshow sample size

Suggested URL slug: /sample-size-calculation-formulas-examples

Suggested tags: Biostatistics, Research methodology, Thesis writing, Epidemiology, Community medicine

References

  • Lwanga SK, Lemeshow S. Sample Size Determination in Health Studies: A Practical Manual. Geneva: World Health Organization; 1991.
  • Charan J, Biswas T. How to calculate sample size for different study designs in medical research? Indian Journal of Psychological Medicine. 2013;35(2):121–126.
  • Hulley SB, Cummings SR, et al. Designing Clinical Research. 4th ed. Lippincott Williams & Wilkins; 2013.
  • Kirkwood BR, Sterne JAC. Essential Medical Statistics. 2nd ed. Blackwell Science; 2003.
  • Dean AG, Sullivan KM, Soe MM. OpenEpi: Open Source Epidemiologic Statistics for Public Health. www.openepi.com
  • Park K. Park's Textbook of Preventive and Social Medicine — chapter on biostatistics and sampling.

Related services

Sample Size Calculation Made Simple: Formulas, Worked Examples and Common Mistakes · Resora