Sample Size for Comparing Two Means
How many subjects you need per group to detect a given difference between two averages.
Results
The dashed line marks the value you entered.
What this tool does
Two things decide this, and only two: how big a difference you care about, and how much the measurements scatter within each group. Their ratio is Cohen's d, and once you have that the sample size follows. The relationship is unforgiving — the sample needed grows with the square of the scatter and shrinks with the square of the difference, so halving the gap you want to detect costs you four times the participants. This uses the normal approximation, which runs a little optimistic for small samples; if the answer comes out under about thirty per group, treat it as a floor rather than a target.
Formula
n per group = 2 × (z for confidence + z for power)² × spread² ÷ difference²
Variables
| Symbol | Meaning | Unit |
|---|---|---|
sd | Spread within each group | — |
dl | Difference you want to detect | — |
za | How sure you want to be | — |
zb | Chance of catching a real difference | — |
N | People needed in each group | — |
T | People needed in total | — |
D | Effect size (Cohen's d) | — |
Worked example
- Spread within each group10
- Difference you want to detect5
- How sure you want to be1.959963984540054
- Chance of catching a real difference0.8416212335729143
- People needed in each group63
- People needed in total126
- Effect size (Cohen's d)0.5000
Limitations
- The result is an estimate based only on the values you type. Real situations often include factors this calculator does not know about.
- Standard deviation and variance are calculated for a sample (dividing by n − 1). For a full population, divide by n instead.
- The calculation runs at full precision and only the display is rounded. If you copy an intermediate value and retype it, small differences can appear.