Analysis of Thompson Sampling for the Multi-armed Bandit Problem 2: Logarithmic Regret for N ArmsResearch Paper
Motivation
Thompson Sampling is the oldest heuristic for the multi-armed bandit problem: proposed by Thompson in 1933, it plays each arm with the posterior probability that the arm is the best one. It is simple to implement, performs well empirically (Chapelle and Li, NIPS 2011), and has been used in production systems such as click-through-rate prediction for search advertising. For a long time, however, no finite-time regret guarantee was known for it: the analyses available before 2012 gave only regret.
Agrawal and Goyal (arXiv:1111.1797, COLT 2012) gave the first logarithmic bounds on the expected regret of Thompson Sampling. This mission formalizes their bound for the general case of arms (their Theorem 2). A companion mission of the same series formalizes their two-armed bound (Theorem 1), whose proof is independent.
Timeline. Lai and Robbins (1985) proved that every consistent algorithm has regret at least of order . Auer, Cesa-Bianchi and Fischer (2002) showed that UCB1 achieves in finite time. Agrawal and Goyal (2012) proved for Thompson Sampling with arms; Kaufmann, Korda and Munos (2012) and Agrawal and Goyal (2013) later proved the asymptotically optimal constant for Bernoulli rewards.
Setting
A stochastic -armed bandit has arms . Arm , when played, yields a random reward drawn from a fixed distribution supported in , with mean ; rewards of an arm are i.i.d. and independent of the other arms. Arm is assumed to be the unique optimal arm, for , and is the gap of arm .
Thompson Sampling for general stochastic bandits (Algorithm 2 of the paper) keeps, for each arm , a count of successes and of failures, both starting at . In each round it draws independently for every arm, plays , observes a reward , performs a Bernoulli trial with success probability , and increments on success and on failure.
The expected regret in time is
the expectation being over the rewards, the Bernoulli trials and the posterior samples.
The proof works with the reward stacks : the outcome of the -th Bernoulli trial of arm , all independent. Then , the number of successes in the first plays of arm , is a random variable. The other objects of the proof are the threshold , the saturated set of suboptimal arms with at least plays before round , the intervals between the -th and -th plays of arm , and the counts and defined in §4.
Formalization targets
Goal: Theorem 2
There is an absolute constant such that for every , every instance as above and every horizon ,
does not depend on , on the reward distributions or on .
Milestones
- Lemma 4: with the event that every saturated arm's sample lies within of its mean, , also conditionally on .
- Lemma 5 (Eq. (7)): the expected regret from saturated arms inside is at most .
- Lemma 1: , where counts the trials before an independent sample exceeds .
- Lemma 3: a three-case bound on in terms of the Bernoulli KL divergence between and .
Significance
The result. Theorem 2 shows that Thompson Sampling, a randomized Bayesian heuristic, achieves regret logarithmic in the horizon for any number of arms with bounded rewards, matching the order in of the Lai–Robbins lower bound. Its dependence on the gaps, , is worse than UCB1's; the paper's own Remark 1 and later work improve it. The proof introduced the device of bounding the waiting time between plays of the optimal arm through geometric variables with Beta-cdf parameters (Lemmas 1 and 3), which reappears in later analyses of Thompson Sampling.
Formalizing it. The theorem is proved on paper; it has not been machine-checked. Bandit theory in Lean (bandit environments, regret, UCB-type analyses) is still young, and no Beta–Bernoulli Thompson Sampling result is formalized. The mission produces a Lean model of Algorithm 2 for general rewards with the paper's stack coupling, the §4 bookkeeping of saturated arms and intervals, and the paper's lemmas as separate targets.
Difficulty
Two difficulties are specific to the -armed analysis. First, the arm that competes with arm changes over time: the set of saturated arms grows, and which saturated arm is "best" depends on the history, so the waiting time between plays of arm cannot be compared with a single geometric variable as in the two-armed case. Second, the number of rounds at which arm 's sample is large but arm is not played is not independent of the counts : both depend on the same posterior samples, and Lemma 5 needs a careful conditioning on the history to separate them. The obvious union bound over arms, treating each suboptimal arm as in the two-armed proof, fails because it ignores the interruptions by unsaturated arms, whose number is the source of the squared sum in the bound.
Formalization scope
- Probability space. Algorithm 2 is realized on a product of three independent i.i.d. tables: Beta draws indexed by (arm, round, successes, failures), rewards indexed by (arm, round) and uniform variables indexed by (arm, round); the Bernoulli trial of a round succeeds when the played arm's uniform variable is below its reward. The law of the run is that of Algorithm 2, which runs for every round . is the number of successful trials among the first plays of arm in this infinite run (possibly after the horizon ), so it is a random variable for every , as the paper's independent make it. Ties in the arg max (probability ) go to the smallest index.
- Indexing. Arms are
Fin N, and Lean arm0is the paper's arm . Rounds are ; Lean round is the paper's round . Sums over are sums over . - Expectations are lower Lebesgue integrals in , which has no junk value for non-integrable functions. Conditional expectations given are written as finite sums over the values of .
- The . The paper writes in the sense of its footnote 1 ( for ). The goal states it with one universal constant , quantified before , the instance and , for every . The explicit constants printed in App. D are not formalized: expanding the paper's Eq. (21) gives terms and where the paper prints , and Eq. (22) drops a factor in its term. The claim does not depend on these slips; a statement pinned to the printed numerals might be false.
- Ruled out. A constant depending on , on the means or on ; a fixed number of arms; Bernoulli rewards only; or any algorithm other than Algorithm 2 would each make the goal a different and weaker theorem. The statement quantifies over all and all reward distributions on .
- Not included. Eq. (8), the bound "for all instantiations", is not a milestone: each term is conditioned on a different , and the pointwise reading does not follow from the argument given. Remark 1 (an alternate bound) and App. A (several optimal arms) are not part of this mission.
- Contributions welcome: Beta–Binomial identities, geometric waiting times, Hoeffding bounds for binomial cdfs, and the stopping-time arguments behind Lemma 5. Lemma 1 and Lemma 3 are shared with the two-armed mission of this series.
Selected references
- S. Agrawal and N. Goyal, Analysis of Thompson Sampling for the Multi-armed Bandit Problem, COLT 2012; arXiv:1111.1797v3, 2012. https://arxiv.org/abs/1111.1797
- W. R. Thompson, On the likelihood that one unknown probability exceeds another in view of the evidence of two samples, Biometrika 25, 1933. https://doi.org/10.1093/biomet/25.3-4.285
- T. L. Lai and H. Robbins, Asymptotically efficient adaptive allocation rules, Advances in Applied Mathematics 6, 1985. https://doi.org/10.1016/0196-8858(85)90002-8
- P. Auer, N. Cesa-Bianchi and P. Fischer, Finite-time analysis of the multiarmed bandit problem, Machine Learning 47, 2002. https://doi.org/10.1023/A:1013689704352
- O. Chapelle and L. Li, An empirical evaluation of Thompson Sampling, NIPS 2011. https://papers.nips.cc/paper/4321-an-empirical-evaluation-of-thompson-sampling
- E. Kaufmann, N. Korda and R. Munos, Thompson Sampling: an asymptotically optimal finite-time analysis, ALT 2012. https://arxiv.org/abs/1205.4217
- S. Agrawal and N. Goyal, Further optimal regret bounds for Thompson Sampling, AISTATS 2013. https://arxiv.org/abs/1209.3353