Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Try the new restaurant or go back to the good one?
Every time you eat out you choose: your favourite place (reliably good) or somewhere new (maybe better, maybe worse). Only by trying a place do you learn how good it is. Too much trying and you waste many evenings on bad food; too little and you may never discover the best place in town. This is the exploration–exploitation dilemma, and the multi-armed bandit (named after rows of slot machines, “one-armed bandits”) is its cleanest mathematical form.
Bandits decide which sensing mode to use when you can afford only one, which experiment to run next, which antenna or frequency to try, how to allocate observation time among targets, and which controller variant to deploy (A/B testing). They are also the simplest setting in which to learn the exploration ideas used in reinforcement learning.
- 1. In a bandit problem, after choosing an arm you see…
- 2. Exploring means…
- 3. Never exploring risks…
Level 1: Beginner
★★☆☆☆ Basic⏱ 25 minSecondary-school mathematics: arithmetic and elementary algebra.Stochastic bandits and regret
Arms i = 1, …, K give i.i.d. rewards with unknown means . With , gaps and the number of pulls of arm i:
Good algorithms pull bad arms only about log T times each.
Three strategies
- ε-greedy: with probability ε pull a random arm, otherwise the best empirical mean. With fixed ε it keeps exploring forever, so regret grows like , linear in T.
- UCB1 (Auer, Cesa-Bianchi, Fischer, 2002): pull . “Optimism in the face of uncertainty.”
- Thompson sampling: keep a posterior per arm (Beta(1 + successes, 1 + failures) for Bernoulli rewards), draw one sample from each, and pull the largest.
- 1. UCB1 index with mean 0.5, n = 2, t = e:
- 2. Beta posterior mean after 3 successes, 1 failure (uniform prior):
- 3. Fixed-ε greedy's long-run regret is…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.Lower bound (Lai and Robbins, 1985)
For any algorithm that is good on every instance (consistent), and every suboptimal arm,
where kl is the Bernoulli KL divergence. Arms that are hard to distinguish from the best (small kl) must be sampled more. The bound is asymptotic: at a finite T, regret can sit below the constant times ln T.
UCB1’s guarantee
Logarithmic, but with a worse constant than Lai–Robbins (1/Δ vs Δ/kl ≈ 1/(2Δ)). KL-UCB and Thompson sampling attain the optimal constant.
Minimax rate
Over all instances, the worst-case regret is . The hardest gaps are about : big enough to cost, small enough to be hard to detect.
- 1. The Lai–Robbins constant for each bad arm is…
- 2. UCB1's regret bound scales like…
- 3. The worst-case (minimax) regret is…
Level 3: Advanced
★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.Why UCB1 works (sketch)
By Hoeffding, with high probability for all arms at time t. If a bad arm i is pulled at time t, then its index beats the best arm’s, and on the good event , i.e. . So each bad arm is pulled at most times plus the (summable) failures of the good event, and multiplying by gives the bound. ∎
Thompson sampling
Thompson sampling selects arm i with exactly its posterior probability of being the best. It explores automatically: an arm’s posterior stays wide until it is pulled enough. Agrawal and Goyal (2012) and Kaufmann et al. (2012) proved it achieves the Lai–Robbins constant for Bernoulli bandits. Its Bayesian regret is on any prior (Russo and Van Roy, 2014).
Why the lower bound holds (idea)
To be sure arm i is not the best, an algorithm must collect enough evidence to rule out the alternative world in which is slightly above . Distinguishing the two worlds needs about samples of arm i (a change-of-measure argument), or else it suffers linear regret in the alternative world.
- 1. UCB1 pulls a bad arm at most about…
- 2. Thompson sampling pulls an arm with probability equal to…
- 3. The Lai–Robbins proof uses…
Level 4: Expert
★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.Bandits, measured
Exercise 1 (5 arms, 100 runs). Regret at T = 500, 1000, 2000 and 5000:
| algorithm | regret |
|---|---|
| ε-greedy (ε = 0.1) | 24.8, 39.6, 63.6, 126.8 |
| UCB1 | 51.0, 79.4, 117.4, 181.8 |
| Thompson sampling | 24.5, 29.9, 34.9, 41.4 |
ε-greedy’s regret grows linearly at 0.021 per round, matching ε·mean gap = 0.02. UCB1’s per-round regret falls, but its large constant makes it the worst here at this horizon. Thompson sampling’s regret grows by 7.1 per unit of ln T. The Lai–Robbins constant is 9.46 (× ln 5000 = 80.6), and Thompson sits below it at T = 5000. That’s no contradiction: the bound is asymptotic, and the slope is still climbing toward it.
Exercise 2: which gaps are hardest? On two arms (0.5 vs 0.5 − Δ) at T = 2000, UCB1’s regret is 9.2, 17.1, 30.9, 38.6, 36.9 and 26.0 for Δ = 0.01, 0.02, 0.05, 0.1, 0.2 and 0.4, and Thompson’s is 8.3, 13.6, 17.2, 14.4, 8.8 and 5.8. Tiny gaps cost little because the arms are nearly equal; big gaps are found quickly. The worst sits in between, always below √(KT) = 63. Thompson’s worst case over gaps grows from 9.6 at T = 500 to 17.2 at T = 2000 (×1.8 for 4× the rounds, close to √4 = 2).
Bandits in AI, robotics and aerospace
- Adaptive sensing: choose which instrument mode or target to observe when time is limited (Earth observation scheduling).
- Communication: select frequencies, beams or relays under unknown, changing channel quality.
- Experiment design and A/B testing of controller variants, with far less regret than fixed splits.
- RL exploration: UCB and Thompson ideas underpin exploration bonuses and posterior sampling in reinforcement learning.
References
- T. L. Lai, H. Robbins (1985). “Asymptotically efficient adaptive allocation rules.” Advances in Applied Mathematics, 6.
- P. Auer, N. Cesa-Bianchi, P. Fischer (2002). “Finite-time analysis of the multiarmed bandit problem.” Machine Learning, 47.
- W. R. Thompson (1933). “On the likelihood that one unknown probability exceeds another in view of the evidence of two samples.” Biometrika, 25.
- S. Agrawal, N. Goyal (2012). “Analysis of Thompson sampling for the multi-armed bandit problem.” COLT.
- D. Russo, B. Van Roy (2014). “Learning to optimize via posterior sampling.” Mathematics of Operations Research, 39.
- T. Lattimore, C. Szepesvári (2020). Bandit Algorithms. Cambridge University Press.