Overview
Curated: · Written: · Reviewed:
A/B Testing
In one line
A randomised comparison of two variants, analysed by assigned arm on one pre-registered primary metric, used when the decision depends on the causal size of the effect. Reach for it when the change can be randomised at a unit that does not leak and traffic can detect the smallest effect that would change the decision.
Key definitions
- Randomisation unit: the level at which assignment is made. It must be at least as coarse as the level at which treatment leaks between users.
- ITT (intention to treat): analysis by assigned arm, whatever users actually experienced.
- SRM (sample ratio mismatch): observed split differs from the intended split. A chi-squared check that blocks the readout.
- MDE (minimum detectable effect): the smallest true effect the test detects at the chosen power and alpha.
- Guardrail: a metric with a pre-agreed stop threshold. It can stop a ship but never makes one.
- Surrogate: a short-term metric validated against the long-term outcome it stands for.
Formulas and complexity
At a 3.2% baseline, a 10% relative lift (3.52%), two-sided alpha 0.05 and 80% power, this gives about 49,800 per arm.
CUPED uses only a strictly pre-treatment covariate. With events logged from N users, the effective sample is nearer N than the event count.
How it works
Assignment is a deterministic hash of a stable id, logged at decision time and sticky across sessions. The SRM check runs before any metric is read. Analysis is by assigned arm. Any trigger is evaluated and logged identically in both arms.
When to use and when not to
| Situation | Use A/B | Choose something else |
|---|---|---|
| Visible UI change, users randomisable | Yes, randomise by user | No |
| Marketplace or shared resource | No, unit leaks | Market-level randomisation or switchback |
| MDE at or below a plausible effect | Yes | Plausible effect far below MDE: monitor or evaluate qualitatively |
| Long-term outcome only | Yes with a validated surrogate | Unvalidated surrogate: long-term holdout |
| Heavy-tailed revenue | CUPED plus a pre-agreed cap | Post-hoc cap chosen after seeing data |
| Legal or security obligation | No | Ship under the obligation |
Traps interviewers probe
- Conditioning on a post-treatment variable. Restricting analysis to users who reached a step the change itself affects reintroduces selection, and the restricted comparison can reverse the overall result. Fix: analyse every assigned user. Use only pre-trigger eligibility for a restriction.
- Stopping at the first significant look. Repeated looks at p < 0.05 inflate false positives, and continuous monitoring at a nominal 5% can reach roughly 30%. Fix: pre-register looks with an alpha-spending function such as O'Brien-Fleming, or use always-valid inference.
- Reading through an SRM. A mismatched split means assignment, logging or filtering is broken. Fix: block the readout, find the cause, and do not adjust the analysis for the ratio.
- Analysing events as independent. Two million events from fifty thousand users gives an interval several times too narrow. Fix: aggregate to the user, or use the delta method or clustered errors.
- Segment fishing. Twelve unplanned segments at alpha 0.05 give about a 46% chance of at least one false positive. Fix: pre-register segments and test the interaction.
Interview tips
Open with the design and the decision: "A randomised comparison by assigned user, analysed ITT on one pre-registered metric, with guardrails and a rule written before launch." Then name the first check you run, which is the SRM.
Expect these follow-ups: why the ratio check comes first; how you would detect interference and switch to a switchback; why a significant day-two result is not a 12% claim; how a long-term holdout reconciles claimed wins with the measured trajectory; and how you would size a test with low traffic.
30-second outline: state the hypothesis and unit. State the assignment and the ITT analysis. State the SRM gate. State the primary metric, its CI and the guardrail thresholds. State the decision rule for significant, non-significant and harmful outcomes.
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.