Experiments, Peeking, and Optimal Stopping

Matteo Courthoud2 May 2022

Problem

Product teams check A/B test results before the planned sample is collected. If the statistic crosses the significance threshold at an interim look, the temptation is to stop and ship. This breaks the test: the real false positive rate ends up far above the nominal α, and confidence intervals no longer have the stated coverage. Waiting for the full planned sample is safe but slow, and that sample is often larger than the data needed for a verdict.

Example from the article: a simulated metric X~N(μ,1) with known variance, testing H0:μ=0 against H1:μ=0.1 at α=0.05 and power 0.8, which needs 785 observations. Stopping at the first threshold crossing after observation 100 rejected a true null in 25 of 100 runs.

Solution in brief

Replace the fixed-sample test with the Sequential Probability Ratio Test (SPRT). After each observation, update the cumulative log-likelihood ratio between the two hypotheses and compare it with two fixed bounds computed from α and β. Crossing a bound is a valid stopping signal, so the test ends as soon as the evidence is enough while keeping the planned error rates.

Questions this case answers
  • How to stop a randomized experiment early on interim data while keeping the planned type I and type II error rates
  • How to run an A/B test with repeated looks at the data without inflating the false positive rate?
  • How to stop an experiment early when the result is already clear?
  • How to cut the average sample size of an A/B test without losing power?

Tools and methods

  • Fixed-sample z-test with power analysis — baseline sample size and the demonstration of how peeking inflates errors
  • Sequential Probability Ratio Test (SPRT) — stopping rule built on the cumulative log-likelihood ratio
  • Monte Carlo simulation — checking error rates and average duration before relying on the rule
Continue reading — it's free

Google or a one-time email code. No password.