08

When the test is lying

A broken experiment does not announce itself. It produces numbers that look exactly like real ones. So before reading any result, check the instrument.

Every chapter so far has assumed that the experiment works: users are split at random, each sees the version they were assigned, and every visit is logged the same way in both groups. In practice each of those steps is software, and software breaks. When it breaks, the statistics do not complain. They calmly compute a precise answer to the wrong question.

Any figure that looks interesting or different is usually wrong.

That is Twyman’s law, the alarm chapter 2 mentioned, named after the media researcher Tony Twyman and a favourite of Ron Kohavi’s. It is not cynicism. It is arithmetic: there are many more ways for a pipeline to break than for a small change to produce a huge effect, so a huge effect is more likely to be a broken pipeline.

The cheapest, strongest check: sample ratio

You planned a 50/50 split. Count the users in each group.

If the counts are further apart than chance allows, something between randomisation and analysis is treating the groups differently, and whatever it is can bias the comparison in either direction. This is a sample ratio mismatch, an SRM.

It is not rare. Microsoft found SRMs in about 6% of its experiments; at LinkedIn about one in ten of a certain kind of targeted experiment used to have one. Microsoft’s platform will not show a result until the experiment passes this check.

How can a split go wrong when a coin decides it? Usually the coin is fine. What breaks is everything after it: some people in one group are lost, or added, before they are counted. Below, dark squares are returning customers, light squares new visitors. Make version B slow to load and watch what happens to the people who are impatient.

When the slow version loses people

How to read itSame squares as in chapter 1: dark ones are returning customers, light ones new visitors. Switch to “B loads slowly”: some impatient new visitors leave B before they are counted, shown as red outlines. Compare the counts under each block, then the verdict.

A · counted

B · counted

Red outlines are people who left B before the page finished loading, so the logging never saw them. In this simulation the new design changes nothing; returning customers buy four times as often as new ones.

The slow variant did not convince anyone to buy. It filtered out the people least likely to buy, and the test counted only the survivors. The only visible symptom is that B has fewer people than A. That is what the sample ratio check catches, and it is why it comes before reading any result. Check your own numbers:

Sample ratio check

How to read itType the number of people counted in each group, or pick an example. The line below is zoomed in around a perfect 50/50 split. The grey zone is how far from 50/50 a fair coin can drift by chance with this many people. The dot is your test: inside the zone is fine, outside means something is broken.

share of people in A
—
chance alone allows
—
p-value of the check
—

The default numbers are the point. A split of 49.5% to 50.5% looks like nothing; you would not notice it on a dashboard. With 200,000 users it has a p-value around 0.00001. Something is losing or adding users in one group, and until you know what, you do not know what the result means.

The maths

Pearson’s chi-square goodness of fit, with observed counts Oi and expected counts Ei from the planned shares:

χ2=∑i(Oi−Ei)2Ei
Slowly, with numbers

In wordsFor each group: how far the count is from what was planned, squared, divided by what was planned. Then add the groups up.

χ²
Chi-squared, said “kai”. One number for how badly the counts fit the plan; 0 is a perfect fit.
∑
Capital sigma: “add up what follows, once for each group”.
i
Which group: A, then B.
O
Observed: the people actually counted in the group.
E
Expected: the people the plan said it should get.

With numbers100,000 and 102,000 make 202,000, so a 50/50 split expects 101,000 in each. A: (100,000 − 101,000)² / 101,000 = 1,000,000 / 101,000 = 9.9. B is the same distance the other way: 9.9. Sum: 19.8.

Turning 19.8 into a p-value is another lookup: CHISQ.DIST.RT(19.8, 1) in a spreadsheet gives 0.0000086. A healthy split would show a difference this large less than once in a hundred thousand tests.

with k − 1 degrees of freedom for k groups: the number of group shares that are free to vary once the total is fixed (with two groups, knowing A’s count fixes B’s, so one). For 100,000 against 102,000: χ² ≈ 19.8, p ≈ 8.6 × 10−6.

The threshold is strict, p < 0.0005, because every experiment is checked: at 0.05, one healthy test in twenty would be flagged. Real SRMs usually land far below the threshold.

Where mismatches come from

