Sample Size Calculator

Survey & A/B Test Power Analysis Finite Population Free · No Signup

Free online sample size calculator for surveys, A/B tests, and research studies. Compute required sample size with confidence level, margin of error, power analysis, finite population correction, step-by-step formulas, interactive Plotly chart, and Python export.

Sample Size
Use 0.5 for maximum (most conservative)
e.g. ±5% = 0.05
For finite population correction

Result

📊

Enter parameters and click Calculate

Compute required sample size for surveys, A/B tests, and research studies.

Sample Size Visualization

Python Compiler

What Is Sample Size?

Sample size is the number of observations or respondents needed in a study to draw reliable conclusions about a population. Choosing the right sample size balances statistical rigor with practical constraints like cost and time.

Population (N) Sample (n)
🎯

Precision

Larger samples yield narrower confidence intervals and smaller margins of error, giving more precise estimates.

Power

Adequate sample size ensures enough statistical power to detect real effects and avoid false negatives.

⚖️

Efficiency

Too large wastes resources; too small produces unreliable results. Proper calculation finds the optimum.

Sample Size Formulas

Survey (proportion):  n = z² × p(1−p) / E²
z = critical value, p = expected proportion, E = margin of error
Mean estimation:  n = z² × σ² / E²
σ = population standard deviation, E = margin of error
A/B test (two proportions):  n = (zα/2 + zβ)² × [p₁(1−p₁) + p₂(1−p₂)] / (p₁−p₂)²
Per group. zβ from desired power (e.g. 0.84 for 80%)
Compare means:  n = 2(zα/2 + zβ)² × σ² / δ²
Per group. δ = minimum detectable difference

Key Factors Affecting Sample Size

FactorEffect on Sample SizeExplanation
Confidence LevelHigher → larger n99% confidence requires more data than 90% for the same precision
Margin of ErrorSmaller → larger nHalving the margin of error quadruples the required sample size
VariabilityHigher → larger nMore variable populations need larger samples to estimate accurately
PowerHigher → larger n90% power needs about 30% more samples than 80% power
Effect SizeSmaller → larger nDetecting small differences requires substantially more observations

Statistical Power

Statistical power (1 − β) is the probability that a study will detect a true effect when one exists. Under-powered studies waste resources because they are unlikely to produce significant results even when the effect is real.

Worked Example: A/B test with p₁=0.10, p₂=0.12, 95% confidence. Compare 80% vs 90% power.
z0.025 = 1.96
80% power: zβ = 0.842 → n ≈ 3,623 per group
90% power: zβ = 1.282 → n ≈ 4,862 per group
Going from 80% to 90% power increases sample size by ~34%.

Rule of thumb: Use 80% power as a minimum for most studies. Use 90% for confirmatory trials or when the cost of a false negative is high.

Practical Tips

📋 Surveys

Use p=0.5 when unsure of the true proportion. Apply finite population correction when sampling >5% of the population. Account for expected non-response by inflating the sample size (e.g. divide by expected response rate).

🔍 A/B Tests

Define the minimum detectable effect before starting. Smaller effects need much larger samples. Consider using sequential testing to stop early if the effect is large. Always run the test for the full planned duration.

🏥 Clinical Research

Regulatory agencies typically require 80–90% power. Account for dropout rates by over-enrolling. Pre-register your sample size calculation. Use interim analyses with appropriate alpha-spending functions.

Frequently Asked Questions

For a typical survey with 95% confidence and 5% margin of error, use p=0.5 for maximum conservatism. This gives about 385 respondents for a large population. Smaller margins need larger samples.
Using p=0.5 maximizes the product p×(1−p), which gives the largest possible sample size. This is the most conservative estimate when you do not know the true proportion in advance.
For large populations, sample size depends mainly on confidence and margin of error. Finite population correction matters when sampling more than about 5% of the population, reducing the required size.
Power (1−β) is the probability of detecting a real effect. 80% power means a 20% chance of missing a true effect. Higher power requires larger samples but gives more reliable results.
You need the baseline conversion rate, the minimum detectable effect, and desired power. Smaller effects need much larger samples. A 1% improvement from 10% to 11% needs about 15,000 per group at 80% power.
You can accept a wider margin of error, lower confidence level, or lower power. For A/B tests, you can also focus on detecting larger effects only or use sequential testing methods.

Support This Free Tool

Every coffee helps keep the servers running. Every book sale funds the next tool I'm dreaming up. You're not just supporting a site — you're helping me build what developers actually need.

500K+ users
200+ tools
100% private
Privacy Guarantee: Private keys you enter or generate are never stored on our servers. All tools are served over HTTPS.