Ask Mallard
Analysis method

Sample size for comparing two means

5 min read

Size two independent groups to detect a meaningful mean difference, using a common standard deviation and exact noncentral t power.

Fit

When to use it, and when not to

Use it when

  • You will compare a continuous outcome between two independent groups.
  • A common population standard deviation is a defensible planning assumption.

Not when

Before you start

What you need

Decide these first
  1. The meaningful difference and common standard deviationSupply delta, the absolute difference to detect, and sd, the common population SD. Both must be positive.
  2. The allocation ratioSupply ratio as group 2 divided by group 1. The default is equal allocation; the engine imposes a minimum of 0.05.
  3. The two-sided significance levelAlpha is the chance of rejecting a true null under the model. Supply a probability between zero and one.
  4. The target powerPower is the chance of rejecting the null at the assumed effect. The engine limits this input to 0.5 through 0.999.
It rests on these
  1. The units counted in the sample size are independent.How to check: Check for shared clinics, families or repeated observations before using an individual-level calculation.
  2. The effect and spread are defensible planning values.How to check: Use prior data and clinical judgment. Repeat the calculation with smaller effects and larger spreads.
  3. The t model uses normal outcomes with the same population variance in both groups.How to check: Check expected spread and extreme values. A Welch analysis needs its own unequal-variance sizing assessment.

Plain language

How it works

The engine compares a meaningful difference with its standard error under a common population SD. It uses both tails of the noncentral t distribution.

The test model

For group counts n1 and n2, the standard error is SD times the square root of (1/n1 + 1/n2). Degrees of freedom are n1 + n2 minus two.

What the engine counts

It searches integer counts, rounding group 2 up from the allocation ratio. Power at a supplied total splits that total by the ratio without integer rounding.

Match the planned analysis

The linked two-sample article teaches Welch. Its unequal-variance test differs from this sizing model. Choosing a sample-size method helps check whether this model fits.

The method at a glance
Sample size for comparing two means: Mean difference, common SD and allocation. Then Exact two-sided noncentral t power. Then Integer counts for two groups.Sample size for comparing two meansMean difference, common SDand allocationExact two-sided noncentralt powerInteger counts for twogroupsThis calculation assumes a common population SD. It does not size an unequal-variance Welch test exactly,despite linking to the two-sample t-test article. Clustering and incomplete outcomes need separateplanning.
Conceptual diagram. It shows the structure of the idea, not data from any study.

Worked example

A worked example

Invented for illustration
Setting
Two independent trial groups will provide a blood pressure outcome.
Question
How many people with observed outcomes are needed in each group?
Approach
Use delta = 5; sd = 10; ratio = 1; alpha = 0.05; power = 0.8. Differences and SD are in mmHg.
Result
The engine returns 64 in group 1 and 64 in group 2: 128 people total. Power at that total is 80.15%.
What it means
These are analyzable counts under a common-SD model. Recruitment losses need a separate allowance. The calculation does not establish clinical importance.

In practice

Recent studies PubMed search · not vetted

Searching PubMed…

Watch out

Common mistakes

The one to remember

This calculation assumes a common population SD. It does not size an unequal-variance Welch test exactly, despite linking to the two-sample t-test article. Clustering and incomplete outcomes need separate planning.

  • Using a standard error as the standard deviation.Instead: Supply the spread of individual outcomes in the outcome units.
  • Treating the sizing calculation as exact power for Welch.Instead: The engine pools the assumed variance. Assess unequal variances with a method matched to the planned analysis.

Inside Mallard

How Mallard uses this

For two means, Mallard returns both group counts, their total and power at a supplied total, conditional on the allocation ratio and common SD.

No Mallard code example points to this page.
Atlas node analysis.sample_size_two_means, the id a plan cue records.

Related Learn pages

Related designs and methods

Evidence

Sources & further reading

  1. Sample sizes for clinical trials with normal data. (opens in a new tab) · Stat Med · doi 10.1002/sim.1783
  2. Statistics review 4: sample size calculations. (opens in a new tab) · Crit Care · doi 10.1186/cc1521
Prepared with AI assistance. PubMed records checked on 2026-11-06 by title, authors, year and DOI: record verified, confirm it supports this use. No independent professional or methodological approval is claimed. The sources provide context for mean inference and sample-size planning. The worked figures come from Mallard’s engine, not a table copied from a source.
Last source review: 2026-11-06
AI-generated educational content
Mallard uses reputable methodological and reporting sources, but this material may contain errors or omit important context. Verify important methodological decisions with the cited sources and, when appropriate, a qualified research methodologist or statistician.