Written and maintained by CASRAI Editorial Board
Last updated
Sample size determination formulas turn a precision or power target into a number of participants. Which formula applies depends on what you are estimating (a proportion or a mean) and whether you are comparing groups. This page gives the formulas for a single proportion, a single mean, two means and two proportions, then the finite-population, dropout and unequal-allocation adjustments, each with the arithmetic shown. It is for researchers planning a survey or a two-group study who need to pick the right formula and defend the inputs.
Which sample size formula fits your study?
Match the formula to the research question. The symbol definitions below follow Serdar et al. (2021), Table 1; the two-group formulas are the ones written out in Sakpal (2010).
| Study question | Formula family | Inputs you must supply |
|---|---|---|
| What share of a population has a characteristic (survey prevalence)? | Single proportion, with design effect | Expected proportion P, margin of error E, design effect D, Z for the confidence level |
| What is the average of a measurement, to within a stated accuracy? | Single mean (precision) | Standard deviation s from earlier or pilot work, accuracy d, Z |
| Do two group means differ? | Two means | Pooled standard deviation, difference of means, Z for alpha and for power; allocation ratio if groups are unequal |
| Do two group proportions differ? | Two proportions | p1, p2, Z for alpha and for power |
| Is the population small and known? | Finite-population correction | Initial n0 and the population size |
Serdar et al. also tabulate formulas for odds ratios, correlation coefficients, ROC/AUC and sensitivity/specificity studies; this page covers the four most-used cases. For the logic of power itself, see power in statistics and the broader power analysis and sample size calculation guide.
What do Z, alpha and power contribute to every formula?
Z values fix your error rates. For a two-sided alpha of 0.05, Z(α/2) = 1.96; for 80% power, Z(β) = 0.84 (Serdar et al., 2021). The values below are standard normal quantiles that I computed, so you can swap targets:
| Target | Z value |
|---|---|
| Two-sided alpha 0.05 (95% confidence) | 1.9600 |
| Two-sided alpha 0.01 (99% confidence) | 2.5758 |
| One-sided alpha 0.05 | 1.6449 |
| Power 80% | 0.8416 |
| Power 90% | 1.2816 |
Textbooks round the 80% power value to 0.84; using 0.8416 rarely changes the result after rounding up.
Single proportion: how many respondents does a survey need?
For estimating a proportion in a survey, the sample size is n = D × Z² × P(1 − P) / E². In Serdar et al. (2021), P is the expected prevalence, E the precision (margin of error), D the design effect and Z(α/2) = 1.96 at alpha 0.05. The design effect is 1 for simple random sampling and is usually between 1 and 2 for stratified, systematic or cluster designs. When you have no estimate of P, 0.5 gives the largest, most cautious n.
Worked example. P = 0.5, E = 0.05, Z = 1.96, simple random sampling (D = 1):
- Z² = 1.96² = 3.8416
- P(1 − P) = 0.5 × 0.5 = 0.25
- n0 = 3.8416 × 0.25 / 0.05² = 0.9604 / 0.0025 = 384.16, rounded up to 385
- With a cluster design and D = 1.5: 1.5 × 384.16 = 576.24, rounded up to 577
For how respondents are drawn, see simple random sampling.
Finite population: how does a small population change the answer?
If the population is small and known, you need fewer respondents than the infinite-population formula gives. The standard finite-population correction (algebra applied here, not a formula quoted from Serdar or Sakpal) is n_adj = n0 / (1 + (n0 − 1) / N), where N is the population size.
Worked example. n0 = 384.16 and N = 2,000: (384.16 − 1) / 2,000 = 0.19158; 1 + 0.19158 = 1.19158; 384.16 / 1.19158 = 322.40, rounded up to 323. The correction matters when the sample would be a large fraction of the population; for very large populations n_adj is almost equal to n0. See population vs sample for the terms.
Single mean: sample size for a stated accuracy
To estimate a mean, n = Z² × s² / d², where s is the standard deviation from a previous or pilot study and d is the accuracy wanted (Serdar et al., 2021). Example: s = 12, d = 3, Z = 1.96 gives 3.8416 × 144 / 9 = 61.47, rounded up to 62. A precision example using the NIST formulation is in what is a good sample size for a quantitative study.
Two means: comparing two groups
Sakpal (2010) gives the per-group size as n = (Z(α/2) + Z(β))² × 2σ² / (μ1 − μ2)². Serdar et al. define σ as the pooled standard deviation, the difference of means as d, and r = n1/n2 as the group ratio.
Worked example (Sakpal’s inputs): difference 0.5, σ = 1.195, alpha 0.05 two-sided, power 80%. (1.96 + 0.84)² = 7.84; 2σ² = 2 × 1.428 = 2.856; 7.84 × 2.856 = 22.39; 22.39 / 0.25 = 89.6, rounded up to 90 per group, 180 in total. The effect you choose drives everything here; see effect size. For software with exact t-distribution results, see G*Power.
Two proportions: comparing event rates
Sakpal (2010) gives the per-group size as n = (Z(α/2) + Z(β))² × [p1(1 − p1) + p2(1 − p2)] / (p1 − p2)².
Worked example (Sakpal’s inputs): p1 = 0.50, p2 = 0.34, alpha 0.05 two-sided, power 80%.
- p1(1 − p1) = 0.25 and p2(1 − p2) = 0.34 × 0.66 = 0.2244, sum 0.4744
- (1.96 + 0.84)² = 7.84, and 7.84 × 0.4744 = 3.719
- (p1 − p2)² = 0.16² = 0.0256
- n = 3.719 / 0.0256 = 145.3, rounded up to 146 per group, 292 in total
The published article’s protocol text states 142 per arm, which does not match its own arithmetic; 146 follows from the formula. Changing the target changes the result: with 90% power (Z = 1.2816) the same inputs give 194.7, so 195 per group; with a one-sided alpha of 0.05 (Z = 1.6449) and 80% power they give 114.6, so 115 per group.
How do you adjust for dropout and unequal group sizes?
Dropout
If a proportion d of participants is expected to drop out, inflate the size: N1 = n / (1 − d) (Sakpal, 2010). Inflating the 146 per group above for 10% dropout: 146 / 0.9 = 162.2, rounded up to 163 per group, 326 in total. Divide by (1 − d), not multiply by (1 + d); the second under-recruits.
Unequal allocation
For allocation ratio k = n1/n2, Sakpal (2010) gives n1 = 0.5 n (1 + k) and n2 = 0.5 n (1 + 1/k), where n is the per-group size for equal allocation. Using Sakpal’s example, n = 100 and k = 2 give n1 = 150 and n2 = 75, a total of 225 instead of 200: unequal groups cost extra participants overall.
How do you calculate it in Excel, R or Python?
All three snippets reproduce the single-proportion survey example (385) and the two-proportion example (146).
Excel
=ROUNDUP(NORM.S.INV(0.975)^2*0.5*0.5/0.05^2,0) ' -> 385
=ROUNDUP((NORM.S.INV(0.975)+NORM.S.INV(0.8))^2*(0.5*0.5+0.34*0.66)/(0.5-0.34)^2,0) ' -> 146
R (base)
ceiling(qnorm(0.975)^2*0.5*0.5/0.05^2) # 385
ceiling((qnorm(0.975)+qnorm(0.8))^2*(0.5*0.5+0.34*0.66)/(0.5-0.34)^2) # 146
Python
from statistics import NormalDist
from math import ceil
z = NormalDist().inv_cdf
print(ceil(z(0.975)**2*0.5*0.5/0.05**2)) # 385
print(ceil((z(0.975)+z(0.8))**2*(0.5*0.5+0.34*0.66)/(0.5-0.34)**2)) # 146
Free dedicated tools named by Serdar et al. (2021) include G*Power, R, PS (Vanderbilt) and Piface; PASS and nQuery are commercial. Dedicated software may use exact or arcsine-based methods, so results can differ by a participant or two: the arcsine (Cohen’s h) calculation in Python’s statsmodels, for example, returns 148 per group for the two-proportion inputs above.
Assumptions and common mistakes
- Always round up, never to the nearest integer.
- The inputs (P, s, p1, p2, the difference) are assumptions; take them from earlier studies or a pilot, and state the source.
- Adjust for dropout after computing the analysable sample, not before.
- Report per-group and total numbers separately.
- Use P = 0.5 for a survey only when you truly have no prior estimate.
How do you report a sample size justification?
An example sentence: “A sample of 146 participants per group (292 in total) was needed to detect a difference between proportions of 0.50 and 0.34 with 80% power and a two-sided alpha of 0.05; allowing for 10% dropout, 163 per group (326 in total) were recruited.” State the formula or software, alpha, power, the inputs with their source, and the dropout allowance. A statistical analysis plan is the usual place to record it.
FAQ
What is the formula for sample size in research?
There is no single formula. For a survey proportion it is n = D × Z² × P(1 − P) / E²; for two groups it combines (Z(α/2) + Z(β))² with the variability and the difference to detect.
What is the sample size formula for a known population?
Compute n0 with the proportion or mean formula, then apply n_adj = n0 / (1 + (n0 − 1) / N).
Do these formulas work for a qualitative study?
No. They estimate precision or power for quantitative parameters, so they do not apply to qualitative designs.
Which sample size calculator should I use?
Any of the tools above can check a hand calculation; the formulas here let you verify what the tool returns.
Sources
- Serdar CC, Cihan M, Yucel D, Serdar MA. Sample size, power and effect size revisited: simplified and practical approaches in pre-clinical, clinical and laboratory studies. Biochemia Medica 2021;31(1):010502. PMC7745163 (read 2026-11-08).
- Sakpal TV. Sample size estimation in clinical trial. Perspectives in Clinical Research 2010;1(2):67-69. PMC3148614 (read 2026-11-08).
- The finite-population expression, Z-value table and all arithmetic on this page were computed for this guide.







