What is A/B Test Sample Size Calculation?
A/B tests require sufficient sample size to draw reliable conclusions. Too few samples lead to "false negatives" (missing real improvements) or "false positives" (mistaking ineffective changes as effective). Calculating sample size upfront prevents ending tests too early or wasting time on meaningless tests. Sample size calculation is the foundation of experimental design, ensuring statistically significant results.
Sample Size Calculation Formulas
This calculator uses statistical formulas to calculate required sample size:
Basic Sample Size Formula
n = 2 × (Zα/2 + Zβ)² × p(1-p) / δ²
Where:
n = Sample size per group
Zα/2 = Z-value for confidence level (95% → 1.96)
Zβ = Z-value for power (80% → 0.84)
p = Baseline conversion rate
δ = Minimum detectable difference
MDE and Absolute Difference
Absolute Difference = Baseline Conversion Rate × MDE
Example: Baseline rate 5%, MDE 10%
Absolute Difference = 5% × 10% = 0.5%
This means detecting a change from 5% to 5.5%
Test Duration Calculation
Test Duration = Total Sample ÷ Daily Traffic
Example: Need 20,000 total samples, daily traffic 2,000
Test Duration = 20,000 ÷ 2,000 = 10 days
Recommend at least 7 days to cover weekday/weekend differences
Why Calculate Sample Size?
- Avoid premature conclusions:Know how many samples are needed upfront to avoid stopping tests with insufficient data, leading to wrong decisions
- Control experiment costs:Know how long testing will take, plan resources and timeline reasonably, avoid waiting indefinitely
- Ensure statistical validity:Meeting sample requirements allows you to claim statistically significant results, making data more persuasive
- Optimize experiment design:Adjust experimental parameters based on acceptable MDE, finding balance between precision and efficiency
- Build team confidence:Using scientific methods to design experiments gives product decisions data support, reducing subjective judgment
Use Cases
- Website conversion optimization:Test landing page redesigns, CTA button colors, form designs and their impact on conversion rate
- E-commerce product pages:Test different product descriptions, image layouts, price display methods on add-to-cart rate
- App feature testing:Run Feature Flag tests before new feature launches to evaluate impact on user retention and engagement
- Email marketing optimization:Test different subject lines, send times, content layouts on open rates and click rates
- Ad creative testing:Test different ad copy, images, videos on CTR and conversions
- Pricing strategy experiments:Test different pricing plans on purchase rate and revenue to find optimal price point
Sample Size Reference for Common Scenarios
Below are sample size references for different baseline conversion rates and MDE combinations (95% confidence, 80% power):
| Baseline Rate | MDE 10% | MDE 20% |
|---|---|---|
| 1% | ~156,000/group | ~39,000/group |
| 3% | ~51,000/group | ~13,000/group |
| 5% | ~30,000/group | ~7,700/group |
| 10% | ~14,400/group | ~3,600/group |
| 20% | ~6,400/group | ~1,600/group |
Lower conversion rates and smaller differences to detect require more samples. If sample requirements are too high, consider accepting larger MDE or testing metrics with higher conversion rates.
Ways to Improve Experiment Efficiency
- Choose larger MDE:If only testing large improvements (e.g., 20%+), sample size decreases significantly, accelerating test cycles
- Test higher conversion rate metrics:Click rate is usually higher than purchase rate; test clicks first then estimate purchases to reduce required samples
- Use Multi-Armed Bandit method:Multi-Armed Bandit automatically allocates more traffic to better-performing versions during testing
- Stratified sampling for precision:Stratify users (e.g., new vs returning) and test separately to reduce variability and sample requirements
- Pre-filter audience:Only test on target user groups to reduce dilution of results by irrelevant traffic
- Use CUPED method:Use pre-experiment data to reduce variability, can reduce sample requirements by 30-50%
Common A/B Testing Mistakes
- Stopping tests too early:Correct approach: Even if you see significant differences, complete the planned sample size. "Peeking" significantly increases false positive rates
- Ignoring multiple comparison problem:Correct approach: When testing multiple variants simultaneously, adjust significance level (e.g., Bonferroni correction), otherwise false positives accumulate
- Test duration too short:Correct approach: Run at least one week to cover weekday/weekend differences, avoid specific date behavioral biases affecting results
- Ignoring external factors:Correct approach: Consider seasonality, promotions, market events and other external factors, choose relatively stable periods for testing
- Changing too many variables at once:Correct approach: Test one variable at a time. Multiple simultaneous changes make it impossible to determine which factor caused the impact
Related Terms
- Minimum Detectable Effect (MDE)
- The minimum lift you want this test to detect. Smaller MDE requires more samples.
- Confidence Level
- Probability of avoiding "false positives". 95% confidence means only 5% chance of mistaking ineffective changes as effective.
- Statistical Power
- Ability to detect real differences. 80% power means if there truly is an effect, 80% chance of detecting it.
- p-value
- Probability of observing current or more extreme results assuming null hypothesis is true. p < 0.05 is typically considered statistically significant.
- Conversion Rate
- Proportion of users completing target action. The most commonly used primary metric in A/B testing.
- Sequential Testing
- A method allowing multiple result checks during testing, but requires special statistical corrections to control false positives.
Frequently Asked Questions
Why does my calculation require so many samples?
Required sample size mainly depends on MDE size. Smaller MDE (detecting more subtle differences) exponentially increases required samples. If sample size is impractically high, consider accepting larger MDE — meaning only testing changes that could bring larger improvements.
Can I stop early if I see significant results before reaching sample size?
Not recommended. This practice called "peeking" significantly increases false positive rates. If you must check results early, use specialized methods like Sequential Testing, which adjusts significance thresholds to compensate for multiple checks.
What does 95% confidence level mean?
95% confidence level means if the null hypothesis is true (change has no effect), you have only 5% chance of incorrectly claiming it's effective (false positive). This is industry standard, but some cases may use 90% (exploratory tests) or 99% (high-risk decisions).
Why is 80% power recommended?
80% power is a balance between efficiency and accuracy. It means if change is truly effective, 80% chance of detecting it, 20% chance of missing it. Increasing to 90% requires about 30% more samples. Consider higher power for important decisions.
How should I set MDE?
MDE should be based on business value. Ask yourself: Is this improvement meaningful for the business? Usually 10-20% is recommended. If a 5% improvement is worth the investment, set it to 5%; but be prepared for more samples and longer testing time.
What if traffic is too low?
Several strategies: (1) Accept larger MDE, only test changes that could bring significant improvements (2) Test higher conversion rate metrics like click rate (3) Extend test duration (4) Use more efficient methods like CUPED (5) Focus testing on high-traffic pages.