arxiv: v2 [stat.ml] 19 Jul 2012

Similar documents
On Bayesian bandit algorithms

Bayesian and Frequentist Methods in Bandit Models

Stratégies bayésiennes et fréquentistes dans un modèle de bandit

Analysis of Thompson Sampling for the multi-armed bandit problem

Multi-armed bandit models: a tutorial

On the Complexity of Best Arm Identification in Multi-Armed Bandit Models

The information complexity of sequential resource allocation

Online Learning and Sequential Decision Making

Regret Analysis of Stochastic and Nonstochastic Multi-armed Bandit Problems, Part I. Sébastien Bubeck Theory Group

Bandit models: a tutorial

Two optimization problems in a stochastic bandit model

Lecture 5: Regret Bounds for Thompson Sampling

Two generic principles in modern bandits: the optimistic principle and Thompson sampling

The information complexity of best-arm identification

Revisiting the Exploration-Exploitation Tradeoff in Bandit Models

Advanced Machine Learning

Anytime optimal algorithms in stochastic multi-armed bandits

Analysis of Thompson Sampling for the multi-armed bandit problem

On the Complexity of Best Arm Identification with Fixed Confidence

KULLBACK-LEIBLER UPPER CONFIDENCE BOUNDS FOR OPTIMAL SEQUENTIAL ALLOCATION

Lecture 4: Lower Bounds (ending); Thompson Sampling

Informational Confidence Bounds for Self-Normalized Averages and Applications

Optimality of Thompson Sampling for Gaussian Bandits Depends on Priors

Subsampling, Concentration and Multi-armed bandits

Stat 260/CS Learning in Sequential Decision Problems. Peter Bartlett

Reinforcement Learning

Bandits : optimality in exponential families

On the Complexity of Best Arm Identification with Fixed Confidence

Kullback-Leibler Upper Confidence Bounds for Optimal Sequential Allocation

arxiv: v4 [cs.lg] 22 Jul 2014

Dynamic resource allocation: Bandit problems and extensions

On the Complexity of A/B Testing

Learning to play K-armed bandit problems

Bandit Algorithms. Tor Lattimore & Csaba Szepesvári

A minimax and asymptotically optimal algorithm for stochastic bandits

arxiv: v2 [stat.ml] 14 Nov 2016

Optimistic Bayesian Sampling in Contextual-Bandit Problems

Bandit Algorithms. Zhifeng Wang ... Department of Statistics Florida State University

arxiv: v4 [math.pr] 26 Aug 2013

Stat 260/CS Learning in Sequential Decision Problems. Peter Bartlett

Exploration and exploitation of scratch games

COS 402 Machine Learning and Artificial Intelligence Fall Lecture 22. Exploration & Exploitation in Reinforcement Learning: MAB, UCB, Exp3

arxiv: v3 [stat.ml] 6 Nov 2017

Optimistic Gittins Indices

Thompson Sampling for Contextual Bandits with Linear Payoffs

Complex Bandit Problems and Thompson Sampling

arxiv: v1 [cs.lg] 15 Oct 2014

Racing Thompson: an Efficient Algorithm for Thompson Sampling with Non-conjugate Priors

Learning to Optimize via Information-Directed Sampling

Regret Analysis of Stochastic and Nonstochastic Multi-armed Bandit Problems. Sébastien Bubeck Theory Group

Sparse Linear Contextual Bandits via Relevance Vector Machines

THE first formalization of the multi-armed bandit problem

Lecture 19: UCB Algorithm and Adversarial Bandit Problem. Announcements Review on stochastic multi-armed bandit problem

Improved Algorithms for Linear Stochastic Bandits

Annealing-Pareto Multi-Objective Multi-Armed Bandit Algorithm

Stat 260/CS Learning in Sequential Decision Problems.

arxiv: v3 [cs.lg] 7 Nov 2017

Value Directed Exploration in Multi-Armed Bandits with Structured Priors

Stochastic Regret Minimization via Thompson Sampling

Robustness of Anytime Bandit Policies

Exploiting Correlation in Finite-Armed Structured Bandits

Grundlagen der Künstlichen Intelligenz

Mechanisms with Learning for Stochastic Multi-armed Bandit Problems

arxiv: v1 [cs.lg] 12 Sep 2017

Csaba Szepesvári 1. University of Alberta. Machine Learning Summer School, Ile de Re, France, 2008

Chapter 2 Stochastic Multi-armed Bandit

An Information-Theoretic Analysis of Thompson Sampling

Multiple Identifications in Multi-Armed Bandits

The Multi-Armed Bandit Problem

Multi-armed bandit based policies for cognitive radio s decision making issues

Corrupt Bandits. Abstract

The Multi-Arm Bandit Framework

Best Arm Identification in Multi-Armed Bandits

Introduction to Reinforcement Learning Part 3: Exploration for decision making, Application to games, optimization, and planning

Evaluation of multi armed bandit algorithms and empirical algorithm

Bandits with Delayed, Aggregated Anonymous Feedback

Stochastic Contextual Bandits with Known. Reward Functions

Online Learning with Feedback Graphs

Reinforcement Learning

Introduction to Bandit Algorithms. Introduction to Bandit Algorithms

Multi armed bandit problem: some insights

An Estimation Based Allocation Rule with Super-linear Regret and Finite Lock-on Time for Time-dependent Multi-armed Bandit Processes

On Regret-Optimal Learning in Decentralized Multi-player Multi-armed Bandits

Regional Multi-Armed Bandits

arxiv: v1 [cs.ds] 4 Mar 2016

