Course outline

Multi-Armed Bandits and Thompson Sampling

By the end of this lesson, you should be able to: explain Thompson sampling in three sentences, say which objective a bandit optimises and which it sacrifices, name the two conditions it needs, and decide between a bandit and an experiment on the question rather than on fashion.

Four promo banners

Meridian tests three promo banners against control. Only one of them does anything:

ArmTrue conversion rate
Control0.1840
A0.1840
B0.1840
C0.1941

An A/B test splits 240,000 users four ways and reads the result at the end. A bandit reallocates as it goes: the more an arm looks like a winner, the more traffic it gets.

Thompson sampling is the version worth knowing, and it's three sentences. Keep a posterior for each arm, exactly the Beta from lesson 1. To serve a user, draw one sample from each arm's posterior and serve whichever arm's sample came out highest. Update that arm's posterior with what happened.

That's it. There's no exploration parameter to tune. An arm that might be best gets traffic in proportion to the probability that it is best, which falls out of the sampling rather than being engineered.

What it bought

Same 240,000 users, one run of each:

ArmA/B pullsA/B conversionsBandit pullsBandit conversions
Control60,00010,85722,5004,221
A60,00010,94734,5006,501
B60,00011,09714,0002,607
C60,00011,719169,00032,848
Total240,00044,620240,00046,177

The bandit sent 70% of traffic to the winning arm and earned 1,557 extra conversions during the test.

Two panels. Left, four traffic-share lines over 240,000 users: the indigo arm C line climbs steadily from 0.25 to about 0.70 while grey control, amber A and teal B all decline toward the bottom. Right, two pairs of bars relative to the A/B baseline: conversions during the test at 1.00 versus 1.03, and standard error on a losing arm at 1.00 versus 3.10.
Left: the bandit finds arm C and commits to it. Right: what that commitment costs.

Averaged over 400 runs:

ConversionsPicked the winnerSE on a losing arm
A/B, equal split44,742100.0%0.00158
Thompson sampling46,29499.8%0.00489

+1,552 conversions, +3.47%. Both find the winner essentially always.