17/36
Part 3 of 6 · Quick numbersLearn
A worked example
10% to 12% needs 3,839 users per arm, 7,678 in all
A sign-up flow converts 10% of visitors. The team wants to detect a lift to 12%, two-sided at , with 80% power.
| Step | Value |
|---|---|
| Control variance, | 0.0900 |
| Treatment variance, | 0.1056 |
| Sum | 0.1956 |
| 1.9600 + 0.8416 = 2.8016 | |
| Squared | 7.8489 |
| 3,838.10 | |
| Round up | 3,839 per arm, 7,678 in all |
In simulation, 3,839 per arm catches the lift 80% of the time
Check it the way you'd check any function: simulate. Draw both arms' conversions many times, run the pooled z-test from the ab-test lesson on each draw, and count how often it comes out significant.
import numpy as np
from statistics import NormalDist
def simulate(n, p1, p2, reps=200_000, alpha=0.05, seed=0):
rng = np.random.default_rng(seed)
# A's conversions in each test
a = rng.binomial(n, p1, size=reps)
b = rng.binomial(n, p2, size=reps)
diff = (b - a) / n
pooled = (a + b) / (2 * n)
# pooled z-test
z = diff / np.sqrt(pooled * (1 - pooled) * 2 / n)
significant = np.abs(z) > NormalDist().inv_cdf(1 - alpha / 2)
return significant.mean(), diff[significant].mean()
share, _ = simulate(3839, 0.10, 0.12)
print(share)
share, _ = simulate(3839, 0.10, 0.10)
print(share)
3,839 per arm and a true 2-point lift, over 200,000 simulated tests. What share comes out significant?
Pick one to see what it prints.
Pick an answer above to see the rest