Skip to content
echogeco
Metrics and analytics · Experiments

Sample size per arm

Turn a baseline rate and the lift worth shipping for into users per arm, and read the calendar off the result.

codemediumExercise · 4 min · 26 of 59
On this page

Every experiment the team plans starts with the same sum, and twice last quarter the sum was done wrong by a factor of a hundred. The function below is the sum done once.

The situation

The analytics team runs experiments for the drafting assistant on three kinds of metric: the help-centre self-serve rate for one tenant (5.0% baseline, 2,000 visitors a day), draft acceptance across all agents (40% baseline), and trial-to-paid conversion on the self-serve tier (6% baseline). Each test is sized in a planning meeting by whoever has the formula in a notebook, and twice last quarter the minimum detectable effect was entered as an absolute gap rather than a fraction of the baseline, so a test that needed 30,000 users per arm was planned with 76, declared "no significant difference" after a day, and the feature was dropped.

Assume the standard settings of 5% significance and 80% power, and the rule of thumb from reading an experiment: users per arm n ≈ 16 × σ² ÷ δ², with σ² = p × (1 − p) for a rate metric and δ = p × lift the absolute gap to detect. A baseline is measured to about two significant figures, so the answer carries two.

The question

Write the function and use it to say how long the help-centre test runs at 2,000 visitors a day.

def solve(baseline_rate, relative_lift):
    """Users per arm needed to detect a relative lift on a rate metric.

    baseline_rate: the control's rate as a fraction, 0 < p < 1 (0.05 for 5%).
    relative_lift: the minimum detectable effect as a fraction of the baseline (0.10 for +10%).
    Returns an int: the rule-of-thumb count per arm, rounded to two significant figures.
    """
solve(0.05, 0.10)  ->  30000
solve(0.20, 0.05)  ->  26000
solve(0.50, 0.10)  ->  1600

A strong answer · Rubric · Where answers go wrong · Solution

Write your answer first, then open