Finite-time Analysis of the Multiarmed Bandit Problem*

Lecture 3: Lower Bounds for Bandit Algorithms

Reinforcement Learning

Upper-Confidence-Bound Algorithms for Active Learning in Multi-Armed Bandits

The multi armed-bandit problem

Deviations of stochastic bandit regret

Stochastic Bandit Models for Delayed Conversions

Boundary Crossing for General Exponential Families

Multi-Armed Bandit Formulations for Identification and Control

Online Learning Schemes for Power Allocation in Energy Harvesting Communications

Multi-Armed Bandits. Credit: David Silver. Google DeepMind. Presenter: Tianlu Wang

Regret lower bounds and extended Upper Confidence Bounds policies in stochastic multi-armed bandit problem

Introduction to Reinforcement Learning Part 3: Exploration for sequential decision making

MDP Preliminaries. Nan Jiang. February 10, 2019

THE MULTI-ARMED BANDIT PROBLEM: AN EFFICIENT NON-PARAMETRIC SOLUTION

Transcription:

Thompson Sampling: An Asymptotically Optimal Finite Time Analysis Emilie Kaufmann, Nathaniel Korda and Rémi Munos arxiv:105.417v [stat.ml] 19 Jul 01 Telecom Paristech UMR CNRS 5141 & INRIA Lille - Nord Europe July 0, 01 Abstract The question of the optimality of Thompson Sampling for solving the stochastic multi-armed bandit problem had been open since 1933. In this paper we answer it positively for the case of Bernoulli rewards by providing the first finite-time analysis that matches the asymptotic rate given in the Lai and Robbins lower bound for the cumulative regret. The proof is accompanied by a numerical comparison with other optimal policies, experiments that have been lacking in the literature until now for the Bernoulli case. 1 Introduction In a stochastic bandit problem an agent is repeatedly asked to choose one action from an action set, each of which produces a reward drawn from an underlying, fixed, but unknown distribution associated with each action. Thus he must choose at each time whether to use the observations he has already gathered to gain the greatest immediate reward exploitation or whether to choose an action from which few observations have been made and risk immediate loss for greater knowledge and potential future gain exploration. In this paper we focus on stochastic bandits with Bernoulli rewards, initially proposed by Thompson in his paper of 1933 [14] to model medical allocation problems. Thompson s paper also presented the first bandit algorithm, Thompson Sampling. This algorithm has received much attention in the recent literature, and in this paper we give the first theoretical proof of the asymptotic optimality of this algorithm in the context of cumulative regret minimisation. Furthermore we achieve this result by giving a finite time analysis for the algorithm. Associated with each action, a, is an unknown Bernoulli distribution B µ a, whose expectation is µ a. At each time t the agent chooses to observe an action A t {1,..., K} and receives a reward R t drawn from the distribution B µ At. A policy, or bandit algorithm, is defined to be a possibly randomised method for choosing A t given the past history of observations and actions. The agent s goal is to minimize the expected cumulative regret of his policy, which is defined to be: [ T ] RT := T µ E R t = a Aµ µ a E[N a,t ] 1 where µ = max a µ a denotes the expectation of the best arm 1, or optimal action, and N a,t the number of draws of arm a at the end of round t. Lai and Robbins proved in [10] that all strongly consistent policies 1 The words arms and actions are used interchangably. 1

i.e. policies satisfying Rt = ot α for all α 0, 1 must satisfy, for any suboptimal arm a lim inf T E[N a,t ] ln T 1 Kµ a, µ where Kp, q denotes the Kullback-Leibler divergence between B p and B q: Kp, q := p ln p q + 1 p ln 1 p 1 q. Their result, which holds for more general classes of reward distributions, leads to the definition of asymptotically optimal policies as policies that satisfy with equality. In the same paper [10] Lai and Robbins were able to describe an asymptotically optimal policy, however no finite-time analysis was provided, nor was it an efficient policy to implement. The UCB1 algorithm by Auer et al. [4] was the first of a series of efficient policies, like UCB-V [3] or MOSS [], for which good regret bounds in finite time were also provided. These policies all use an upper confidence bound for the empirical mean of past rewards as an optimistic index for each arm, choosing at each time the action with the highest current index. However, for each of these algorithms we only have the result that there exists two constants K 1 > and K > 0 such that for every suboptimal action a, with a = µ µ a, E[N a,t ] K 1 lnt + K. 3 a This does not imply with equality since by the Pinsker inequality Kµ a, µ > a. On the contrary, recently proposed index policies such as DMED [8] and KL-UCB [6, 11], which use indices obtained from KL-based confidence regions, have been shown to be asymptotically optimal. Unlike most of this family of upper confidence bound algorithms that has been so successful, Thompson Sampling is a policy that uses ideas from Bayesian modelling and yet it solves the fundamentally frequentist problem of regret minimisation. Assume a uniform prior on each parameter µ a, let π a,t denote the posterior distribution for µ a after the t th round of the algorithm. Let θ a,t denote a sample from π a,t ; we sometimes refer to θ a,t as a Thompson sample. Thompson sampling is the policy which at time t chooses to observe the action with the highest Thompson sample θ a,t, i.e. it chooses action a with the probability that this action has the highest expected reward under the posterior distribution. Before Agrawal and Goyal s recent paper [1] Thompson Sampling had been investigated in [7] as the Bayesian Learning Automaton, and in [1] where an optimistic version was also proposed; however these papers only provided weak theoretical guarantees. In [5] extensive numerical experiments were carried out for Thompson Sampling beyond the scope of the Bernoulli bandit setting to the Generalized Linear Bandit Model but without any theoretical guarantee at all. Consequently the first finite-time analysis of Thompson Sampling in [1] was a major breakthrough, yet the upper bound for the regret that is shown in this paper scales like 3 and the question of Thompson Sampling s asymptotic optimality was still open. Meanwhile, there has been a resurgence of interest in Bayesian strategies for bandit problems see [9] for a review of them. The Bayes-UCB algorithm, an upper confidence bound policy which uses an adaptive quantile of π a,t as an optimistic index, was the first Bayesian algorithm to be proved asymptotically optimal. In this paper we are able to show that the same is true for a randomised Bayesian algorithm, Thompson Sampling. Moreover we refer in our analysis to the Bayes-UCB index when introducing the deviation between a Thompson Sample and the corresponding posterior quantile. Contributions We provide a finite-time regret bound for Thompson Sampling, that follows from 1 and from the result on the expected number of suboptimal draws stated in Theorem. More precisely we show the following:

