Sample Size Estimation for Two-Group Comparison (t-test / Proportion Test)
Per-group sample size for comparing two means:
n = 2 × (z₁₋α∕₂ + z₁₋β)² / d²
where d = |μ₁ − μ₂| / σ is the standardized effect size (Cohen’s d).
At α = 0.05, z₁₋α∕₂ = 1.960; at 80% power, z₁₋β = 0.842, giving the commonly cited
n ≈ 15.7 / d²
What this formula tells you: Sample size scales inversely with the square of the effect size. Halving the effect size quadruples the required sample size. This is why detecting a small difference is so costly.
Before you use this:
- Where does σ come from? It must come from a pilot experiment or comparable published data. A σ pulled from thin air produces a meaningless n.
- This is a normal approximation. It slightly underestimates at small sample sizes (n < 20); the rigorous approach is to iterate with the t-distribution. This tool will flag results when the estimate is small.
- The result is per group, not the total. In animal studies, add an allowance for expected attrition on top of this.
- Sample size cannot be determined after the fact. Running the experiment, finding a non-significant result, and then calculating how many subjects were “needed” is post-hoc power analysis and is statistically meaningless. Sample size must be fixed before the experiment begins.
FAQ
What if I don't know σ?
Look up published data from comparable experiments, or run a small pilot study to estimate it. Without a reliable σ, the sample size calculation is meaningless.
The result says 3 per group — is that reliable?
Mathematically it follows from the formula, but the normal approximation underestimates at small n, and n = 3 is too small to test distributional assumptions. Use t-distribution iteration and consult a statistician.
The experiment was non-significant. Can I back-calculate the required sample size?
Not as a valid conclusion. This is post-hoc power analysis and carries no statistical validity. Sample size must be determined before the experiment begins.
Related tools
Community Diversity Index Calculator (Shannon / Simpson / Chao1)
Paste a species abundance table and compute Shannon, Simpson, evenness, and Chao1 richness estimates.
Enrichment Significance Test Calculator — Hypergeometric Distribution / Fisher's Exact Test
Enter background gene count, pathway gene count, list size, and overlap to compute p-value, fold enrichment, and expected overlap.
qPCR Amplification Efficiency Calculator — Standard Curve Slope to E, Pfaffl Relative Quantification
Fit a standard curve from serial dilutions to calculate amplification efficiency E and R²; apply the Pfaffl method for efficiency-corrected relative quantification.
Buy me a coffee