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 α=0.05\alpha = 0.05, with 80% power.

StepValue
Control variance, 0.10×0.900.10 \times 0.900.0900
Treatment variance, 0.12×0.880.12 \times 0.880.1056
Sum0.1956
z0.975+z0.80z_{0.975} + z_{0.80}1.9600 + 0.8416 = 2.8016
Squared7.8489
7.8489×0.1956 / 0.0227.8489 \times 0.1956 \,/\, 0.02^23,838.10
Round up3,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)
Predict

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