Theorem 1 For every ɛ > 0 there exists a problem-dependent constant Cɛ, µ 1,..., µ K such that the regret of Thompson Sampling satisfies: a lnt + ln lnt RT 1 + ɛ Kµ a, µ + Cɛ, µ 1,..., µ K. a A:µ a µ Besides this asymptotically optimal regret bound, we also provide the first numerical experiments that show Thompson Sampling outperforming the current best optimal policies like DMED, KL-UCB or Bayes-UCB. The rest of the paper is structured as follows. Section contains notations or results already used in [1], [6] or [9] that are useful in our finite-time analysis given in Section 3. Numerical experiments are presented in Section 4. Preliminaries We gather together here some useful preliminaries such as notations not already given in the introduction: For the rest of this paper, we assume action 1 is the unique optimal action. Without loss of generality, we can assume that the parameter µ = µ 1,..., µ K of the problem is such that µ 1 > µ... µ K. We shall denote by S a,t the number of successes observed from action a by time t, and denote the empirical mean by: ˆµ a,t := S a,t N a,t. In the Bernoulli case, with a uniform prior on the parameters µ a of the arms, the posterior on arm a at time t is explicitly π a,t = Beta S a,t + 1, N a,t S a,t + 1. Let Fa,b Beta denote the cdf of a Beta distribution with parameters a and b and Fj,µ B resp f j,µ B the cdf resp pdf of a Binomial distribution with parameters j and µ. We recall an important link between Beta and Binomial distribution which was used in both [1] and [9]: F Beta a,b y = 1 F B a+b 1,ya 1 We use this Beta-Binomial trick at several stages of our analysis. We denote by u a,t resp. q a,t the KL-UCB resp. Bayes-UCB index at time t, and define them by { Sa,t u a,t : = argmax K, x x> S a,t N a,t N a,t q a,t : = Q 1 1 t lnt, π a,t. } lnt + lnlnt N a,t where Qα, π denotes the quantile of order α of the distribution π A special link between these two indices is shown in [9]: q a,t < u a,t. In Appendix A of [1] the authors show that adding a second optimal arm can only improve the regret performance of Thompson Sampling. 3

3 Finite Time Analysis 3.1 Sketch of Analysis Unlike Agrawal and Goyal s analysis, which is based on explicit computation of the expectation E[N,T ], we are more inspired by standard analyses of frequentist index policies. Such policies compute, for each arm a at round t, an index, l a,t, from the sequence of rewards observed from a by time t, and choose A t = argmax a l a,t. A standard analysis of such a policy aims to bound the number of draws of a suboptimal arm, a, by considering two possible events that might lead to a play of this arm: the optimal arm arm 1 is under-estimated, i.e. l 1,t < µ 1 ; the optimal arm is not under-estimated and the suboptimal arm a is drawn. Taking these to be a good description of when the suboptimal arm is drawn leads to the decomposition E[N a,t ] P l 1,t < µ 1 + P l a,t l 1,t > µ 1 A t = a The analysis of an optimistic algorithm then proceeds by showing that the left term the underestimation term is o lnt and the right term is of the form lnt + o lnt or at 1 worst a Kµ a,µ 1 lnt + o lnt as in the analysis of UCB1. This style of argument works for example for the KL-UCB algorithm [6] and also for the Bayesian optimistic algorithm Bayes-UCB [9]. However we cannot directly apply this approach to analyse Thompson Sampling, since the sample θ a,t is not an optimistic estimate of µ a based on an upper confidence bound. Indeed, even when π 1,t is well concentrated and therefore close to a Gaussian distribution centred at µ 1, P θ 1,t < µ 1 is close to 1 and the under-estimation term is not o lnt. Hence we will not compare in our proof the sample θ a,t to µ a, but to µ a 6 lnt/n a,t if N a,t > 0 which is the lower bound of an UCB interval. We set the convention that if N a,t = 0, 6 lnt/n a,t =. As is observed in [1] the main difficulty in a regret analysis for Thompson Sampling is to control the number of draws of the optimal arm. We provide this control in the form of Proposition 1 whose proof, given in Section 3.3, explores in depth the randomised nature of Thompson Sampling. Proposition 1 There exists constants b = bµ 1, µ 0, 1 and C b = C b µ 1, µ < such that P t b C b. This proposition tells us that the probability that the algorithm has seen only a small number draws on arm 1 is itself small. As a result we can reduce to analysing the behaviour of the algorithm once it has seen a reasonable number of draws on arm 1, and thus the posterior distribution is well concentrated. Remark 1 In general, a result on the regret like E[ ] t K lnt does not imply a deviation inequality for see [13]. Proposition 1 is therefore a strong result, that enables us to adapt the standard analysis mentioned above. Using this result, the new decomposition finally yields the following theorem: Theorem Let ɛ > 0. With b as in Proposition 1, for every suboptimal arm a, there exist constants Dɛ, µ 1, µ a, Nb, ɛ, µ 1, µ a and N 0 b such that: lnt + ln lnt E[N a,t ] 1 + ɛ + Dɛ, µ 1, µ a + Nb, ɛ, µ 1, µ a + N 0 b + 5 + C b. Kµ a, µ 1 The constants will be made more explicit in the proofs of Proposition 1 and Theorem. The fact that Theorem holds for every ɛ > 0 gives us the asymptotic optimality of Thompson Sampling. 4

