A sample-size calculation tells you how many observations you need to detect an effect of a given size with adequate power — conventionally 80% — at your significance level, usually α = 0.05. The three levers are effect size, power, and α: demanding to detect smaller effects, or wanting higher power, requires larger samples. A study that is too small risks missing a real effect (low power); planning the size in advance avoids wasted work. Results follow standard power-analysis formulas, validated to full precision.

About Sample Size

When to use it

Run a sample-size calculation before you collect data, as part of designing a study or A/B test. It turns a vague “how many do I need?” into a defensible number and protects you from an underpowered study that cannot detect the effect you care about.

The inputs explained

  • Effect size — the smallest difference worth detecting (e.g. Cohen's d, or a proportion change). This is the hardest input; base it on prior studies or a pilot. See effect size explained.
  • Power (1−β) — the probability of detecting a true effect; 0.80 is standard, 0.90 for high-stakes work.
  • Significance level (α) — the false-positive rate you tolerate, usually 0.05.
  • One- vs two-sided — two-sided is the safe default.

Worked example

To detect a medium effect (d = 0.5) between two groups with 80% power at α = 0.05 (two-sided), you need roughly 64 per group. Halving the effect to d = 0.25 roughly quadruples the requirement. Enter your targets above to get the exact number.

Common mistakes

  • Post-hoc power — computing power after a null result adds nothing; plan power in advance.
  • Guessing the effect size optimistically — inflated effect sizes produce samples that are too small.
  • Forgetting attrition — inflate the target to cover dropout and unusable responses.
  • Confusing the two error types — α is the false positive, β the false negative; see Type I & II errors.

Guide: Sample Size Calculation

Too small a sample produces unreliable results with wide confidence intervals — you may miss a real effect (Type II error). Too large a sample wastes resources and can make trivial differences statistically significant.

Calculating the required sample size before collecting data ensures your study has adequate statistical power to detect the effect you care about.

The margin of error (MOE) is the maximum acceptable error in your estimate. If you want to estimate a population mean with a margin of error of ±5 kg, your CI will be: (sample mean) ± 5 kg.

Smaller MOE → more precise estimate → larger required sample size. Halving the margin of error quadruples the required sample size.

You can estimate SD from:

  • Pilot study: Run a small preliminary study (n=20–30) to estimate SD
  • Published literature: Find similar studies and use their reported SD
  • Range rule: Estimate SD ≈ Range / 4 (for approximately normal data)
  • Expert knowledge: Use domain knowledge about the typical spread of the measurement

The required sample size for a proportion is maximised when p = 0.5. If you don't know the expected proportion, use p = 0.5 for the most conservative (largest) sample size estimate.

If you have a good estimate of the expected proportion from prior data (e.g. the baseline rate is around 30%), use that value to get a more accurate and possibly smaller required sample size.

A smaller margin of error gives a more precise estimate but requires a larger sample. Doubling precision (halving E) quadruples the required n.

p(1−p) is maximized at p = 0.5, so using it gives the largest (most conservative) sample size. If you have a better estimate, use it to reduce sample size.