A/B test sample size calculator
calculate_sample_sizeDetermine required sample size per variant for A/B conversion-rate tests from baseline rate, MDE, alpha, power, variant count, Bonferroni adjustment, and allocation ratio.
Instructions
Exact sample size per variant for an A/B test on a conversion rate (two independent proportions): baseline rate, minimum detectable effect (relative or absolute), alpha, power, one or two-sided, several variants with optional Bonferroni, and unequal allocation. Uses the pooled/unpooled normal formula (same as R power.prop.test) and also reports the figure Evan Miller's calculator gives, so the two can be reconciled.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mde | Yes | Minimum detectable effect. Relative by default (0.10 = a 10% lift); set mde_type "absolute" for percentage points as a proportion (0.01 = 1 point). | |
| alpha | No | Significance level, default 0.05. | |
| power | No | Statistical power, default 0.80. | |
| sided | No | two-sided (default) or one-sided test. | two |
| mde_type | No | relative (default) or absolute. | relative |
| variants | No | Number of arms including control. 2 = A/B, 3 = A/B/C. | |
| bonferroni | No | Split alpha across the variant-vs-control comparisons (Bonferroni). | |
| baseline_rate | Yes | Control conversion rate as a proportion, for example 0.042 for 4.2%. | |
| allocation_ratio | No | Users in each variant per user in control. 1 = even split. |