3. Proof of Theorem Step 1: Decomposition First we recall the modified decomposition mentioned above: 6 lnt 6 lnt E[N a,t ] P θ 1,t µ 1 + P θ a,t > µ 1, A t = a N 1,t N 1,t 6 lnt P θ 1,t µ 1 + 6 lnt P θ a,t > µ 1, A t = a, θ a,t < q a,t + P θ a,t > q a,t The sample θ a,t is not very likely to exceed the quantile of the posterior distribution q a,t we introduced: P θ a,t > q a,t 1 t lnt 1 + lnt lnt where this last inequality follows for T e. So finally, using that u a,t q a,t, 6 lnt 6 lnt E[N a,t ] P θ 1,t µ 1 + P u a,t > µ 1, A t = a + 4 } {{ } A } {{ } B Step : Bounding term A Dealing with term A boils down to showing a new self-normalized inequality adapted to the randomisation present in each round of the Thompson algorithm. Lemma 1 There exists some deterministic constant N 0 b such that 6 lnt P θ 1,t µ 1 N 0 b + 3 + C b < with C b defined as in Proposition 1. Proof. Let U t denote a sequence of i.i.d. uniform random variables, and let Σ 1,s be the sum of the first s rewards from arm 1. In the following, we make the first use of the link between Beta and Binomial distributions: P θ 1,t µ 1 6 lnt = P U t FS Beta +1, S 1,t+1 µ 1 1,t t b 6 lnt 6 lnt = P U t 1 F B S 6 lnt 1,t + P t b +1,µ 1 = P F B S 1,t U t t b + P t b +1,µ 1 P s {t b...t} : F B 6 lnt s+1,µ 1 s = t s= t b P Σ 1,s F B 1 6 lnt s+1,µ 1 s Σ 1,s U t + P t b U t + P t b 5

The first term in the final line of this display now deals only with Binomial random variables with large numbers of trials greater than t b, and so we can draw on standard concentration techniques to bound this term. Proposition 1 takes care of the second term. Note that F B 1 U t Bin s + 1, µ 1 6 lnt/s and is independent from Σ 1,s s+1,µ 1 6 lnt/s Bin s, µ 1. For each s, we define two i.i.d. sequences of Bernoulli random variables: 6 lnt X 1,l l B µ 1 and X,l l B µ 1, s 6 lnt and we let Z l := X,l X 1,l, another i.i.d. sequence, with mean s. Using these notations, s s 6 lnt P Σ 1,s F B 1 6 lnt s+1,µ 1 s U t P l=1 Z l 1 = P l=1 Z l s 6s lnt 1. Let N 0 b be such that if t N 0 b, 6t b lnt 1 > 5t b lnt. For t N 0 b, we can apply Hoeffding s inequality to the bounded martingale difference sequence Z l = Z l 6 lnt/s to get P Σ 1,s < F B 1 6 lnt s+1,µ 1 s U t exp 5s lnt 4s = e 5 lnt = 1. t 5 We conclude that 6 lnt P θ 1 t < µ 1 N 0 b + 1 t 3 + C b N 0 b + 3 + C b. Step 3: Bounding Term B We specifically show that: Lemma For all a =,..., K, for any ɛ > 0 there exist Nb, ɛ, µ 1, µ a, Dɛ, µ 1, µ a > 0 such that for all T > Nb, ɛ, µ 1, µ a lnt + ln lnt B 1 + ɛ + Dɛ, µ 1, µ a. Kµ a, µ 1 Proof. First rewrite term B so that we can apply Proposition 1: 6 lnt B P u a,t > µ 1, A t = a, t b + P t b N 1,t 6 lnt P u a,t > µ 1, A t = a + C b For ease of notation we introduce t b K + x, y := Kx, y1 x y, f T t := lnt + lnlnt 6 lnt lnt + ln lnt β t = t b, and K T,a ɛ = 1 + ɛ. Kµ a, µ 1 Now u a,t α = N,t K + ˆµ,N,t, α f T t 6

and so summing over the values of N,t and inverting the sums we get K T,a P u a,t > µ 1 β t, A t = a =E s=1 + E t=s s= K T,a +1 t=s 1 sk + ˆµ a,s,µ 1 β t f T t1 At=a,N,t=s 1 sk + ˆµ a,s,µ 1 β t f T t1 At=a,N,t=s As y K + ˆµ a,s, y is increasing and t β t is decreasing for t e 1/b, for T such that we have that if t K T,a ɛ, K T,a ɛ e 1/b, 5 1 sk + ˆµ a,s,µ 1 β t f T t 1 sk+ ˆµ a,s,µ 1 β KT,a f T t 1 sk + ˆµ a,s,µ 1 β KT,a f T T. and therefore, P u a,t > µ 1 β t, A t = a E +E K T,a s=1 t=s s= K T,a +1 1 At=a,N,t=s 1 sk+ ˆµ a,s,µ 1 β KT,a f T T t=s. 1 At=a,N,t=s Given that T t=s 1 A t=a,n,t=s 1 for all s, the first term is upper bounded by K a,t, whereas the second is upper bounded by E 1 KT,a K + ˆµ a,s,µ 1 β KT,a f T T So, for T satisfying 5, B K T,a + s= K T,a +1 K T,a +1 Using the convexity of K + ˆµ a,s,., we can show that P K + ˆµ Kµ a, µ 1 a,s, µ 1 β KT,a. 1 + ɛ K + ˆµ a,s, µ 1 K + ˆµ a,s, µ 1 β Ka,T + If K + ˆµ a,s, µ 1 β KT,a Kµa, µ 1 /1 + ɛ, then K + ˆµ a,s, µ 1 Kµ a, µ 1 1 + ɛ Kµ a, µ 1 1 + ɛ/ + µ 1 1 µ 1 β K a,t. µ 1 1 µ 1 β K a,t where the last inequality 6 holds for large enough T. There exists a deterministic constant N = Nb, ɛ, µ 1, µ a such that for all T N both 5 and 6 are satisfied. Hence, for all T N B K T,a + P K + ˆµ a,s, µ 1 Kµ a, µ 1 1 + ɛ. K T,a +1 Since this last sum is bounded above explicitly by some constant Dɛ, µ 1, µ a in [11] we have proved the lemma. To be explicit, Dɛ, µ 1, µ a = 1+ɛ/ ɛ minµ a1 µ a;µ 11 µ 1. 7. 6

Conclusion: The result now follows from Lemmas 1, and inequality 4. 3.3 Proof of Proposition 1 Since we focus on the number of draws of the optimal arm, let τ j be the occurrence of the j th play of the optimal arm with τ 0 := 0. Let ξ j := τ j+1 1 τ j : this random variable measures the number of time steps between the j th and the j +1 th play of the optimal arm, and so K a= N a,t = j=0 ξ j. For each suboptimal arm, a relevant quantity is C a = 3 µ 1 µ a and let C = max a 1 C a = 3 µ 1 µ. We also introduce δ a = µ1 µa and let δ = δ. Step 1: Initial Decomposition of Summands First we use a union bound on the summands to extract the tails of the random variables ξ j : K P t b = P N,t t t b a= P j { 0,.., t b } : ξ j t 1 b 1 t b Pξ j t 1 b 1 7 j=0 This means that there exists a time range of length t 1 b 1 during which only suboptimal arms are played. In the case of two arms this implies that the unique suboptimal arm is played t1 b 1 times during the first half of this time range. Thus its posterior becomes well concentrated around its mean with high probability, and we can use this fact to show that the probability the suboptimal action is chosen a further t1 b 1 times in a row is very small. In order to generalise this approach we introduce a notion of a saturated, suboptimal action: Definition 1 Let t be fixed. For any a 1, an action a is said to be saturated at time s if it has been chosen at least C a lnt times. That is N a,s C a lnt. We shall say that it is unsaturated otherwise. Furthermore at any time we call a choice of an unsaturated, suboptimal action an interruption. We want to study the event E j = {ξ j t 1 b 1}. We introduce the interval I j = {τ j, τ j + t 1 b 1 } included in {τ j, τ j+1 } on E j and begin by decomposing it into K subintervals: { l 1t 1 b 1 lt 1 b } 1 I j,l := τ j +, τ j +, l = 1,..., K. K K Now for each interval I j,l, we introduce: F j,l : the event that by the end of the interval I j,l at least l suboptimal actions are saturated; n j,l : the number of interruptions during this interval. We use the following decomposition to bound the probability of the event E j : PE j = PE j F j,k 1 + PE j F c j,k 1 8 To bound both probabilities, we will need the fact, stated in Lemma 3, that the probability of θ 1,s being smaller than µ + δ during a long subinterval of I j is small. This follows from the fact that the posterior on the optimal arm is always BetaS 1,τj + 1, j S 1,τj + 1 on I j : hence, when conditioned on S 1,τj, θ 1,s is an i.i.d. sequence with non-zero support above µ + δ, and thus is unlikely to remain below µ + δ for a long time period. This idea is also an important tool in the analysis of Thompson Sampling in [1]. 8

Lemma 3 λ 0 = λ 0 µ 1, µ > 1 such that for λ ]1, λ 0 [, for every random interval J included in I j and for every positive function f, one has P { s J, θ 1,s µ + δ} { J ft} α µ1,µ ft + C λ0,λ where C λ,µ1,µ, d λ,µ1,µ > 0, and α µ1,µ = 1/ 1 µ δ. 1 ft λ e jd λ,µ 1,µ The proof of this important lemma will be postponed to section 3.4 and all the constants are explicitly defined there. Another keypoint in the proof is the fact that a sample from a saturated suboptimal arm cannot fall too far from its true mean. The following lemma is easily adapted from Lemma in [1]. Lemma 4 P s t, a 1 : θ a,s > µ a + δ a, N a,s > C a lnt K 1 t. Step : Bounding PE j F j,k 1 On the event E j F j,k 1, only saturated suboptimal arms are drawn on the interval I j,k. Using the concentration results for samples of these arms in Lemma 4, we get PE j F j,k 1 P{ s I j,k, a 1 : θ a,s > µ a + δ} E j F j,k 1 + P{ s I j,k, a 1 : θ a,s µ a + δ a } E j F j,k 1 P s t, a 1 : θ a,s > µ a + δ a, N a,t > C a lnt + P{ s I j,k, a 1 : θ a,s µ + δ} E j F j,k 1 K 1 t + Pθ 1,s µ + δ, s I j,k. The last inequality comes from the fact that if arm 1 is not drawn, the sample θ 1,s must be smaller than some sample θ a,s and therefore smaller than µ + δ. Since I j,k is an interval in I j of size we get using Lemma 3, for some fixed λ ]1, λ 0 [, t 1 b 1 K Pθ 1,s µ + δ, s I j,k } α µ1,µ t 1 b 1 K t 1 b λ 1 + C λ,µ1,µ e jd λ,µ1,µ =: gµ1, µ, b, j, t. K 9 Hence we have show that PE j F j,k 1 and choosing b such that b < 1 1 λ, the following hypothesis on g holds: gµ 1, µ, b, j, t < +. t 1 j t b K 1 t + gµ 1, µ, b, j, t, 10 Step 3: Bounding PE j Fj,K 1 c larger than some deterministic constant N µ1,µ,b specified in the base case, K 1 PE j Fj,l 1 c l t + fµ 1, µ, b, j, t for some function f such that t 1 We show through an induction that for all l K, if t is 1 j t fµ 1, µ b, b, j, t <. For l = K we get K 1 PE j Fj,K 1 c K t + fµ 1, µ, b, j, t. 11 9

