Multi-armed bandit vs. A/B test: which to use
A bandit sends more traffic to the winning variant while a test runs; an A/B test holds the split. What each costs, with 1,000 simulated tests of both.
The Mockly team
8 min readYour ad platform already works this way. Give Meta or Google five ads and it doesn't split your budget evenly for two weeks and then report back. It shifts delivery toward the ads that perform, as the results come in.
A multi-armed bandit brings that idea to the landing page. Instead of holding a 50/50 split until the test ends, it sends more visitors to the version that's winning while the test is still running. If you pay for every click, that sounds like free money.
It isn't free. This post covers what a bandit is, what it buys you, what it costs, and the mistake that makes its results lie, with numbers from 1,000 simulated tests run both ways.
What is a multi-armed bandit?#
The name comes from slot machines, the "one-armed bandits." Picture a row of them, each paying out at a different rate that you don't know, and a fixed number of pulls. Every pull spent finding out which machine is best is a pull not spent on the best machine. Every pull spent on the machine that looks best so far might be a pull on the wrong one. Balancing the two is the multi-armed bandit problem: explore, or exploit.
On a landing page, the machines are your variants, a pull is a visitor, and a payout is a conversion.
An A/B test settles the trade-off in two steps. First explore, at a fixed split, until you know which version is better. Then exploit, by shipping the winner to everyone. A bandit does both at once: it moves traffic a little at a time as the evidence comes in.
How a bandit decides where traffic goes#
The most widely used rule is Thompson sampling, which William Thompson published in 1933, decades before anyone had a web page to test. It says: give each variant a share of the traffic equal to the chance that it's the best one, given the results so far.
Say that after one day, B has converted a little better than A, and the numbers put the chance that B is truly the better page at 70%. B gets about 70% of tomorrow's visitors. If B keeps its lead, that chance climbs toward 100%, and so does its share. If the lead was luck, the chance falls back, and the traffic with it.
A variant that's probably losing still gets some visitors. That's what lets it recover when it was only unlucky, and it's the difference between a bandit and simply turning off whichever page is behind.
What a bandit buys you: fewer visitors on the losing page#
We simulated a test with a real winner. A converts at 5% and B at 6%, a 20% lift, with 2,000 visitors a day for 14 days. We ran it 1,000 times at a fixed 50/50 split, and 1,000 times with the split moved once a day by Thompson sampling, each version always keeping at least 5% of the traffic.
Share of each day's visitors sent to the better version
Day 7
- Moving split (a bandit)
- 86%
- Fixed split (an A/B test)
- 50%
Show the numbersHide the numbers
| Day | Moving split, to B | Fixed split, to B |
|---|---|---|
| 1 | 50% | 50% |
| 2 | 74% | 50% |
| 3 | 76% | 50% |
| 4 | 79% | 50% |
| 5 | 82% | 50% |
| 6 | 84% | 50% |
| 7 | 86% | 50% |
| 8 | 87% | 50% |
| 9 | 88% | 50% |
| 10 | 89% | 50% |
| 11 | 90% | 50% |
| 12 | 90% | 50% |
| 13 | 91% | 50% |
| 14 | 91% | 50% |
After one day at 50/50, the moving split sent B 74% of the second day's visitors, on average. By day 7 it was 86%, and by day 14, 91%. Over the whole test, 82.6% of visitors saw the better page, against 50% at a fixed split.
That's worth real conversions. The fixed split averaged 1,542 conversions a test, and the moving split 1,633: 5.9% more, from the same traffic, the same two pages, and the same two weeks. When the traffic is bought, that's 5.9% more orders for the same ad spend while the test runs.
What a bandit costs you: the verdict#
The visitors a bandit takes away from the losing page are the visitors that would have proved it was losing. With less traffic, the page that's behind is measured more slowly, and the gap between the two stays uncertain for longer.
In the same simulation, we read each test's results once a day, with intervals that stay valid at every look. The fixed split named B the winner within 14 days in 75.4% of tests. The moving split did in 31.1%.
So the bandit earned more during the test, and was far less likely to finish it. That's the trade in one line: a bandit makes the most of the test you're running, and an A/B test answers the question you asked. If the answer is worth more than two weeks of extra conversions, because you'll use it on the next ten pages, a fixed split gets you there sooner.
The trap: you can't count a bandit's results the usual way#
This is the part most explanations skip, and it's the part that costs money.
In an A/B test, you divide each variant's conversions by its visitors and compare. With a bandit, that same arithmetic can show a big difference between two identical pages.
The reason is timing. Conversion rates move. Weekends differ from weekdays, a sale lifts everything, and a new ad brings a different crowd. At a fixed split, both variants get the same share of the good days and the bad ones, so it cancels out. A bandit changes the split as it goes, so one variant ends up with more of its visitors on some days than on others.
Say both pages convert at 2% on an ordinary day and at 10% on a sale day, and the split has moved to 20/80 by the time the sale starts:
| A's visitors | A's conversions | B's visitors | B's conversions | |
|---|---|---|---|---|
| Ordinary day, split 50/50 | 1,000 | 20 | 1,000 | 20 |
| Sale day, split 20/80 | 400 | 40 | 1,600 | 160 |
| Counted together | 1,400 | 60, or 4.3% | 2,600 | 180, or 6.9% |
B looks 62% better. The pages are identical: each converted at exactly 2% on the ordinary day and exactly 10% on the sale day. B simply had more of its visitors on the day everything converted. Statisticians call this Simpson's paradox, and a bandit walks straight into it, because it moves traffic exactly when a variant looks good.
To see how often it bites, we ran 1,000 tests in which nothing differs between A and B, and both convert better as the days go, from 2% on day 1 to 10% on day 14.
Tests of two identical versions that named a winner
- Moving split, visitors counted together
- 70.0%
- Moving split, each day weighted (Mockly)
- 2.2%
- Fixed 50/50 split
- 1.3%
The dashed line is 5%: the most false winners the intervals allow.
With a moving split and every visitor counted together, 70.0% of the tests called one of two identical pages the winner.
The fix is to compare the variants within each day, where the split was fixed and the comparison is fair, and then weight each day by its share of all the visitors, the same weight for both variants. Read that way, the same tests named a winner 2.2% of the time. That's in line with the fixed split's 1.3%, and under the 5% the intervals allow.
In the table above, the weighting gives each page a 6% rate. Half the visitors came on each day, so each day counts for half, and both pages come out at the average of 2% and 10%.
It works when there's a real difference, too. With B truly 20% better and the same rising rate, the weighted results measured B's lift at 21% on average. Counted together, they measured it at 71%.
And when nothing drifts, the weighting does no harm: with both pages at a flat 5%, the weighted results named a false winner in 1.4% of tests.
When to use a bandit, and when to use an A/B test#
Use a bandit when the traffic is worth more than the answer:
- A page with a deadline. A sale lander, a launch page, or a holiday offer may be gone before a fixed test would finish. There's no "ship the winner" afterward, so the conversions during the test are the whole point.
- A risky challenger. You're testing a bold new angle against the page that pays the bills. If the new one flops, a bandit limits what the flop costs you.
- Many variants. With five headlines, most are losers. A bandit stops paying for them quickly.
Use a fixed-split A/B test when the answer is worth more than the traffic:
- A decision you'll build on. An offer, a price, or an angle you plan to scale across pages and ads deserves the fastest, cleanest verdict.
- A small expected difference. Small differences need every visitor measuring both sides.
- Low traffic. A bandit needs enough visitors each day to move on evidence, not on noise.
- A result someone else has to trust. A fixed split is easier to explain to a client or a finance team.
Whichever you choose, the rules for reading a test still hold. Peeking at results multiplies false winners unless your statistics allow for it, and running in whole weeks keeps weekday and weekend visitors in proportion.
Four questions to ask of any bandit#
Before you turn one on
- Does every variant keep a minimum share of traffic? Without one, an unlucky first day can starve a good page before it has the chance to recover.
- How often does the split move? If it moves faster than once a day, it chases the difference between morning and evening visitors.
- Are the results weighted by period? If the tool divides total conversions by total visitors, read the table above again.
- Does it ship the winner on its own? Decide whether you want a tool that ends the test without asking, or one that leaves the call to you.
How Mockly does it#
In Mockly, a bandit is a setting on an experiment, off to begin with, called Automatic allocation. Turned on, each variant's share of new visitors is the chance it's the best one on the experiment's goal, by Thompson sampling, for conversion rate or revenue per visitor. The chance is worked out rather than drawn at random, so the same results always give the same split.
Every variant keeps a minimum share: 5% each of two, or 3% each of three. The split moves at most once a day, and only once every variant has had 100 visitors since the last move. It waits while the experiment is paused, or while traffic isn't splitting the way it was set.
Results don't restart when the split moves. Each move begins a new period, and the rates, lifts, and verdict are weighted by period, as described above, with intervals that stay valid however often you look. Mockly never ships a winner on its own. That stays your call.
The simulations in this post use the studio's own allocation and statistics code, and a test in our codebase runs them again and checks every number quoted here. Automatic allocation explains the setting, and the product page shows it in the studio.
Further reading#
- William R. Thompson, On the Likelihood that One Unknown Probability Exceeds Another in View of the Evidence of Two Samples, Biometrika, 1933: where Thompson sampling comes from.
- Steven L. Scott, A modern Bayesian look at the multi-armed bandit, Applied Stochastic Models in Business and Industry, 2010: the case for using it in online experiments.
- Daniel Russo, Benjamin Van Roy, Abbas Kazerouni, Ian Osband, and Zheng Wen, A Tutorial on Thompson Sampling, Foundations and Trends in Machine Learning, 2018.
- Clifford H. Wagner, Simpson's Paradox in Real Life, The American Statistician, 1982.