Opens in a new tab

Home / Resources / Sample Size & Power

Sample Size for Comparing Two Means:
Formula and Example

Sample size for comparing two means depends mainly on the smallest mean difference worth detecting, outcome variability, target power, significance level and study design. For two independent groups of equal size, a standard normal-approximation formula provides a useful starting point. Paired observations and unequal allocation require different calculations (Machin et al., 2009; Chow et al., 2017).

Sample Size & Power
INPUTS NEEDEDDifference, SD, α, power
FORMULA FAMILYNormal approximation
TYPICAL RESULT99 per group (example)
SOFTWAREG*Power, R, Stata
REPORT TOProtocol, SAP, grant

When is this calculation appropriate?

Use this method when the primary outcome is quantitative, such as a validated scale total, blood-pressure measurement or functional score, and the aim is to compare a specified mean between two independent groups. Specify whether the target is a post-treatment mean difference, change from baseline, or a covariate-adjusted treatment effect: these choices affect the design and its required sample size.

Design Preferred basis for planning Why it differs
Two independent groups Difference in means and within-group SD Independent participants provide independent information
Same patients before and after SD of paired differences Pairing induces correlation
Two groups with baseline-adjusted ANCOVA Residual SD or R² informed by baseline relationship Adjustment can change precision
More than two groups Prespecified contrast or omnibus test Multiple comparisons and allocation matter
Clustered participants Cluster-adjusted approach Observations within clusters are not independent

These distinctions follow the design-specific treatment of continuous outcomes in Machin et al. (2009).

Sample size for comparing two means: the formula

Under independent groups, an approximately normally distributed test statistic, common SD σ and equal allocation:

FORMULA

n per group ≈ 2 (z₁₋α/₂ + z₁₋β)² σ² / δ²

Where n is analyzable participants per group; δ is the target difference between means; σ is the expected within-group SD; α is the two-sided type I error rate; and 1 − β is statistical power. The critical values are from the standard-normal distribution. This is an approximation, not a universal exact t-test formula (Chow et al., 2017; Machin et al., 2009).

The standardized mean difference is d = δ/σ. The same approximation can be written as n ≈ 2(z₁₋α/₂ + z₁₋β)²/d². A smaller anticipated effect relative to the SD increases sample size sharply.

WORKED EXAMPLE (HYPOTHETICAL VALUES)

A two-arm study plans to detect a six-point difference in a continuous outcome. Assume a common SD of 15 points, two-sided α = .05 and 80% power.

  1. Determine δ = 6 and σ = 15.
  2. For α = .05 use z ≈ 1.960. For 80% power use z ≈ 0.842.
  3. Calculate n ≈ 2 × (1.960 + 0.842)² × 15² / 6² = 98.11.
  4. Round up to 99 analyzable participants per group, or 198 total.

This is the normal-approximation result. An exact noncentral-t calculation may produce a slightly different requirement; prespecify the planned test and verify the final n using suitable statistical software (Machin et al., 2009).

If 20% are expected to lack analyzable primary-outcome data, a simple recruitment inflation gives ceil(99/0.8) = 124 recruits per arm. Missing outcomes may also introduce bias; recruitment inflation alone does not solve that problem.

Where do the mean difference and SD come from?

Use comparable populations, outcomes, observation times and interventions. For the SD, a relevant prior study is generally preferable to a generic rule. For the target difference, consider a clinically or substantively meaningful effect, not merely the most favorable published estimate. Small pilot estimates can be unstable, and relying on them without sensitivity analysis may mislead planning (Albers & Lakens, 2018; Lakens, 2022).

A useful practice is to show a sensitivity table: calculate how required n changes across plausible SDs and effect sizes. Label each alternative assumption and justify its source.

Example in R

A sensitivity table takes a few lines in R. This sketch uses hypothetical candidate values and the t-based function, so each cell is the analyzable n per group for that combination of target difference and SD.

R

# Hypothetical candidate assumptions: replace with justified values
deltas <- c(5, 6, 7)       # candidate target differences
sigmas <- c(12, 15, 18)    # candidate common standard deviations

