A prep site lists a Netflix data science onsite question, posted in October 2025, on designing and powering a frequency-cap experiment: "Design an experiment and provide power calculations that account for interference and clustering" (1 source). A candidate's report of a Netflix data science onsite, apparently the same one, says both technical cases were about ad frequency caps (1 report). Interference and clustering adjust the answer. The calculation they adjust comes first, and our version of it reads like this:
A sign-up flow converts 10% of visitors, and we want to detect a lift to 12%. Write sample_size_per_arm(p_baseline, mde, alpha=0.05, power=0.8, relative=False): the users each arm needs for a two-sided test. Then write days_to_run: how long the test runs, in whole weeks, when 1,500 new users arrive a day and half of them enter it.
Too few users, and a real improvement disappears into the noise. Too many, and you spend weeks of traffic that another test needed.
The practice comes in four levels. Level 1 sizes the test at two-sided alpha 0.05 and 80% power, with each arm's own variance, and rounds up to whole users. Level 2 takes any alpha and power. Level 3 takes a lift stated as a share of the baseline, with relative=True. Level 4 adds days_to_run, which turns users into days, in whole weeks.
From four choices to a number of daysInteractive
→
→
you choose = a 10% baseline, a lift to 12%, two-sided alpha 0.05, 80% power.
You don't write it yet. The lesson starts with the two ways a test can be wrong, builds the formula one piece at a time, then turns users into days and answers the follow-ups: uneven splits, CUPED, clusters and ratio metrics. At the end you solve the whole problem, level by level, in an interview simulation with a 30-minute timer.
This lesson builds on the A/B test lesson, which read a finished test with the two-proportion z-test. This one decides, before the test starts, how much data that test gets. The CUPED lesson comes next and gets the same answer from fewer users.
A test can be wrong in two ways, and you choose how often
A test can say significant when nothing changed, or miss a change that's real. Here are both, as a table.
No real effect
A real effect the size of the MDE
Significant
false positive, probability α
true positive, probability 1−β: the power
Not significant
correct, probability 1−α
false negative, probability β
Each column is one state of the world. Each row is what the test says. You pick the two error rates before the test starts.
Predict
At alpha = 0.05, how many of twenty changes that do nothing still come out significant?
Alpha is the false positive rate. At α=0.05, one change in twenty that does nothing still comes out significant, half of them looking like wins. Lowering alpha buys you fewer launches of pure noise.
Beta is the false negative rate when the true effect is exactly the minimum detectable effect, the MDE: the smallest true effect the test is built to catch. Power is 1−β, the chance you catch that effect. The usual 80% means a test sized correctly still misses one real MDE-sized win in five. Raising power buys you fewer good ideas killed by bad luck.
Here are both columns as a picture. Each curve shows where the measured lift lands if you could run the same test many times.
Pick an answer above to see the rest
Predict
A true 2-point lift, 3,839 users per arm. What share of tests land past the bar and come out significant?
Where the measured lift lands, 3,839 users per arm (a sketch)
barbar
no real effect 2.5% past each bar: alpha
a true 2-point lift 80% past the bar: the power. 20% short of it: beta
-2-101234
points
The test calls a result significant when it lands past the bar, at about 1.4 points on either side of zero.
With no real effect, 2.5% of the curve spills past each bar, 5% in all: alpha. With a real 2-point lift the whole curve moves right. The part short of the bar is beta, 20%, and the part past it is the power, 80%.
In the editor, results holds 30 tests as pairs: whether the effect was real, and whether the test came out significant. Write error_rates(results): alpha and power, read off the batch.
You can tighten either error rate. Guess what the usual step costs.
Predict
Raising power from 80% to 90% costs about how many more users?
Both cost users. Here's what one test, a conversion rate going from 10% to 12%, needs as you tighten them:
Settings
(z1−α/2+z1−β)2
Users per arm
Versus the default
α=0.05, 80% power
7.85
3,839
1.00x
α=0.05, 90% power
10.51
5,139
1.34x
α=0.05, 95% power
12.99
6,355
1.66x
α=0.01, 80% power
11.68
5,712
1.49x
α=0.01, 90% power
14.88
7,277
1.90x
α=0.10, 80% power
6.18
3,024
0.79x
z1−α/2 is the ab-test lesson's interval multiplier: the point that leaves α/2 of the normal curve above it, 1.96 at α=0.05. z1−β is the same kind of point for power, 0.84 at 80%. The formula chapter shows why their sum, squared, sets the number of users.
Pick an answer above to see the rest
Power is always power to detect one effect size
80% power is a promise about one true lift. Ask what happens at another.
Predict
A test sized for a 2-point lift meets a true 3-point lift. How often does it catch it?
Power of the test sized for 2 points, by the true lift
0.25 points
6.5%
0.5 points
11%
1 point
30%
1.5 points
56%
2 points
80%
3 points
98%
The test sized for 2 points has 80% power at 2 points only. It catches a 1-point lift 30% of the time and a 3-point lift 98% of the time.
In the editor, write significant_share(true_lift, se, bar): the share of the measured lift's curve past either bar, which is the test's power at any true lift. It uses the sketch's rounded spread and bar, 0.714 and 1.4, so it prints 0.288 and 0.987 where the bars show 30% and 98%.
StatQuest's picture of power as the overlap between two distributions, then how sample size changes that overlap.
Statistical Power, Clearly Explained!!! · StatQuest with Josh Starmer · May 2020YouTube
Pick an answer above to see the rest
The minimum detectable effect is a decision you make
Alpha and power are settings. The third input, the lift to detect, is a judgment.
Predict
Who picks the minimum detectable effect?
Take a sign-up flow that converts 10% of visitors. A redesign that lifts it to 12% might be worth shipping, and one that lifts it to 10.1% might not be worth the engineering. That line is the MDE: the smallest true effect the test is built to catch at the stated power. Nothing in the data tells you what it is, so ask what lift would change the decision.
A 2% lift can mean 2 points or 2% of the baseline
Detect a 2% lift on a 10% baseline, read two ways
2 points
3,839
2% of 10%
356,332
Users per arm. 2% of 10% is 0.2 points, so it costs 93 times the users.
The same words name two sizes, so pin down what lift means. Here is the request detect a 2% lift on a 10% baseline, read both ways:
Reading
Treatment rate
Δ
Users per arm
2 points, absolute
12%
0.02
3,839
2% of 10%, relative
10.2%
0.002
356,332
The two readings differ by a factor of 93. Δ, delta, is the lift in rate units.
The practice function takes an absolute lift. If you're handed a relative one, convert it once at the top: a relative lift r on a baseline p is Δ=r⋅p, so 2% of 10% is 0.002.
In the editor, write treatment_rate(p_baseline, lift, relative=False): the one place a relative lift gets converted.
The formula: how far the true lift must sit from zero
The formula comes from one picture: where the true lift has to sit for the test to catch it.
Predict
At two-sided alpha 0.05 and 80% power, how many standard errors must the true lift sit from zero?
How far the true lift must sit from zero
0122.8 SE
10% to 12%, 3,839 per arm: one SE is 0.71 points
1.96
0.84
1.96 SE: zero to the bar, 1.40 points0.84 SE: the bar to the true lift, 2.00 points
Picture the measured difference d^, d-hat, between the two arms' rates. If the true lift is Δ, then d^ is roughly normal around Δ. SE, the standard error, is how far a typical estimate lands from the truth. The arms are independent, so the variance of d^ is the sum of theirs, and SE is its square root:
SE=np1(1−p1)+p2(1−p2)
Here p1 is the baseline rate, p2 the treatment rate and n the users in each arm: the ab-test lesson's pA, pB and nA=nB.
The test calls the result significant when d^ lands more than z1−α/2 standard errors from zero. That's the bar in the figure.
For d^ to clear the bar with probability 1−β, the bar has to sit z1−β standard errors below the truth. So the truth has to sit z1−α/2+z1−β standard errors from zero:
Δ=(z1−α/2+z1−β)SE
Square both sides, put in the SE and solve for n. Write σ12=p1(1−p1) and σ22=p2(1−p2) for the two arms' variances, with p2=p1+Δ:
n=Δ2(z1−α/2+z1−β)2(σ12+σ22)
In words: the two z's added and squared, times the two variances added, over the lift squared.
At α=0.05 and 80% power the z's add to 1.96 + 0.84 = 2.80. So the MDE has to sit 2.8 standard errors from zero, the same anchor Gelman and Carlin use.
The test could also come out significant in the wrong direction. At the MDE that chance is about one in a million, so the formula leaves it out.
In the editor, write ses_from_zero(p_baseline, mde, n): how many standard errors the true lift sits from zero, with n users per arm.
The 2.8 is two z's added. Here they are, from Python's normal curve.
from statistics import NormalDistprint(round(NormalDist().inv_cdf(0.975), 3))print(round(NormalDist().inv_cdf(0.80), 3))print(round(NormalDist().inv_cdf(0.90), 3))
Predict
inv_cdf(0.975) is 1.96. What's inv_cdf(0.80), the point with 80% of the curve below it?
Pick one to see what it prints.
NormalDist().inv_cdf(q) turns a share into a point: the point with a share q of the normal curve below it.
z1−α/2 is the significance bar. A two-sided test splits α between the two tails, so at 0.05 it's NormalDist().inv_cdf(0.975), 1.960.
z1−β is how far past the bar the truth has to be for the estimate to clear it often enough. At 80% power it's NormalDist().inv_cdf(0.80), 0.842, and at 90% it's 1.282.
A one-sided test puts all of alpha in one tail, so its bar moves in. At 1.96 each tail holds 2.5%. Switch to one-sided and slide z to 1.645, and the one tail holds 5%:
Two-sided and one-sided bars at alpha 0.05Interactive
-3-2-10123z
Both tails beyond 1.96: 2.50% each, so p = 5.00%.
In the editor, write z_sum(alpha=0.05, power=0.8): the two z's added, for any two-sided alpha and power.
CheckpointThe two z's
Write z_sum(alpha=0.05, power=0.8). It returns the number of standard errors the MDE has to sit from zero: z1−α/2+z1−β, for a two-sided test at alpha with the given power. At the defaults it's 1.960 + 0.842 = 2.802.
Pick an answer above to see the rest
Each arm brings its own variance, and p(1 - p) sets how noisy its users are
The other half of the formula is the variance, and each arm brings its own.
Predict
Which conversion rate has the noisiest users?
One user's variance, p(1 - p), at each rate
2%
0.0196
10%
0.0900
12%
0.1056
30%
0.2100
50%
0.2500
90%
0.0900
A conversion rate's variance is p(1−p), where p is the rate.
A lift from 10% to 12% moves the treatment arm toward 50%. So the treatment arm is noisier than the baseline: 0.1056 against 0.0900. Each arm brings its own variance to the sum.
Some calculators put the pooled rate in the alpha term, as the ab-test lesson's z statistic does, and land a couple of users away: 3,841 here. The practice problem uses the unpooled form, and either is fine in an interview if you say which one you used.
In the editor, write arm_variances(p_baseline, mde): both arms' p * (1 - p) added.
CheckpointBoth arms' variance
Write arm_variances(p_baseline, mde): σ12+σ22, each arm's p(1−p) added up. The treatment rate is the baseline plus the absolute lift mde. For 10% to 12% it's 0.0900 + 0.1056 = 0.1956.
Pick an answer above to see the rest
The formula gives a minimum, so round up
The formula's answer is rarely a whole number, and the way you round it matters.
Users per arm
3,838
3,838.10
3,839
Power
79.999%
exactly 80%
just over 80%
Comes from
int(), round()
the formula
math.ceil
The formula gives the smallest n that reaches the target power, and users come whole. Anything below it falls short, so round up.
In the editor, z_sum and arm_variances are ready. Write sample_size_per_arm(p_baseline, mde, alpha=0.05, power=0.8) from them, rounded up.
CheckpointUsers per arm, rounded up
Finish sample_size_per_arm(p_baseline, mde, alpha=0.05, power=0.8) from the two pieces in the editor. It's the squared z's times both arms' variance, over the lift squared, returned as the whole number of users that reaches the target power.
Put together, the formula is one short function
Here are the pieces in one function, the shape level 1 of the practice asks for.
10% to 12% needs 3,839 per arm. About how many does a 1-point lift, 10% to 11%, need?
Pick one to see what it prints.
Those are 10% to 12%, a 1-point lift, and 90% power. math.ceil returns an int, which the practice tests also check.
Pick an answer above to see the rest
What halving the lift costs
The lift is the input you have the most say over. Watch what halving it does to n.
for lift in [0.04, 0.02, 0.01, 0.005]: print(lift, sample_size_per_arm(0.10, lift))
Predict
Each time the lift halves, the users needed grow by about what factor?
Pick one to see what it prints.
Each time the lift halves, the users grow about four times.
Users per arm, by the lift on a 10% baseline
4 points
1,033
2 points
3,839
1 point
14,749
0.5 points
57,760
The standard error shrinks like 1/n. Detecting half the lift still needs the MDE 2.8 standard errors from zero, so the standard error has to halve, and that takes four times the users. In the formula, it's the Δ2 in the denominator.
The practice test checks this at a 30% baseline: 2 points needs 8,391 per arm and 1 point needs 33,272, a ratio of 3.97. At 10%, 3,839 becomes 14,749, a ratio of 3.84. Neither is exactly 4, because the treatment rate moves with the lift and takes its variance along.
It works in your favor too. Kohavi and colleagues point out that a test planned to detect a 1% change catches a bug that drops the metric by 20% in 1/400 of the planned time, since (20/1)2=400. Big regressions show up fast. That's why a risky change can go to a sliver of traffic first.
In the editor, write scaled_n(n, lift_from, lift_to): the quick rescaling by the lift squared, to check against the exact numbers.
The baseline moves n, and which way depends on how the lift is stated
The baseline moves n too, and which way depends on how the lift is stated.
print("baseline +2 points +10% of it")for p in [0.02, 0.10, 0.30, 0.50]: print(f"{p:>8.0%} {sample_size_per_arm(p, 0.02):>11,} {sample_size_per_arm(p, 0.10 * p):>12,}")
Predict
The lift is fixed at 2 points. Does a 30% baseline need more or fewer users than a 10% one?
Pick one to see what it prints.
Read the first column of numbers. The lift is fixed at 2 points, and a higher baseline costs users, because p(1−p) grows toward 50%. Past 50% the variance falls again.
Read the second. The lift is fixed at 10% of the baseline, and a higher baseline saves users. The lift in points grows with the baseline. n falls with the lift squared, but the variance grows too, so n falls about as (1−p)/p: from 2% to 10%, 5.5 times fewer users.
So a rare event is expensive to move by a share of itself. On a 2% baseline, a 10% relative lift is 0.2 points, and it takes 80,679 users per arm.
In the editor, sample_size_per_arm is ready. Write users_for_share(p_baseline, share): the users per arm for a lift stated as a share of the baseline, the table's second column.
In an interview you want a number in ten seconds, before the exact one.
Predict
Lehr's rule is 16σ²/Δ². For 10% to 12%, σ² = 0.09 and Δ = 0.02. About how many per arm?
For a quick number, memorize this:
n≈Δ216σ2per arm
Here σ2, sigma squared, is one user's variance, and Δ is the lift. For a conversion rate, σ2=p(1−p).
The 16 is 2×7.85=15.70, rounded up. The 7.85 is (1.96+0.84)2. The 2 is the two arms: a difference of two means has twice the variance of one. It isn't there for the two tails, which are already in the 1.96.
Lehr proposed it in 1992 as an equation to memorize, "intended only for a specific set of values (80 per cent power for a two-tailed alpha = 0.05 test)". Change either and the 16 changes. Kohavi and colleagues' survey of online experiments uses 21 for 90% power, and 2×10.51=21.01. The survey gives it as the minimum sample size, "where n is the number of users in each variant and the variants are assumed to be of equal size".
In the editor, write lehr_constant(alpha=0.05, power=0.8): the constant for any alpha and power, so the 16 and the survey's 21 both come out of it.
With the baseline's variance, Lehr's rule runs low when the treatment arm is noisier
How close the quick number lands depends on which variance you plug in.
Baseline to treatment
Exact
Lehr, baseline variance
Lehr, average variance
10% to 12%
3,839
3,600 (6.2% low)
3,912 (1.9% high)
10% to 11%
14,749
14,400 (2.4% low)
15,032 (1.9% high)
2% to 2.4%
21,106
19,600 (7.1% low)
21,512 (1.9% high)
30% to 32%
8,391
8,400 (0.1% high)
8,552 (1.9% high)
50% to 52%
9,804
10,000 (2.0% high)
9,992 (1.9% high)
With the baseline's variance alone, the rule has the same blind spot as the baseline-variance mistake. It runs low whenever the treatment arm is noisier.
With the two arms' average variance, it's always 1.9% high, because 16 is 15.70 rounded up.
In the editor, write lehr(p_baseline, mde, average=False): both versions of the quick number, to check the table.
Emma Ding's interview take on the 16σ²/δ² rule of thumb and its four inputs, alpha, beta, the variance and delta.
Sample Size Estimation in A/B Testing: Easy Explanation for Data Science Interviews · Emma Ding · Jun 2022YouTube
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, with 80% power.
Step
Value
Control variance, 0.10×0.90
0.0900
Treatment variance, 0.12×0.88
0.1056
Sum
0.1956
z0.975+z0.80
1.9600 + 0.8416 = 2.8016
Squared
7.8489
7.8489×0.1956/0.022
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 npfrom statistics import NormalDistdef 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.
significant holds True or False for each simulated test, so its .mean() is the share that came out significant. diff[significant] keeps only those tests' differences.
The first share is the power, from 200,000 simulated tests of 10% going to 12%. The second has both arms at 10%, so it's the false positive rate. Over 2 million simulated tests they were 80.0% and 5.0%: the power and the alpha you asked for.
Hold on to the second number simulate returns, the average significant difference. It comes back when the lesson turns to underpowered tests.
sample_size_per_arm at other settings:
90% power: 5,139 per arm.
A 1-point lift, 10% to 11%: 14,749 per arm.
α=0.01: 5,712 per arm.
A 2% relative lift, 10% to 10.2%: 356,332 per arm.
Pick an answer above to see the rest
Part 3 done
Part 4 of 6about 14 min
Days and power
From users to days
The formula gives users. A schedule needs days, and the days come in whole weeks. days_for(users, users_per_day) is the function you write at the end of this step: the days to collect users, in whole weeks.
from math import ceil# both arms, at 1,500 a day with half in the testfor n_per_arm in (3839, 5139, 14749): print(days_for(2 * n_per_arm, 1500 * 0.5))
Predict
1,500 new users a day, half of them in the test. How long does the 2-point test run?
Pick one to see what it prints.
Say 1,500 new visitors a day reach the sign-up flow, and half of them go into the test. That's 750 a day. The test needs 7,678 users, so it takes 10.2 days: 11 days, then two whole weeks.
7,678 users at 750 a day: 10.2 days, so 11, then whole weeks
07 days
week 1
7
week 2
4
3
a day the users needa day that finishes the week
Two weeks also covers the 90% power version, 10,278 users in 13.7 days. The 1-point lift needs 29,498 users, 39.3 days, so six weeks.
In symbols, with u new users a day and a share s of them in the test, before rounding to weeks:
days=⌈us2n⌉
The brackets with only top corners, ⌈⌉, mean round up. Then round the days up again, to the next multiple of 7.
In the editor, write days_for(users, users_per_day): the two roundings, to a whole day and then to whole weeks.
Count new users, not daily actives, and run whole weeks
Which daily count goes under the users matters as much as the rounding.
Predict
To turn users into days, which daily count do you use?
Two details change the answer:
Count new users, not daily actives. A returning user is already in the sample, so distinct users pile up more slowly than visits. Kohavi and colleagues note this, and that a straight line is still a reasonable approximation for most sites. Use the new users per day from a comparable past window.
Round up to whole weeks. Weekday and weekend users behave differently. The survey recommends running at least a week or two, then in multiples of a week, so day-of-week effects can be analyzed.
Fix the length before you start, and read the result at the end. The n assumes one look.
Move the baseline and the lift and watch the users and the days change. The defaults are this lesson's example: 10% conversion, a 2-point lift, and 375 users per arm a day.
Power and sample sizeInteractive
Alpha
Power
Users per arm on the x axis. The dashed lines cross at the n that reaches 80% power.
Per arm
3,839
Relative lift
20.0%
Days at this traffic
11
n = (z0.975 + z0.8)² × 0.1956 ÷ 0.020², with z0.975 = 1.960, at 375 users per arm per day
In the editor, sample_size_per_arm is ready. Write days_to_run(p_baseline, mde, new_users_per_day, share_in_test): the whole path from a lift to a run length.
CheckpointFrom a lift to a run length
Write days_to_run(p_baseline, mde, new_users_per_day, share_in_test): how long a 50/50 test runs, in days rounded up to whole weeks. sample_size_per_arm is in the editor. With 1,500 new users a day and half of them in the test, the 2-point test runs 14 days.
Pick an answer above to see the rest
An underpowered test overstates the effects it finds
Significance only lets the big estimates through
Run the worked example's simulation on a smaller truth. The test is still sized for 2 points, but the true lift is 1 point:
share, average = simulate(3839, 0.10, 0.11)print(round(share, 3), round(average, 4))
Predict
The test is sized for 2 points, and the true lift is 1 point. What share of tests come out significant?
Pick one to see what it prints.
Only 30% of the tests come out significant. Those that do average 1.8 points, not 1:
A true 1-point lift, 3,839 users per arm
bartruthbar1.8
every estimate the truth is 1 point. The shaded 30% clear the bar, and they average 1.8
-10123
points
Significance is a filter: at 3,839 users per arm, a difference has to clear roughly 1.4 points. If the true lift is 2 points, most estimates clear it anyway. If it's 1 point, only the lucky high draws do, so the significant ones overstate the truth.
In the editor, estimates holds 20 simulated tests of a true 1-point lift. Write significant_mean(estimates, bar): the average of only the ones that clear the bar.
The smaller the true lift, the more the significant estimates exaggerate it
Now shrink the truth further, and keep the test the same.
Predict
The test stays sized for 2 points while the true lift shrinks toward 0.25 points. What happens to the average significant estimate?
From a million simulated tests at each true lift, all sized for 2 points. The last column is the share of significant results that point the wrong way:
True lift
Power
Significant estimates average
Exaggeration
Wrong sign
2 points
80%
2.25 points
1.12x
about 1 in a million
1.5 points
56%
1.99 points
1.33x
0.004%
1 point
30%
1.81 points
1.81x
0.1%
0.5 points
11%
1.69 points
3.4x
3.3%
0.25 points
6.5%
1.63 points
6.5x
15%
As the truth shrinks, the significant estimates barely move. They're pinned just above the bar, so their size tells you where the bar is, not how big the effect is.
Gelman and Carlin call the overstatement a Type M error, for magnitude, and the sign flips Type S errors, for sign. At 80% power their exaggeration ratio is 1.12. When power drops well below 0.5, "the exaggeration ratio becomes high (that is, statistically significant estimates tend to be much larger in magnitude than true effect sizes)."
In the editor, write exaggeration and wrong_sign: Gelman and Carlin's two errors, measured on a sample.
Underpowered wins shrink when you rerun them, and misses kill good ideas
A launch reported at +1.8 points delivers +1. That's the winner's curse: on average, the winners you pick overstate their own effect.
Rerun the 1-point winners, and they average 1.00 point, and only 30% come out significant again. The misses mislead too: at 30% power, 70% of real 1-point lifts come out not significant, and a good idea dies.
The survey calls underpowered experiments a common mistake. The fix is the sizing in this lesson:
Power the test for an effect you believe, not one picked to make the test cheap.
Report the confidence interval with the estimate.
Rerun surprising wins.
Part 4 done
Part 5 of 6about 14 min
Fewer users
In an uneven split, the small arm sets the precision
Teams split traffic unevenly for real reasons, like ramping a risky change up slowly or keeping a small holdout. It costs time, because the small arm sets the precision. With k treatment users per control user, the control needs
nC=Δ2(z1−α/2+z1−β)2(σC2+kσT2)
and the treatment gets nT=knC, where σC2 and σT2 are each arm's p(1−p).
def sample_size_split(p_control, mde, treat_share, alpha=0.05, power=0.8): p_treat = p_control + mde z = NormalDist().inv_cdf(1 - alpha / 2) + NormalDist().inv_cdf(power) # treatment users per control user k = treat_share / (1 - treat_share) var_c, var_t = p_control * (1 - p_control), p_treat * (1 - p_treat) n_control = ceil(z ** 2 * (var_c + var_t / k) / mde ** 2) return n_control, ceil(k * n_control)print("split control treatment total vs 50/50")for treat_share in [0.5, 0.2, 0.1, 0.01]: control, treatment = sample_size_split(0.10, 0.02, treat_share) split = f"{round(100 * (1 - treat_share))}/{round(100 * treat_share)}" total = control + treatment print(f"{split:>5} {control:>8,} {treatment:>10,} {total:>8,} {total / 7678:>8.2f}x")
Predict
The same 10% to 12% test on a 90/10 split. About how many users in all, against 7,678 at 50/50?
Pick one to see what it prints.
That's the same 10% to 12% test, with each split written control/treatment. To scale, the control balloons and the treatment hardly shrinks:
Users by split, for the same 10% to 12% test
05000100001500020000
50/50: 7,678
3,839
3,839
80/20: 12,569
10,055
2,514
90/10: 22,684
20,415
2,269
controltreatment
The treatment arm's own noise doesn't average away, however big the control gets. Even an infinite control leaves it needing about 2,070 users. The 99/1 split wouldn't fit: 206,905 control users.
At a fixed flow of traffic, the 90/10 test runs 2.95 times as long. Kohavi and colleagues give 1/(4p(1−p)) as the rule of thumb for that factor, with p the treatment's share: 2.78 at 90/10 and about 25 at 99/1. It comes out a little worse here because the small arm is the noisier 12% one.
In simulation the 90/10 sizing detected the lift more than 80% of the time, with either z-test.
In the editor, write split_factor(treat_share): the rule of thumb, to compare with the table's last column.
With one treatment 50/50 is all but optimal, and several treatments share a bigger control
Several treatments change the answer, because they share one control.
Predict
Three treatments share one control. How big should the control be, against each treatment?
Three treatments and one control, in equal-arm units
01234 arms
equal arms: 4.00
1
1
1
1
control 1.73 times each treatment: 3.73, 6.7% fewer
1.37
0.79
0.79
0.79
controltreatment 1treatment 2treatment 3
For one treatment and one control, 50/50 is as good as it gets. The optimal split puts users in proportion to each arm's standard deviation. For 10% against 12% that's 48/52, and it saves 0.16%, which doesn't matter.
With several treatments each compared to one control, the control serves every comparison, so give it more. The rule: the control gets the square root of the number of treatments, times each treatment's users. With three treatments that's 1.73 times, and the total drops 6.7% against equal arms. The survey makes the same point about a larger control.
Ramp up for safety, then run the real test at 50/50. The survey suggests stepping a treatment from 0.1% of traffic up toward 50% and checking the data at each step.
In the editor, write control_share(treatments): the control's share of all users under the square-root rule.
Less variance means fewer users, and CUPED cuts the variance
The next way to save users attacks the variance in the formula's top line.
Predict
A pre-experiment covariate correlates 0.7 with the metric. What share of the variance does CUPED keep?
n is proportional to the variance, so any cut in variance is the same cut in users. Three tools do most of the work, and CUPED is the first.
Correlation ρ
Variance kept
Users per arm, 10% to 12%
0
1.00
3,839
0.5
0.75
2,879
0.7
0.51
1,958
0.9
0.19
730
CUPED, which the CUPED lesson covers, subtracts the part of the metric that a pre-experiment covariate predicts. A covariate here is a number you already had for each user before the test began. With correlation ρ, rho, between the covariate and the metric, the variance shrinks to 1−ρ2 of what it was, and n with it.
In a simulation with ρ=0.7, a test that needed 1,570 users per arm on the raw metric got by with 801. At 801 users per arm the CUPED-adjusted comparison had 80% power, and the raw one 52%.
In the editor, raw_n is the formula before rounding. Write cuped_per_arm(p_baseline, mde, rho): the users per arm after CUPED, the table's last column.
Triggering analyzes only the users the change can reach
Triggering works on the lift, not the variance.
Predict
Only 20% of users can be affected, and they go from 10% to 12%. Analyze everyone, and the lift becomes what?
Everyone who enters the test
020100 %
only some users can be affected by the change
20%
80%
can be affectedcan't be: noise, no signal
Analyze
The lift
Users per arm
everyone
0.4 points
89,862
the 20%
2 points
3,839 of them, 19,195 entering each arm
Triggering means you analyze only the users the change can reach. Kohavi and colleagues' example is a checkout change, analyzed only on users who started checkout, because everyone else adds noise and no signal.
Say 20% of users can be affected, and the change lifts them from 10% to 12%. Analyze everyone, and the lift is diluted to 0.4 points, which takes 89,862 users per arm.
Analyze the 20%, and you need 3,839 of them. That means 19,195 users entering each arm: 4.7 times fewer.
In the editor, write diluted_lift and entering_per_arm: the two numbers in the table.
Revenue per user has a heavy tail: a few big spenders swing the average. A conversion rate doesn't. In the survey's example, detecting a 5% change in conversion instead of in revenue cut the sample size by a factor of 3.3.
Part 5 done
Part 6 of 6about 17 min
Follow-ups
What interviewers ask next
The Netflix question from the first step comes back here, with every adjustment the lesson covered.
The frequency-cap question: start from the base n, then adjust it
The frequency-cap question, from the base nInteractive
→
→
→
→
→
base n = 3,839 per arm for 10% going to 12%.
A frequency cap limits how many times one person sees the same ad. The Netflix question a prep site lists asks for power calculations "that account for interference and clustering" (1 source). Each piece moves n in a direction you can work out, so take them in the order of the figure.
The metric and the MDE. Measure per member, the unit you randomize, and state the MDE as two rates. A cap cuts impressions, so clicks per impression can rise even while clicks per member fall. If you need a per-impression rate, size it with the delta method, which a later step shows.
Who can be affected. A cap of three a day changes nothing for someone who would have seen two. Log in both arms whether each member would have hit the cap, and analyze those members. That's triggering, worth 4.7 times fewer users in its example.
Clustering and interference. The next two steps take these one at a time.
Then days. New members per day in, whole weeks out, as before.
Randomizing whole clusters multiplies n by the design effect
Randomize households or regions, and you randomize a unit that holds several of the units you measure. Outcomes inside one unit move together. Multiply n by the design effect, DEFF, with m members per cluster and intra-cluster correlation ρ:
DEFF=1+(m−1)ρ
The intra-cluster correlation is the correlation between two members of the same cluster. It's 0 when the cluster says nothing about a member's outcome, and 1 when every member of a cluster has the same one.
Predict
Clusters of 20 members, with ρ = 0.05. What's the design effect, 1 + (m - 1)ρ?
With clusters of 20 and ρ=0.05 it's 1.95, so the 2-point test needs 7,485 users per arm, 375 clusters. In simulation that design had 80% power.
Sized as if users were independent, at 192 clusters per arm, power fell to 52%. Analyzing those users as if they were independent turned a 5% false positive rate into 16%.
There's a ceiling too. A cluster is worth m/DEFF independent users, which never reaches 1/ρ, however many members it holds:
One cluster's worth in independent users, at ρ = 0.05
5 members
4.2
20 members
10.3
100 members
16.8
1,000 members
19.6
Never past 1 / ρ = 20, however many members a cluster holds.
Past a point you need more clusters, not bigger ones. The lesson Randomized by city, analyzed by user covers the analysis.
In the editor, write design_effect(m, rho) and cluster_worth(m, rho): the factor on n, and the ceiling in the figure.
When the arms compete for one ad budget, control can change too
Ads add one more problem: the two arms can compete for the same budget.
When the arms compete for one ad budgetInteractive
→
→
one campaign = chasing its delivery goal.
Ads run against budgets and delivery goals. When the cap stops showing an ad to treatment members, a campaign chasing its goal can show it to control members instead. So control changes too, and the gap between arms isn't what a full launch would do.
The fix is to randomize at a level where the arms don't compete for the same impressions, such as whole markets. Or give each arm its own share of every campaign's budget. Both create clusters, so the design effect applies, and the number of clusters becomes the constraint.
A ratio metric needs its variance per member, not per impression
A frequency cap is often judged on a rate per impression, and that rate's variance needs care. ratio_variance is the function you write at the end of this step: the variance per member.
Four members, 10 ads each, one of them doing most of the clicking. Is the per-member variance bigger or smaller than the coin-flip view?
Pick one to see what it prints.
That's four members, each shown 10 ads, with a click-through rate of 10% overall and one member doing most of the clicking. The first number is the variance per member. The second treats every impression as a coin flip, and it's less than half as big. You randomized members, and one member's impressions aren't independent coin flips, so the coin-flip variance comes out too small, and so does the test.
The delta method gives the variance per member. With Ci and Ni for member i's clicks and impressions, R=∑iCi/∑iNi the overall rate and Nˉ the average impressions per member:
σ2=Nˉ2Var(Ci−RNi)
In words: one number per member, their clicks minus R times their impressions. Take the sample variance of those numbers, which divides by the number of members minus 1, and divide it by the average impressions squared.
Estimate it from past data and use it in place of each arm's p(1−p) in the formula, with n counting members.
In a simulation with about 10 impressions per member, click rates that vary from member to member, and a click-through rate going from 5.0% to 5.5%, the per-member variance was 1.95 times what the coin-flip view says. Sized correctly, the test needs 6,090 members per arm, and it detected the lift 80% of the time. Sized as coin flips, it gets 3,124 and detects the lift 52% of the time.
In the editor, write ratio_variance(clicks, impressions) in plain Python, so each step of the delta method is yours.
With fixed traffic, solve for the smallest lift you can detect
When traffic is fixed, the question flips: We have two weeks. What can we detect? Solve for Δ. The exact answer comes from bisecting on the function you already wrote:
def smallest_lift(n_per_arm, p_baseline, alpha=0.05, power=0.8): lo, hi = 0.0, 1 - p_baseline # bisect: n falls as the lift grows for _ in range(60): mid = (lo + hi) / 2 if sample_size_per_arm(p_baseline, mid, alpha, power) > n_per_arm: lo = mid else: hi = mid return hiprint(round(smallest_lift(5000, 0.10), 4))
Predict
5,000 users per arm on a 10% baseline, 80% power. What's the smallest lift you can detect?
Pick one to see what it prints.
That's 1.74 points. If that's bigger than any lift you believe in, the test can't answer the question as designed. Shrink the variance, trigger or run longer before you run it.
A quick version, for an interview, uses the baseline's variance for both arms:
Δ≈(z1−α/2+z1−β)n2p(1−p)
At 5,000 users per arm on a 10% baseline that's 2.80×0.18/5000=1.68 points. It runs a little low, for the same reason as the baseline-variance mistake.
In the editor, write quick_mde(n_per_arm, p_baseline): the quick formula, to see how far below the exact 1.74 points it lands.
With a Bonferroni correction, three treatments need 1.33 times the users each
Several treatments also mean several comparisons, and each one is another chance for a false positive.
Predict
Three treatments with a Bonferroni correction. What alpha does each comparison run at?
Three treatments against one control are three comparisons. A Bonferroni correction splits alpha evenly across them, so each one runs at α=0.05/3. The bar rises from 1.96 to 2.39, and each comparison needs 1.33 times the users: 5,120 per arm instead of 3,839.
Then make the shared control bigger, as the chapter on fewer users showed. Power one primary metric, and treat the rest as guardrails or as corrected secondary results.
In the editor, write bonferroni_factor(m): how many times the users each comparison needs, for any number of comparisons.
In simulation, checking a no-effect test at the end of each of 14 days and stopping at the first significant result turned a 5% false positive rate into 22%. If you need to stop early, use a sequential design and plan the looks into the sizing. The ab-test lesson walks through those designs.
The practice problem, start to finish
That's every piece of the practice problem, and every follow-up it lists. The simulation asks for both functions under a timer, so rehearse the order once.
Check yourself
5 questions
1.You compute the alpha z as NormalDist().inv_cdf(1 - alpha). What happens to the 10% to 12% test?
2.A teammate sizes a test of 2% to 3% with 2 * 0.02 * 0.98 as the variance. What goes wrong?
3.The PM wants to detect a 2% lift on a 10% conversion rate and means 2% of the baseline. How many users per arm is that, against 3,839 for 2 points?
4.The formula gives 3,838.10 users per arm. What should the function return?
5.A test sized for a 2-point lift, 3,839 users per arm on a 10% baseline, runs on a change whose true lift is 1 point. When it comes out significant, what lift does it report on average?
Where this shows up
The reports behind this lesson, each with its source.
A prep site lists a Netflix DS onsite question (posted 2025-10-13): design and power a frequency-cap experiment that accounts for interference and clustering.
Prep site·PracHub (prep site question bank)·2025-10-13Source
Data scientist onsite (Oct 2025 report): both technical cases were about ad frequency caps.
Candidate report·PracHub (first-person report, curated and edited by the site)·2026-08-25Source
“I suggest for memorization an equation for calculating approximate sample size requirements intended only for a specific set of values (80 per cent power for a two-tailed alpha = 0.05 test)”
“But when power gets much below 0.5, the exaggeration ratio becomes high (that is, statistically significant estimates tend to be much larger in magnitude than true effect sizes).”