
A/B Testing Sample Size Formula
Learn how an A/B test sample size and estimated monthly test duration are calculated from conversion rate, uplift, confidence, power, and traffic.
This calculator estimates the visitors needed to compare one control version with one variant. It helps determine whether available eligible monthly traffic is sufficient to detect a selected conversion-rate uplift at the chosen confidence and statistical power.
- 100% Free
- No Sign-Up Required
- Private & Secure
- Mobile Friendly
Required Visitors per Variant
Where:
The formula estimates the number of visitors needed in each version by comparing the baseline conversion probability with the expected variant probability. Smaller differences and stricter confidence or power settings increase the required sample.
Variables Explained
| Variable | What It Means | Unit |
|---|---|---|
| n - Required visitors per variant | Estimated number of eligible visitors needed in the control group and separately in the variant group. | visitors |
| p₁ - Baseline conversion probability | The control conversion rate expressed as a decimal probability. | percent |
| p₂ - Expected variant conversion probability | The baseline probability after applying the selected relative uplift. | percent |
| p̄ - Average conversion probability | The average of the baseline and expected variant probabilities. | percent |
| z_confidence - Confidence z-score | The z-score representing the selected two-sided confidence level, such as 1.96 for 95%. | N/A |
| z_power - Power z-score | The z-score representing the selected statistical power, such as 0.84 for 80%. | N/A |
| d - Conversion-rate difference | The absolute decimal difference between the expected variant and baseline conversion probabilities. | percent |
| V - Eligible monthly visitors | The visitors expected to enter the experiment each month after applying the test traffic share. | visitors |
Step-by-Step Calculation
Convert the baseline rate to a probability
A displayed percentage such as 3% becomes 0.03 for use in the calculation.
baselineRate = baselineConversionRate / 100
Calculate the expected variant rate
The minimum detectable uplift is relative to the baseline. A 10% uplift on a 3% baseline produces a 3.3% expected variant rate.
variantRate = baselineRate * (1 + minimumDetectableUplift / 100)
Find the average and difference in rates
The average rate is used in the variance estimate, while the difference is the effect the test is designed to detect.
averageRate = (baselineRate + variantRate) / 2; conversionRateDifference = variantRate - baselineRate
Calculate visitors needed in each variant
This two-proportion approximation estimates the sample for a 50/50 control-versus-variant test and rounds up to a whole visitor.
sampleSizePerVariant = ceil(pow(confidenceZScore * sqrt(2 * averageRate * (1 - averageRate)) + powerZScore * sqrt(baselineRate * (1 - baselineRate) + variantRate * (1 - variantRate)), 2) / pow(conversionRateDifference, 2))
Calculate total visitor requirement
Both the control and variant need the calculated sample size.
totalRequiredVisitors = sampleSizePerVariant * 2
Estimate the duration in months
The combined sample requirement is divided by monthly traffic that is actually eligible for the experiment.
eligibleMonthlyVisitors = monthlyVisitors * testTrafficShare / 100; estimatedTestMonths = totalRequiredVisitors / eligibleMonthlyVisitors
Example: 3% baseline rate and 10% detectable uplift
Convert the baseline rate
3 / 100
0.03
Calculate the expected variant rate
0.03 × (1 + 10 / 100)
0.033
Find the detectable difference
0.033 − 0.03
0.003
Calculate the sample per variant
ceil((1.96 × sqrt(2 × 0.0315 × 0.9685) + 0.84 × sqrt(0.03 × 0.97 + 0.033 × 0.967))² / 0.003²)
53,151 visitors per variant
Calculate total visitors
53,151 × 2
106,302 visitors
Estimate duration
106,302 / (100,000 × 100 / 100)
1.1 months
Final Result
The test needs about 53,151 visitors in each variant, 106,302 visitors in total, and approximately 1.1 months at the stated eligible monthly traffic.
Assumptions
- ✓The experiment has exactly two versions: one control and one variant.
- ✓Eligible traffic is allocated evenly, with approximately 50% assigned to each version.
- ✓The confidence z-score represents a two-sided comparison of conversion rates.
- ✓The baseline conversion rate, visitor mix, and traffic quality remain reasonably stable while the test runs.
- ✓Monthly eligible traffic is representative of the traffic available during the experiment.
Limitations
- !This is a planning approximation and does not guarantee a statistically valid or commercially useful outcome.
- !Uneven allocation, multiple variants, repeated interim checks, and multiple metrics may require a different design and more traffic.
- !Seasonality, campaigns, product changes, tracking changes, or audience shifts can make actual duration differ from the estimate.
- !Very low conversion rates and very small effects may be sensitive to modeling choices and data-quality issues.
Common Mistakes to Avoid
Entering an absolute percentage-point change as though it were a relative uplift; a 10% uplift on a 3% baseline means 3.3%, not 13%.
Using total site traffic instead of the visitors who are eligible to enter the experiment.
Assuming the monthly duration is per variant rather than based on total eligible traffic split between both variants.
Choosing a very small uplift without recognizing that it can substantially increase the required sample.
Stopping as soon as an interim result looks positive instead of following a preplanned analysis approach.
Related Formulas
Frequently Asked Questions
What is the A/B testing sample size formula?
It is a two-proportion sample-size approximation that uses the baseline conversion probability, expected variant probability, confidence z-score, and power z-score to estimate visitors required in each group.
How do I calculate a 10% uplift from a 3% conversion rate?
Multiply 3% by 1.10. The expected variant rate is 3.3%, which is a 0.3 percentage-point absolute increase.
Why does the formula use both confidence and power?
Confidence controls the selected false-positive threshold, while power represents the chance of detecting the planned effect if it exists. Higher settings generally require more visitors.
Why is required sample size rounded up?
A partial visitor is not possible, and rounding up avoids understating the target sample.
How is A/B test duration in months calculated?
The calculator divides total required visitors across both variants by the number of eligible visitors expected to enter the test each month.
Does this formula work for multivariate or multi-variant tests?
No. It is designed for a single control and one variant with equal allocation. More variants usually require a different analysis plan.
Ready to calculate your result?
Use the calculator to get instant results with your own inputs.