Aleksander Fabijan, Lukas Vermeer, Pavel Dmitriev and colleagues sorted the causes they had seen by the stage of the experiment where they occur. A summary in our words:

One execution problem deserves its own sentence because it is so common. Many testing tools change the page in the browser after it loads: the visitor’s screen paints A, then the tool’s script swaps in B. That flicker is part of the experience only B’s group gets, it slows B down, and impatient people leave before they are counted. Testing on the server, so the page arrives already as A or B, avoids it.

What flicker looks like

How to read itWireframes of a hotel page whose headline is being tested. The new headline is drawn in blue.

Rooms in FlorenceSee rooms
A’s visitorsthe page arrives finished
Rooms in FlorenceSee rooms
B’s visitors, at firstthe old page appears
Free cancellationon most roomsSee rooms
B’s visitors, a moment laterthe script swaps in the new headline
What it showsOnly B’s visitors see the page change under their eyes, and only they wait for it. Some leave in that moment, before they are counted, so B ends up with fewer people than A and with more patient ones.

Notice that several of these are caused by the change itself. A variant that crashes on old phones will have fewer users, and the users it keeps will be on newer phones and convert better. The test reports a win that is really a loss of your least valuable users. The SRM is the only visible symptom.

A win that is really a loss of visitors

How to read itWireframes of a product page. B adds a photo gallery, drawn in blue, that old phones cannot run.

€48Add to basket★★★★☆ 212 reviews
A, on every phoneworks; everyone is counted
€48Add to basket★★★★☆ 212 reviews
B, on newer phonesworks; these visitors are counted
This pagestopped working
B, on older phonescrashes before the visit is logged; these visitors vanish from B
What it showsB’s group is missing its visitors with old phones, who tend to buy less. The visitors it keeps buy more than A’s average, so B looks like a winner. The only trace of what happened is that B has fewer people than it should.

Mismatches hide inside metrics too

The same logic applies inside a metric. Pavel Dmitriev and colleagues put it first in their list of twelve interpretation pitfalls.

If your metric is clicks per page view and the variant changes how many page views there are, the denominator itself has an SRM, and the ratio can move in a direction that has nothing to do with whether users had a better time (ratio metrics are introduced in chapter 5). Check counts at every level you compute a ratio over, not just users.

A/A tests: testing the test

An A/A test is an experiment in which both groups get exactly the same thing.

Nothing has changed, so the right answer is known in advance: no difference. Running one checks the whole machine (assignment, logging, metric calculations, the statistics) against a question whose answer you already know.

One A/A test proves very little

Here is the catch that is easy to miss. A test at the 5% significance level declares a difference 5% of the time when there is none. That is the definition. So a single A/A test that comes out “significant” is not proof that something is broken: it happens to one healthy test in twenty. And a single A/A test that comes out clean is not proof that everything works: a setup that is badly broken still passes most individual A/A tests.

What tells you something is the pattern across many A/A tests. In a sound setup about 5% come out significant, and their p-values are spread evenly between 0 and 1. In a broken one, too many come out significant and the p-values pile up near zero.

Two hundred A/A tests

How to read itEach bar counts A/A tests, tests where both groups see the same thing, by the p-value they produced. The first bar, in blue, holds the ones that came out “significant”. In a healthy setup every bar is about the same height, close to the dashed line, and the first bar holds about 5% of the tests. A tall first bar means the setup finds differences that are not there: switch to the setup with a common bug to see one.

p below 0.05: “significant”what a healthy setup gives

Two hundred simulated A/A tests. The bug: the coin is tossed on every page view, but results are counted per person. The same person lands in both groups and is counted as if they were several independent people, so the statistics think there is less noise than there is.

How to use them

Other ways a true number misleads

Even with a fair split and clean logging, three effects of time can make a correct number tell the wrong story.

In practice

Four habits that catch a broken test before anyone reads its result.

What we’ve learned

  • A broken experiment produces numbers that look exactly like real ones.
  • Check the sample ratio first, every time; a 49.5/50.5 split can be a serious bug.
  • Mismatches often come from the change itself: crashes, slowness, logging.
  • One A/A test proves little either way; the pattern across many A/A tests shows whether the setup is sound.
  • A surprising result is more likely a bug than a breakthrough.

Sources