Skip to the page

Statistics and experiments · mid

Designing an A/B test

A good test names a hypothesis, the unit of randomisation, one primary metric, guardrails, the sample size and a decision rule, all before the test starts. When users share a resource such as riders, user-level randomisation can mislead.

The notes

What you must know

  • Write the hypothesis and the decision rule before the test: for example ship if margin per user does not fall by more than an agreed amount and orders rise.
  • Unit: the user (a device for logged-out users), from a hash of the user id, so one person always sees one version. Check the split and that groups looked alike before the test.
  • One primary metric fixed in advance, for example contribution margin per user. Secondary metrics explain it. Guardrails (delivery cost, delivery time, cancellations, complaints) must not get worse.
  • Run at least two full weeks and avoid the festive sale unless the decision is about sale behaviour.
  • Interference: users share riders. If treatment users order more, riders are busier for control users too, so a user-level test can mix in a side effect.
  • City level removes spillover but has few units (for example 12 cities) that differ a lot, so it is noisy. Use matched pairs or synthetic-control style comparisons.
  • Switchback: turn the change on and off in random time slots within each city. It handles shared supply. It needs slots long enough, a buffer after each switch, and analysis that treats each slot as the unit.
  • Use switchback or city-and-time designs for supply-side effects. Use user-level tests for pure demand questions with little spillover.

The red pen

Common traps: mistake → fix

  • Mistake: Randomising by user always fixes everything

    Fix: not when users share riders, drivers or stock.

  • Mistake: Conversion rate is enough as the only metric

    Fix: a lower threshold can raise orders and still lose margin.

  • Mistake: A city-level test with two cities is fine

    Fix: two units cannot separate the effect from city differences.

Easy to hard

Questions interviewers ask, easy to hard

  1. Design an A/B test for lowering the free-delivery threshold.
  2. What are guardrail metrics? Give three.
  3. Would you randomise by user, city or time slot for a peak-hour delivery fee? Why?
  4. What is a switchback test?
  5. What goes wrong if you pick the success metric after the test?

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview