Sub topic 11
Why peeking at results early gives false winners
This chapter assumes you can run the sample-size and z-test code from the earlier chapters and know what a p-value means. Here you will see why checking a test before it reaches its planned size inflates false winners, and what to do instead.
What peeking is
Peeking means checking significance while a test is running and stopping as soon as p drops below 0.05. It feels harmless, but the 0.05 threshold assumes you look once, at the sample size you chose in advance.
A p-value wanders as data arrives. Early on, the counts are small and noisy, so the gap between A and B swings widely. Each look is another chance for noise to cross the threshold. If you stop at the first crossing, you keep the lucky draw.
Seeing the inflation
The simulation below runs A/A tests. Both variants have the same 2% click rate, so any "winner" is false. Each test sends 2,000 recipients per variant in 10 batches and checks the p-value after every batch. It requires NumPy.
import numpy as np
from math import sqrt
from statistics import NormalDist
rng = np.random.default_rng(7)
def p_value(x_a, n_a, x_b, n_b):
pooled = (x_a + x_b) / (n_a + n_b)
se = sqrt(pooled * (1 - pooled) * (1 / n_a + 1 / n_b))
z = (x_b / n_b - x_a / n_a) / se
return 2 * (1 - NormalDist().cdf(abs(z)))
runs, looks, batch, rate = 2000, 10, 2000, 0.02
peek_false = final_false = 0
for _ in range(runs):
a = rng.binomial(batch, rate, size=looks).cumsum()
b = rng.binomial(batch, rate, size=looks).cumsum()
ps = [p_value(a[i], batch * (i + 1), b[i], batch * (i + 1))
for i in range(looks)]
peek_false += min(ps) < 0.05 # stopped at any look
final_false += ps[-1] < 0.05 # looked only once, at the end
print(f"single look: {final_false / runs:.1%} false winners")
print(f"10 looks: {peek_false / runs:.1%} false winners")Expect the single-look rate near 5%, as designed. The ten-look rate should land around 19%, roughly four times higher. The exact numbers vary with the seed.
Stopping rules that work
Choose one of these before you launch:
- Fixed horizon. Compute the sample size per variant, send, and analyze once at the end. This is the simplest option and the one to use by default.
- Planned looks with a stricter threshold. Decide the number of looks in advance, such as 3, and require a smaller p-value at each. Dividing 0.05 by the number of looks (a Bonferroni correction) is safe but conservative.
- Sequential methods. Alpha-spending designs, such as O'Brien-Fleming boundaries, are built for repeated looks. They need a statistics library or a tool that implements them.
For subject-line tests with a send-the-winner step, the fixed horizon has a practical form. Set a wait window, such as 4 hours after send, and a minimum sample size. Then read the result once. Do not end the window early because one variant seems ahead.
Safe things to do while a test runs
- Monitor delivery problems, such as bounces or a broken link. These are health checks, not result checks.
- Keep a log of when you looked, if you looked.
- Treat early differences as unreliable, even large ones, because small samples exaggerate them.
Exercise
A teammate checks a subject-line test after every 1,000 sends and stops the first time p < 0.05. The planned size was 20,000 per variant. Name two valid fixes.
Show answer
Wait until the planned 20,000 per variant and analyze once (fixed horizon). Or, decide the number of looks in advance and use a stricter per-look threshold, such as 0.05 divided by the number of looks, or a sequential method like alpha spending. Checking after every 1,000 sends is about 40 looks, so the plain 0.05 threshold gives many false winners.