Home Math & Calculator Tools Sample Size Calculator
n=?
Math

Sample Size Calculator

Calculate required sample size for surveys (proportion), mean-comparison studies, and A/B tests. Includes power analysis with an adjustable power slider, sample size vs power chart canvas, and accounts for dropout/attrition rates.

📊 3 study types⚡ Power analysis📈 Power chart📋 Attrition adjustment
Switch Tool:
🔒 100% Private — All calculations run in your browser. Nothing sent to any server.

📖 How to Use the Sample Size Calculator

  1. 1
    Choose your study type

    Proportion survey (e.g. opinion polls, elections): enter margin of error, confidence level, and expected proportion. Mean comparison (e.g. drug trials, A/B testing of continuous metrics): enter effect size (Cohen's d), α, and power (1−β). A/B test (conversion rates): enter baseline rate, minimum detectable effect, α, and power.

  2. 2
    Set statistical parameters

    Confidence level (1−α): typically 95% (α=0.05) or 99%. Statistical power (1−β): typically 80% or 90% — the probability of detecting a real effect. Adjust the power slider to see how sample size changes. For two-group studies, the result is per group (total = 2×n).

  3. 3
    View the power chart and adjustments

    A canvas plots sample size vs statistical power, showing the curve for your chosen parameters. The tool also calculates an inflated sample size accounting for expected dropout rate (default 10%): n_adjusted = n/(1−dropout). A sensitivity table shows required n at different power levels (70%, 80%, 90%, 95%).

💡 Key Reference

Power (1−β)Meaning
0.80Standard minimum
0.90Preferred in medicine
0.95Regulatory trials
Type II error β1 − power

Frequently Asked Questions

Why does sample size matter?

Sample size directly affects the precision and reliability of study results. Too small a sample: insufficient power (high chance of missing a real effect — Type II error), wide confidence intervals, unreliable estimates. Too large a sample: wastes resources and may detect trivially small effects that are statistically significant but practically meaningless. The correct sample size is the minimum needed to detect a meaningful effect with adequate confidence and power. This is calculated BEFORE data collection in proper study design.

What is statistical power?

Statistical power (1−β) is the probability of correctly rejecting the null hypothesis when it is false — the probability of detecting a real effect. Power of 0.80 means: if the true effect exists, you have an 80% chance of finding it statistically significant. The remaining 20% is β, the Type II error rate. Power depends on: sample size (larger → more power), effect size (larger → more power), α level (higher α → more power but more false positives), and variability (lower variance → more power). Convention is 80% power (some fields use 90% or 95%).

What is Cohen's d and how do I estimate it?

Cohen's d is a standardised effect size for comparing two means: d = (μ₁−μ₂)/σ_pooled. Benchmarks: d=0.2 (small), d=0.5 (medium), d=0.8 (large). If you don't know the expected effect size, use a pilot study, prior literature, or the minimum practically significant difference (e.g. 2 points on a 0-100 scale when SD≈10 gives d=0.2). Over-estimating d leads to underpowered studies; under-estimating wastes resources. Cohen's d assumes equal variances and normally distributed data.

What is the formula for survey sample size?

For estimating a proportion with margin of error E at confidence level (1−α): n = z² × p(1−p) / E². Where z is the critical value (z=1.96 for 95% CI), p is the expected proportion (use 0.5 for maximum conservatism), and E is the desired margin of error. Example: 95% CI, E=±5%, p=0.5: n = (1.96)² × 0.25 / (0.05)² = 3.8416 × 0.25 / 0.0025 = 384. For a finite population N: n_finite = n / (1 + (n−1)/N). For populations over 10,000, the finite population correction rarely changes the result significantly.

How does attrition affect sample size?

Attrition (dropout) is common in longitudinal studies, clinical trials, and surveys with multiple data collection points. If you need n complete responses but expect k% dropout, you need to recruit n/(1−k/100) participants. With 20% dropout and n=200 needed: recruit 200/0.80 = 250. For clinical trials, regulatory guidelines (FDA, EMA) require pre-specified handling of missing data (intention-to-treat vs per-protocol analysis). High attrition (>20%) can introduce bias even with a large sample if dropouts differ systematically from completers.

What is the difference between one-sided and two-sided tests for sample size?

Two-sided (two-tailed) tests: use when you want to detect an effect in either direction (treatment better OR worse than control). More conservative — requires a larger sample. One-sided (one-tailed) tests: use only when you have a strong theoretical or safety reason to test in only one direction (treatment can only be better, e.g. adding a proven drug). Smaller sample needed. The sample size formula changes because you use z_α instead of z_α/2. If using one-sided, this must be pre-specified and justified before data collection — switching after seeing results is p-hacking.