# Required n per group: two-sided alpha = .05, 80% power, two-sample t-test
n_grid <- outer(deltas, sigmas, Vectorize(function(d, s) {
  ceiling(power.t.test(delta = d, sd = s, sig.level = 0.05,
                       power = 0.80)$n)
}))
dimnames(n_grid) <- list(paste0("delta = ", deltas),
                         paste0("SD = ", sigmas))
n_grid

What changes for paired measurements?

For a one-sample test of paired differences, the corresponding approximation uses the SD of the within-person differences, σD:

FORMULA

n pairs ≈ (z₁₋α/₂ + z₁₋β)² σD² / δD²

You cannot replace σD with the SD of baseline scores. The correlation between paired observations affects σD. This also explains why an independent-groups formula should not be copied into a repeated-measures protocol (Machin et al., 2009).

Common planning errors

  • Reporting a total sample when the formula calculated per-group n.
  • Using standard error instead of standard deviation as σ.
  • Selecting an effect only because it produces a feasible sample size.
  • Treating equal-allocation formulas as valid for 2:1 randomization.
  • Ignoring clustering, preplanned covariate adjustment or repeated measurements.
  • Calling an approximate z formula an exact two-sample t-test calculation.

How to report it

REPORTING TEMPLATE

The study was planned to detect a between-group difference of [δ] units in [primary outcome] at [time point]. Assuming a common SD of [σ] based on [source], two-sided α = [value], power = [value], and 1:1 allocation, the required sample was [n] analyzable participants per group, calculated using [specified method and software]. Allowing for [anticipated incomplete outcomes] gave a recruitment target of [N] per group.

Frequently asked questions

The standardized difference d = δ/σ combines the target difference and SD. You may calculate from d if you can justify it, but reporting the difference in actual measurement units often makes the assumptions easier to evaluate (Lakens, 2022).

Not automatically. Baseline-outcome association and the planned adjustment can affect residual variability. Use an ANCOVA-appropriate calculation if ANCOVA is the primary analysis (Machin et al., 2009).

In this approximation, n varies inversely with δ²: halving the target difference increases the calculated n approximately fourfold, with other assumptions unchanged.

Research Planning & Study DesignNot sure a two-group calculation fits your design? A statistician checks the target difference, the SD source and the planned analysis, then confirms the required sample.

Request an Assessment

Research Planning & Study Design

Research Planning & Study Design at OnlineSPSS is carried out by in-house PhD-level statisticians. A statistically trained Research Coordinator reviews your request, and the analytical work, deliverables, timeline and fixed project fee are confirmed before work begins. The research question, interpretation and conclusions remain with you.

References

  1. Albers, C., & Lakens, D. (2018). When power analyses based on pilot data are biased: Inaccurate effect size estimators and follow-up bias. Journal of Experimental Social Psychology, 74, 187–195. https://doi.org/10.1016/j.jesp.2017.09.004
  2. Chow, S.-C., Shao, J., Wang, H., & Lokhnygina, Y. (2017). Sample size calculations in clinical research (3rd ed.). CRC Press. https://doi.org/10.1201/9781315183084
  3. Lakens, D. (2022). Sample size justification. Collabra: Psychology, 8(1), Article 33267. https://doi.org/10.1525/collabra.33267
  4. Machin, D., Campbell, M. J., Tan, S.-B., & Tan, S.-H. (2009). Sample size tables for clinical studies (3rd ed.). Wiley-Blackwell. https://doi.org/10.1002/9781444300710

Last reviewed November 2026 by the OnlineSPSS Statistical Team. Worked examples use hypothetical values and are not client data.

NEXT STEP

Need this done for
your study?

Share your research in about a minute and receive a complimentary assessment the same day: scope, timeline and one fixed fee.

No Commitment Required

Strictly Confidential

Fixed Project Fee

In-House PhD-Level Statisticians

Same-Day Response

Serving Researchers Since 2014