Step 4: The Base Case of the induction Note that on the event E j only suboptimal arms are played during I j,1. Hence at least one suboptimal arm must be played t1 b 1 K times. There exists some deterministic constant N µ1,µ,b such that for t N µ1,µ,b, t1 b 1 K C lnt the constant depends only on µ 1 and µ because C = C. So when t N µ1,µ,b, at least one suboptimal arm must be saturated by the end of I j,1. Hence, for t N µ1,µ,b This concludes the base case. PE j F c j,1 = 0. Step 5: The Induction As an inductive hypothesis we assume that for some l K 1 if t N µ1,µ,b then K 1 PE j Fj,l 1 c l t + fµ 1, µ, b, j, t. Then, making use of the inductive hypothesis, PE j Fj,l c PE j Fj,l 1 c + PE j Fj,l c F j,l 1 K 1 l t + fµ 1, µ, b, j, t + PE j Fj,l c F j,l 1. To complete the induction we therefore need to show that: PE j F c j,l F j,l 1 K 1 t + fµ 1, µ, b, j, t. 1 On the event E j F c j,l F j,l 1, there are exactly l 1 saturated arms at the beginning of interval I j,l and no new arm is saturated during this interval. As a result there cannot be more than KC lnt interruptions during this interval, and so we have PE j F c j,l F j,l 1 PE j F j,l 1 {n j,l KC lnt}. Let S l denote the set of saturated arms at the end of I j,l and introduce the following decomposition: PE j F j,l 1 {n j,l KC lnt} Clearly, using Lemma 4: P{ s I j,l, a S l 1 : θ a,s > µ a + δ a } E j F j,l 1 }{{} A + P{ s I j,l, a S l 1 : θ a,s µ a + δ a } E j F j,l 1 {n j,l KC lnt}. }{{} B A P s t, a 1 : θ a,s > µ a + δ a, N a,s > C a lnt K 1 t. To deal with term B, we introduce for k in {0,..., n j,l 1} the random intervals J k as the time range between the k th and k + 1 st interruption in I j,l. For k n j,l we set J k =. Note that on the event in the probability B there is a subinterval of I j,l of length during which there are t 1 b 1 CK lnt no interruptions. Moreover on this subinterval of I j,l, for all a 1, θ a,s µ + δ. This holds for unsaturated arms as well as for saturated arms since their samples are smaller than the maximum sample 10

of a saturated arm. Therefore, { } B P k {0,..., n j,l } : J k t1 b 1 CK { s I j,l, a S l 1 1 : θ a,s µ + δ} E j F j,l 1 lnt KC lnt { } P J k t1 b 1 CK { s J k, a 1 : θ a,s µ + δ} E j lnt k=1 KC lnt k=1 { } P J k t1 b 1 CK { s J k, θ 1,s µ + δ} lnt Now, we have to bound the probability that θ 1,s µ + δ for all s in an interval of size in I j. So we apply Lemma 3 to get: B CK lnt α µ1,µ t 1 b 1 CK lnt CK lnt + Cλ,µ1,µ t 1 b 1 CK lnt λ e jd λ,µ 1,µ := fµ1, µ, b, j, t. 13 t1 b 1 CK lnt included Choosing the same b as in 9, we get that t 1 1 j t fµ 1, µ b, b, j, t < +. It follows that for this value of b, 1 holds and the induction is complete. Step 8: Conclusion Let b be the constant chosen in Step. From the decomposition 8 and the two upper bounds 10 and 11, we get, for t N µ1,µ,b: K 1 K 1 PE j K t + fµ 1, µ, b, j, t + t + gµ 1, µ, b, j, t. Recalling 7, summing over the possible values of j and t we obtain: P t b N µ1,µ,b + K 1 t b + t 1 t 1 t 1 for some constant C µ1,µ,b <. 3.4 Proof of Lemma 3 1 t b j=1 [Kfµ 1, µ, b, j, t + gµ 1, µ, b, j, t] < C µ1,µ,b On the interval the J included in I j by hypothesis, the posterior distribution π 1,s = π 1,τj is fixed and θ 1,s is, when conditioned on S 1,τj, an i.i.d. sequence with common distribution BetaS 1,τj +1, j S 1,τj +1. Hence, P θ 1,s µ + δ s J = FS Beta 1,τj +1,j S 1,τj +1 µ + δ = 1 Fj+1,µ B S +δ 1,τ j where we use the link between the tail of Beta and Bernoulli distribution mentioned above. Using the independence of the θ 1,s gives P J ft s J, θ 1,s µ + δ S 1,τj = 1 Fj+1,µ B S +δ 1,τ j 1 Fj+1,µ B S +δ 1,τ j Finally P s J, θ 1,s µ + δ = E [ P [ ] ] ft s J, θ 1,s µ + δ S 1,τj E 1 Fj+1,µ B S +δ 1,τ j An exact computation of this expectation leads to [ E 1 Fj+1,µ B S +δ 1,τ j ft] = 11 j 1 Fj+1,µ B +δ sft fj,µ B 1 s s=0

To simplify notation, from now on let y = µ + δ. Using, as in [1], that Fj+1,y B s = 1 yf j,y B s + yfj,y B s 1 1 yf j,y B s, we get: 1 Fj+1,y B sft exp ftfj+1,y B s exp ft1 yfj,y B s Therefore, [ E 1 Fj+1,µ B S +δ 1,τ j ft] j s=0 exp ft1 yfj,y B s fj,µ B 1 s Using the fact that for s yj, Fj,y B s 1 since the median of a binomial distribution with parameters j and y is yj or yj, we get E [1 Fj+1,µ+δ B S 1,τ j ft] jy s=0 jy s=0 exp ft1 yfj,y B s fj,µ B 1 s + exp ft1 yfj,y B s fj,µ B 1 s + } {{ } E j s= jy 1 1 yft 1 fj,µ B 1 s 1 yft. It is easy to show that for every λ > 1, x > 0, x λ exp x λ e λ This allows us to upper-bound the exponential for all λ > 1, using C λ = λ e λ,by: E jy C λ ft1 y λ s=0 f B j,µ 1 s F Bj,y s λ jy C λ ft1 y λ s=0 Now, inspired by Agrawal and Goyal s work proof of Lemma 3 we compute: f B j,µ 1 s f Bj,y s λ = j s µ s 1 1 µ 1 j s f B j,µ 1 s f Bj,y s λ j λyλ µs 11 µ 1 j s s s 1 y λ j s y λ s 1 y λ j s j 1 µ1 µ1 1 y λ = 1 y λ y λ 1 µ 1 Let R λ µ 1, y = µ11 yλ y λ 1 µ 1. There exists some λ 1 > 1 such that, if λ < λ 1, R λ > 1. More precisely, R λ > 1 µ λ 1 y µ1 y > ln > λ ln 1 µ 1 1 y 1 µ 1 1 y s and so λ 1 µ 1, y = µ1 ln 1 µ 1 ln y 1 y if y > 1 + if y < 1 1

For 1 < λ < λ 1 : jy s=0 f B j,µ 1 s f B j,µ +δ sλ 1 µ1 1 y λ 1 µ1 1 y λ j jy j 1 Rλ s µ1 R jy +1 λ 1 = 1 y λ R s=0 λ 1 j R λ R λ 1 Rjy λ = R j jy λ 1 µ1 µ1 R λ 1 1 y λ y λ = R λ R λ 1 e jd λy,µ 1 where d λ y, µ 1 = y ln y λ µ 1 + 1 y ln 1 y λ 1 µ 1. Rearranging we can write d λ y, µ 1 = λ [y lny + 1 y ln1 y] [y lnµ 1 + 1 y ln1 µ 1 ] which is an affine function of λ with negative slope y lny + 1 y ln1 y < 0 for all y 0, 1 and d 1 y, µ 1 = K y, µ 1 > 0. Hence, for fixed 0 < y < µ 1 1 this function is positive whenever λ < y lnµ 1 + 1 y ln1 µ 1 y lny + 1 y ln1 y =: λ µ 1, y. Clearly, λ µ 1, y > 1 and we choose λ 0 = minλ 1, λ. After some calculation one can show that λ λ 1, and therefore that Kµ + δ, µ 1 λ 0 µ 1, µ = λ µ 1, µ + δ = 1 + µ + δ ln 1 µ + 1 µ 1. +δ δ ln 1 µ δ To obtain the constants used in the statement of the lemma we define d λ,µ1,µ := d λ y, µ 1 jy This concludes the proof. C λ,µ1,µ := C λ0 1 µ δ λ R λ 1 R λ. 4 Experiments We illustrate here the performance of Thompson Sampling on numerical experiments with Bernoulli rewards. First we compare in terms of cumulative regret up to horizon T = 10000 Thompson Sampling to UCB, KL-UCB and Bayes-UCB in two different two-arms problem, one with small rewards and the other with high rewards, with different gaps between the parameters of the arms. Figure 1 shows Thompson Sampling always outperforms KL-UCB and also Bayes-UCB for large horizons. The three optimal policies are significantly better than UCB, even for small horizons. Figure displays for several algorithms an estimation of the distribution of the cumulative regret based on N = 50000 trials, for a horizon T = 0000 in a 10-armed bandit problem with µ = 0.1, 0.05, 0.05, 0.05, 0.0, 0.0, 0.0, 0.01, 0.01, 0.01. The first two algorithms are variants of UCB. Of these the UCB-V algorithm is close to the index policy to which Thompson Sampling is compared in [5] in the Bernoulli setting, but this policy is not known to be optimal. This algorithm incorporates an estimation of the variance of the rewards in the index which is defined to be, for an arm that have produced k rewards in n draws, k n + logt n k n 1 k n + 3 logt n The other algorithms displayed in Figure have a mean regret closer sometimes smaller than the lower bound which is only asymptotic, and among them, Thompson is the best. It is also the easiest optimal policy to implement, since the optimization problem solved in KL-UCB and even the computation of the quantiles in Bayes-UCB are more costly than producing one sample from the posterior for each arm. 13

45 35 40 35 UCB KL UCB Bayes UCB Thompson Sampling 30 5 UCB KL UCB Bayes UCB Thompson Sampling 30 5 0 0 15 15 10 10 5 5 0 0 1000 000 3000 4000 5000 6000 7000 8000 9000 10000 0 0 1000 000 3000 4000 5000 6000 7000 8000 9000 10000 Figure 1: Cumulated regret for the two armed-bandit problem with µ 1 = 0., µ = 0.5 left and µ 1 = 0.8, µ = 0.9 right. Regret is estimated as an average over N = 0000 trials. 500 UCB 500 UCB V 500 DMED 400 400 400 R n 300 00 300 00 300 00 100 100 100 0 10 10 3 10 4 0 10 10 3 10 4 0 10 10 3 10 4 500 KL UCB 500 Bayes UCB 500 Thompson 400 400 400 R n 300 00 300 00 300 00 100 100 100 0 10 10 3 10 4 n log scale 0 10 10 3 10 4 n log scale 0 10 10 3 10 4 n log scale Figure : Regret of the various algorithms as a function of time on a log scale. On each graph, the red dashed line shows the lower bound, the solid bold curve corresponds to the mean regret while the dark and light shaded regions show respectively the central 99% and the upper 0.05% 14

5 Discussion This paper provides the first proof of the asymptotic optimality of Thompson Sampling for Bernoulli bandits. Moreover the proof consists in a finite time analysis comparable with that of other known optimal policies. We also provide here simulations showing that Thompson Sampling outperforms currently known optimal policies. Our proof of optimality borrows some ideas from Agrawal and Goyal s paper, such as the notion of saturated arms. However we make use of ideas together with our own to obtain a stronger result, namely control over the tail of rather than its expectation. This is a valuable result which justifies the complexity of the proof of Proposition. Indeed control over these tails allows us to give a simpler finite time analysis for Thompson Sampling which is closer to the arguments for UCB-like algorithms, and also yields the optimal asymptotic rate of Lai and Robbins. Thanks to the generalisation pointed out in [1], the Bernoulli version of Thompson Sampling can be applied to bandit problems with bounded rewards, and is therefore an excellent alternative to UCB policies. It would also be very natural to generalise Thompson to more complex reward distributions, choosing a prior appropriate for the assumptions on these distributions. Indeed, even in complex settings where the prior is not computable, Thompson Sampling only requires one sample from the posterior, which can be obtained efficiently using MCMC. Encouraging numerical experiments for reward distributions in the exponential family using a conjugate prior suggest that a generalisation of the proof is achievable. However this poses quite a challenge since the proof here is often heavily dependent on specific properties of Beta distributions. A natural generalisation would need a prior-dependent finite-time result controlling the tail probabilities of posterior distributions as the number of samples increases. Acknowledgments We thank Aurélien Garivier and Olivier Cappé, for many fruitful discussions and for giving us the opportunity to work together. This work was supported by the French National Research Agency ANR-08-COSI-004 project EXPLO- RA and the European Communitys Seventh Framework Programme FP7/007-013 under grant agreements n 16886 PASCAL, and n 7037 CompLACS. References [1] S. Agrawal and N. Goyal. Analysis of thompson sampling for the multi-armed bandit problem. In Conference On Learning Theory COLT, 01. [] J-Y. Audibert and S. Bubeck. Regret bounds and minimax policies under partial monitoring. Journal of Learning Resaerch, 010. [3] J-Y. Audibert, R. Munos, and Cs. Szepesvári. Exploration-exploitation trade-off using variance estimates in multi-armed bandits. Theoretical Computer Science, 41019, 009. [4] P. Auer, N. Cesa-Bianchi, and P. Fischer. Finite-time analysis of the multiarmed bandit problem. Machine Learning, 47:35 56, 00. [5] O. Chapelle and L. Li. An empirical evaluation of thompson sampling. In NIPS, 011. [6] A. Garivier and O. Cappé. The kl-ucb algorithm for bounded stochastic bandits and beyond. In Conference On Learning Theory COLT, 011. [7] O.C. Granmo. Solving two-armed bernoulli bandit problems using a bayesian learning automaton. International Journal of Intelligent Computing and Cybernetics, 3:07 34, 010. [8] J. Honda and A. Takemura. An asymptotically optimal bandit algorithm for bounded support models. In Conference On Learning Theory COLT, 010. 15

[9] E. Kaufmann, A. Garivier, and O. Cappé. On bayesian upper-confidence bounds for bandit problems. In AISTATS, 01. [10] T.L. Lai and H. Robbins. Asymptotically efficient adaptive allocation rules. Advances in Applied Mathematics, 61:4, 1985. [11] O-A. Maillard, R. Munos, and G. Stoltz. A finite-time analysis of multi-armed bandits problems with kullback-leibler divergences. In Conference On Learning Theory COLT, 011. [1] B.C. May, N. Korda, A. Lee, and D. Leslie. Optimistic bayesian sampling in contextual bandit problems. Journal of Machine Learning Research, 13:069 106, 01. [13] A. Salomon and J-Y. Audibert. Deviations of stochastic bandit regret. In Algorithmic Learning Theory ALT, 011. [14] W.R. Thompson. On the likelihood that one unknown probability exceeds another in view of the evidence of two samples. Biometrika, 5:85 94, 1933. 16