Gradient

Courses

∇\nabla∇The maths behind AI0/72
π\piπMaths0/84
⋆\star⋆AI for everyone0/10
Γ\GammaΓGame theory0/49
py\texttt{py}pyPython for AI0/15
y^\hat{y}y^​Build your own AI0/15
All courses

Tuition

My tuitionOlympiad trackCompetitions

Practice

ProjectsAsk a questionTrain on a GPUExplorationsMaths StoriesUnsolved problemsPlaygroundScience labsMock testsOlympiad

Reference

GlossaryBlogDiscoveries
Explorations › Data you can hold › lesson 6 of 6

A/B tests

Show half your visitors one version and half another, then let the numbers decide. Watch the uncertainty shrink as visitors arrive.

Every big app is running experiments on you right now. A button in blue for some users and green for others; two headlines for the same article. These are A/B tests, and they are the shuffle test from the last lesson, run live.

Split at random

Each visitor is sent to version A or version B by a coin toss. Because the split is random, the two groups are alike in everything except the version, so any difference in behaviour is caused by the version.

The model hides the true sign-up rates, 10% for A and 12% for B. Press 100 more visitors a few times. Early on the bars jump about and the yellow boxes, the range each rate could still be in, overlap: you cannot tell which is better.

Keep going until you can tell

Add visitors and the boxes shrink. Once they stop overlapping, the difference is very unlikely to be luck. For a 2-point gap that takes thousands of visitors; for a 10-point gap only a few hundred.

true gapvisitors needed, roughly
10% vs 20%a few hundred
10% vs 12%several thousand
10% vs 10.5%tens of thousands

Common mistakes

  • Stopping early the moment B looks ahead. Early leads are often luck; decide the number of visitors in advance.
  • Testing many things at once and reporting the one that "won". With 20 tests, one will cross the 1-in-20 line by luck alone.
  • Changing the test halfway, so A and B no longer see the same conditions.

What to remember

  • An A/B test splits people at random between two versions and compares results.
  • Random splitting makes the version the only systematic difference.
  • Small differences need many visitors to detect.
  • Decide the sample size in advance and do not stop at the first lead.
Is it real or luck?Next module: Physics sandbox