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
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:
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:
- Assignment. The randomisation itself is wrong: a bad hash, users reassigned mid-test, a group that overlaps with another experiment.
- Execution. The variant changes who gets counted. A slower page loses impatient users before the logging fires; a crash removes them entirely; a variant that is more engaging brings people back more often; caching serves the wrong version; a variant that changes the consent banner, or anything near it, changes how many people agree to be tracked, and so how many are counted.
- Log processing. The data is cleaned differently: bot filters that react to a variant’s behaviour, sessions joined or split differently.
- Analysis. The wrong people are compared: a trigger condition that only the variant can satisfy, or a date range that cuts the groups unevenly.
- Outside interference. Something else touches one group: a campaign, a deploy, another team’s test. (Not to be confused with the interference between users in marketplaces and social products, where one person’s treatment changes what another sees.)
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.
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.
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.
How to use them
- When you set up a platform, or change how assignment or logging works, run a batch of A/A tests, or replay many A/A splits on historical data, and look at the distribution, not at any one result.
- On a small site, a few A/A tests are still worth running as a smoke test: they catch gross problems such as a broken split or missing logging, even if they cannot certify the statistics.
- At scale, platforms keep A/A tests running continuously in the background, as a smoke alarm: if the share of significant A/A results drifts above 5%, something changed.
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.
- Novelty and primacy. Returning users click on something because it is new, or avoid it because it is unfamiliar. Both fade. Plot the effect day by day; if it is shrinking or growing steadily, the average is not the long-run answer.
- Ramp-ups and mixing periods. If the share of traffic in the variant changed during the test, pooling the days can reverse the true direction of an effect (Simpson’s paradox). Analyse each allocation period, or only the stable one; this is why the ramp days at the start of a test are not counted (chapter 12).
- Carry-over. Reusing the same users from a previous experiment can leave traces of the old treatment. Fresh randomisation avoids it.
In practice
Four habits that catch a broken test before anyone reads its result.
- Check the sample ratio first, every time, before looking at any metric. The analyser does this and refuses to show results that fail.
- Treat an SRM as a bug to find, not a number to adjust. Look at the split by browser, platform, country and day; the cause usually lives in one segment.
- When a result looks too good, assume a bug until you have looked for one.
- Run A/A tests when you set up a platform and keep running them.
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
- Fabijan, A., Gupchup, J., Gupta, S., Omhover, J., Qin, W., Vermeer, L. and Dmitriev, P. (2019). Diagnosing Sample Ratio Mismatch in Online Controlled Experiments: A Taxonomy and Rules of Thumb for Practitioners. KDD 2019. And Vermeer’s taxonomy of causes.
- Microsoft Experimentation Platform. Diagnosing Sample Ratio Mismatch in A/B Testing. The 6% figure, the LinkedIn figure and the p < 0.0005 threshold.
- Dmitriev, P., Gupta, S., Kim, D. W. and Vaz, G. (2017). A Dirty Dozen: Twelve Common Metric Interpretation Pitfalls in Online Controlled Experiments. KDD 2017.
- Kohavi, R., Tang, D. and Xu, Y. (2020). Trustworthy Online Controlled Experiments. Cambridge University Press. Twyman’s law, A/A tests, novelty effects and Simpson’s paradox in ramp-ups.
- Kohavi, R. (2022). Raise the Bar on Shared A/B Tests: Make Them Trustworthy. An SRM test as a minimum for any shared result.
- Weigel, E. (2024). Design for Impact. SRMs explained for designers.