Writing

ExplorableBandits

Thompson sampling, one pull at a time

Each arm is a belief about a click rate. Pull, watch the belief sharpen, and compare the regret against a fixed A/B split.

Cumulative regret 
Thompson sampling
 
UCB1
 
ε-greedy
 
A/B split
 

Regret after T rounds is the sum, over those rounds, of the best true rate minus the true rate of the arm that was played. It uses the true rates and never the clicks, so the lines do not jump with each reward. This is a single seeded run. An average over many seeds would be smoother, and close policies can swap places from one seed to the next.

What to look for

  • Wide beliefs still get pulled. An arm with few pulls has a wide ridge, so now and then its draw lands to the right of the leader's and it gets another try. As the ridge narrows the draws stop reaching that far, and traffic moves to the best arm with no switch-over date.
  • The shape of the regret line. The A/B split pays the same price every round, so its line is straight. ε-greedy keeps paying for its random pulls. Thompson sampling and UCB1 bend toward flat as the weaker arms stop being played.
  • Old evidence is slow to forget. Let it run for a few hundred rounds, then shift the best arm. A ridge built from hundreds of pulls needs many more to move, and the regret lines turn upward until it does.