Thompson Sampling: An Asymptotically Optimal Finite Time Analysis

Emilie Kaufmann, Nathaniel Korda, Rémi Munos

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 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, aa, is an unknown Bernoulli distribution B(μa)\mathcal{B}\left(\mu_{a}\right), whose expectation is μa\mu_{a}. At each time tt the agent chooses to observe an action At{1,,K}A_{t}\in\{1,\dots,K\} and receives a reward RtR_{t} drawn from the distribution B(μAt)\mathcal{B}\left(\mu_{A_{t}}\right). A policy, or bandit algorithm, is defined to be a (possibly randomised) method for choosing AtA_{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:

where μ=maxaμa\mu^{*}=\max_{a}\mu_{a} denotes the expectation of the best armThe words arms and actions are used interchangably., or optimal action, and Na,tN_{a,t} the number of draws of arm aa at the end of round tt. Lai and Robbins proved in that all strongly consistent policies (i.e. policies satisfying R(t)=o(tα)\mathcal{R}(t)=o(t^{\alpha}) for all α(0,1)\alpha\in(0,1)) must satisfy, for any suboptimal arm aa

where K(p,q)K(p,q) denotes the Kullback-Leibler divergence between B(p)\mathcal{B}\left(p\right) and B(q)\mathcal{B}\left(q\right):

Their result, which holds for more general classes of reward distributions, leads to the definition of asymptotically optimal policies as policies that satisfy (2) with equality.

In the same paper 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. was the first of a series of efficient policies, like UCB-V 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 K1>2K_{1}>2 and K>0K>0 such that for every suboptimal action aa, with Δa=μμa\Delta_{a}=\mu^{*}-\mu_{a},

This does not imply (2) with equality since by the Pinsker inequality 2K(μa,μ)>Δa22K(\mu_{a},\mu^{*})>\Delta_{a}^{2}. On the contrary, recently proposed index policies such as DMED and KL-UCB , 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\mu_{a}, let πa,t\pi_{a,t} denote the posterior distribution for μa\mu_{a} after the ttht^{th} round of the algorithm. Let θa,t\theta_{a,t} denote a sample from πa,t\pi_{a,t}; we sometimes refer to θa,t\theta_{a,t} as a Thompson sample. Thompson sampling is the policy which at time tt chooses to observe the action with the highest Thompson sample θa,t\theta_{a,t}, i.e. it chooses action aa with the probability that this action has the highest expected reward under the posterior distribution.

Before Agrawal and Goyal’s recent paper Thompson Sampling had been investigated in as the Bayesian Learning Automaton, and in where an optimistic version was also proposed; however these papers only provided weak theoretical guarantees. In 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 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 for a review of them). The Bayes-UCB algorithm, an upper confidence bound policy which uses an adaptive quantile of πa,t\pi_{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.

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 2. More precisely we show the following:

For every ϵ>0\epsilon>0 there exists a problem-dependent constant C(ϵ,μ1,,μK)C(\epsilon,\mu_{1},\dots,\mu_{K}) such that the regret of Thompson Sampling satisfies:

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 2 contains notations or results already used in , or 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 11 is the unique optimal action. Without loss of generalityIn Appendix A of the authors show that adding a second optimal arm can only improve the regret performance of Thompson Sampling., we can assume that the parameter μ=(μ1,...,μK)\mu=(\mu_{1},...,\mu_{K}) of the problem is such that μ1>μ2...μK\mu_{1}>\mu_{2}\geq...\geq\mu_{K}.

We shall denote by Sa,tS_{a,t} the number of successes observed from action aa by time tt, and denote the empirical mean by:

In the Bernoulli case, with a uniform prior on the parameters μa\mu_{a} of the arms, the posterior on arm aa at time tt is explicitly

Let Fa,bBetaF_{a,b}^{\text{Beta}} denote the cdf of a Beta distribution with parameters aa and bb and Fj,μBF_{j,\mu}^{\text{B}} (resp fj,μBf_{j,\mu}^{\text{B}}) the cdf (resp pdf) of a Binomial distribution with parameters jj and μ\mu. We recall an important link between Beta and Binomial distribution which was used in both and :

We use this ‘Beta-Binomial trick’ at several stages of our analysis.

We denote by ua,tu_{a,t} (resp. qa,tq_{a,t}) the KL-UCB (resp. Bayes-UCB) index at time tt, and define them by

where Q(α,π)Q(\alpha,\pi) denotes the quantile of order α\alpha of the distribution π\pi

A special link between these two indices is shown in : qa,t<ua,tq_{a,t}<u_{a,t}.

Finite Time Analysis

the optimal arm (arm 1) is under-estimated, i.e. l1,t<μ1l_{1,t}<\mu_{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

The analysis of an optimistic algorithm then proceeds by showing that the left term (the“under-estimation” term) is o(ln(T))o\left(\ln(T)\right) and the right term is of the form 1K(μa,μ1)ln(T)+o(ln(T))\frac{1}{K(\mu_{a},\mu_{1})}\ln(T)+o\left(\ln(T)\right) (or at worst 2Δa2ln(T)+o(ln(T))\frac{2}{\Delta_{a}^{2}}\ln(T)+o\left(\ln(T)\right) as in the analysis of UCB1). This style of argument works for example for the KL-UCB algorithm and also for the Bayesian optimistic algorithm Bayes-UCB .

As is observed in 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.

There exists constants b=b(μ1,μ2)(0,1)b=b(\mu_{1},\mu_{2})\in(0,1) and Cb=Cb(μ1,μ2)<C_{b}=C_{b}(\mu_{1},\mu_{2})<\infty such that

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.

Using this result, the new decomposition finally yields the following theorem:

Let ϵ>0\epsilon>0. With bb as in Proposition 1, for every suboptimal arm aa, there exist constants D(ϵ,μ1,μa)D(\epsilon,\mu_{1},\mu_{a}), N(b,ϵ,μ1,μa)N(b,\epsilon,\mu_{1},\mu_{a}) and N0(b)N_{0}(b) such that:

The constants will be made more explicit in the proofs of Proposition 1 and Theorem 2. The fact that Theorem 2 holds for every ϵ>0\epsilon>0 gives us the asymptotic optimality of Thompson Sampling.

2 Proof of Theorem 2

First we recall the modified decomposition mentioned above:

The sample θa,t\theta_{a,t} is not very likely to exceed the quantile of the posterior distribution qa,tq_{a,t} we introduced:

where this last inequality follows for TeT\geq e. So finally, using that ua,tqa,tu_{a,t}\geq q_{a,t},

Step 2: Bounding term A

Dealing with term AA boils down to showing a new self-normalized inequality adapted to the randomisation present in each round of the Thompson algorithm.

There exists some deterministic constant N0(b)N_{0}(b) such that

with CbC_{b} defined as in Proposition 1.

Proof. Let (Ut)(U_{t}) denote a sequence of i.i.d. uniform random variables, and let Σ1,s\Sigma_{1,s} be the sum of the first ss rewards from arm 1. In the following, we make the first use of the link between Beta and Binomial distributions:

The first term in the final line of this display now deals only with Binomial random variables with large numbers of trials (greater than tbt^{b}), and so we can draw on standard concentration techniques to bound this term. Proposition 1 takes care of the second term.

Note that (FB)s+1,μ16ln(t)/s1(Ut)Bin(s+1,μ16ln(t)/s)(F^{\text{B}})^{-1}_{s+1,\mu_{1}-\sqrt{6\ln(t)/s}}\left(U_{t}\right)\sim\text{Bin}\left(s+1,\mu_{1}-\sqrt{6\ln(t)/s}\right) and is independent from Σ1,sBin(s,μ1)\Sigma_{1,s}\sim\text{Bin}\left(s,\mu_{1}\right). For each ss, we define two i.i.d. sequences of Bernoulli random variables:

and we let Zl:=X2,lX1,lZ_{l}:=X_{2,l}-X_{1,l}, another i.i.d. sequence, with mean 6ln(t)s\sqrt{\frac{6\ln(t)}{s}}. Using these notations,

Let N0(b)N_{0}(b) be such that if tN0(b)t\geq N_{0}(b), 6tbln(t)1>5tbln(t)\sqrt{6t^{b}\ln(t)}-1>\sqrt{5t^{b}\ln(t)}. For tN0(b)t\geq N_{0}(b), we can apply Hoeffding’s inequality to the bounded martingale difference sequence Zl=Zl6ln(t)/sZ^{\prime}_{l}=Z_{l}-\sqrt{6\ln(t)/s} to get

Step 3: Bounding Term B

For all a=2,,Ka=2,\dots,K, for any ϵ>0\epsilon>0 there exist N(b,ϵ,μ1,μa),D(ϵ,μ1,μa)>0N(b,\epsilon,\mu_{1},\mu_{a}),D(\epsilon,\mu_{1},\mu_{a})>0 such that for all T>N(b,ϵ,μ1,μa)T>N(b,\epsilon,\mu_{1},\mu_{a})

Proof. First rewrite term BB so that we can apply Proposition 1:

and so summing over the values of N2,tN_{2,t} and inverting the sums we get

As yK+(μ^a,s,y)y\mapsto K^{+}\left(\hat{\mu}_{a,s},y\right) is increasing and tβtt\mapsto\beta_{t} is decreasing for te1/bt\geq e^{1/b}, for TT such that

we have that if tKT,a(ϵ)t\geq K_{T,a}(\epsilon),

Given that t=sT1(At=a,N2,t=s)1\sum_{t=s}^{T}\mathbf{1}_{(A_{t}=a,N_{2,t}=s)}\leq 1 for all ss, the first term is upper bounded by Ka,TK_{a,T}, whereas the second is upper bounded by

Using the convexity of K+(μ^a,s,.)K^{+}\left(\hat{\mu}_{a,s},.\right), we can show that

If K+(μ^a,s,μ1βKT,a)K(μa,μ1)/(1+ϵ)K^{+}\left(\hat{\mu}_{a,s},\mu_{1}-\beta_{K_{T,a}}\right)\leq K(\mu_{a},\mu_{1})/(1+\epsilon), then

where the last inequality (6) holds for large enough TT. There exists a deterministic constant N=N(b,ϵ,μ1,μa)N=N(b,\epsilon,\mu_{1},\mu_{a}) such that for all TNT\geq N both (5) and (6) are satisfied. Hence, for all TNT\geq N

Since this last sum is bounded above explicitly by some constant D(ϵ,μ1,μa)D(\epsilon,\mu_{1},\mu_{a}) in we have proved the lemma. To be explicit, D(ϵ,μ1,μa)=(1+ϵ/2)2ϵ2(min(μa(1μa);μ1(1μ1)))2.D(\epsilon,\mu_{1},\mu_{a})=\frac{(1+\epsilon/2)^{2}}{\epsilon^{2}\left(\min\left(\mu_{a}(1-\mu_{a});\mu_{1}(1-\mu_{1})\right)\right)^{2}}.

Conclusion:

The result now follows from Lemmas 1, 2 and inequality (4).

3 Proof of Proposition 1

Since we focus on the number of draws of the optimal arm, let τj\tau_{j} be the occurrence of the jthj^{th} play of the optimal arm (with τ0:=0\tau_{0}:=0). Let ξj:=(τj+11)τj\xi_{j}:=(\tau_{j+1}-1)-\tau_{j}: this random variable measures the number of time steps between the jthj^{th} and the (j+1)th(j+1)^{th} play of the optimal arm, and so a=2KNa,t=j=0N1,tξj\sum_{a=2}^{K}N_{a,t}=\sum_{j=0}^{N_{1,t}}\xi_{j}. For each suboptimal arm, a relevant quantity is Ca=32(μ1μa)2C_{a}=\frac{32}{(\mu_{1}-\mu_{a})^{2}} and let C=maxa1Ca=32(μ1μ2)2C=\max_{a\neq 1}C_{a}=\frac{32}{(\mu_{1}-\mu_{2})^{2}}. We also introduce δa=μ1μa2\delta_{a}=\frac{\mu_{1}-\mu_{a}}{2} and let δ=δ2\delta=\delta_{2}.

First we use a union bound on the summands to extract the tails of the random variables ξj\xi_{j}:

This means that there exists a time range of length t1b1t^{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 t1b12\lceil\frac{t^{1-b}-1}{2}\rceil 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 t1b12\lceil\frac{t^{1-b}-1}{2}\rceil times in a row is very small.

In order to generalise this approach we introduce a notion of a saturated, suboptimal action:

Let tt be fixed. For any a1a\neq 1, an action aa is said to be saturated at time ss if it has been chosen at least Caln(t)C_{a}\ln(t) times. That is Na,sCaln(t)N_{a,s}\geq C_{a}\ln(t). 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 Ej={ξjt1b1}E_{j}=\{\xi_{j}\geq t^{1-b}-1\}. We introduce the interval Ij={τj,τj+t1b1}\mathcal{I}_{j}=\{\tau_{j},\tau_{j}+\lceil t^{1-b}-1\rceil\} (included in {τj,τj+1}\{\tau_{j},\tau_{j+1}\} on EjE_{j}) and begin by decomposing it into KK subintervals:

Now for each interval Ij,l\mathcal{I}_{j,l}, we introduce:

Fj,lF_{j,l}: the event that by the end of the interval Ij,l\mathcal{I}_{j,l} at least ll suboptimal actions are saturated;

nj,ln_{j,l}: the number of interruptions during this interval.

We use the following decomposition to bound the probability of the event EjE_{j} :

To bound both probabilities, we will need the fact, stated in Lemma 3, that the probability of θ1,s\theta_{1,s} being smaller than μ2+δ\mu_{2}+\delta during a long subinterval of Ij\mathcal{I}_{j} is small. This follows from the fact that the posterior on the optimal arm is always Beta(S1,τj+1,jS1,τj+1)\text{Beta}(S_{1,\tau_{j}}+1,j-S_{1,\tau_{j}}+1) on Ij\mathcal{I}_{j}: hence, when conditioned on S1,τjS_{1,\tau_{j}}, θ1,s\theta_{1,s} is an i.i.d. sequence with non-zero support above μ2+δ\mu_{2}+\delta, and thus is unlikely to remain below μ2+δ\mu_{2}+\delta for a long time period. This idea is also an important tool in the analysis of Thompson Sampling in .

λ0=λ0(μ1,μ2)>1\exists\lambda_{0}=\lambda_{0}(\mu_{1},\mu_{2})>1 such that for λ]1,λ0[\lambda\in]1,\lambda_{0}[, for every (random) interval J\mathcal{J} included in Ij\mathcal{I}_{j} and for every positive function ff, one has

where Cλ,μ1,μ2,dλ,μ1,μ2>0C_{\lambda,\mu_{1},\mu_{2}},d_{\lambda,\mu_{1},\mu_{2}}>0, and αμ1,μ2=(1/2)1μ2δ\alpha_{\mu_{1},\mu_{2}}=(1/2)^{1-\mu_{2}-\delta}.

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 2 in .

On the event EjFj,K1E_{j}\cap F_{j,K-1}, only saturated suboptimal arms are drawn on the interval Ij,K\mathcal{I}_{j,K}. Using the concentration results for samples of these arms in Lemma 4, we get

The last inequality comes from the fact that if arm 1 is not drawn, the sample θ1,s\theta_{1,s} must be smaller than some sample θa,s\theta_{a,s} and therefore smaller than μ2+δ\mu_{2}+\delta. Since Ij,K\mathcal{I}_{j,K} is an interval in Ij\mathcal{I}_{j} of size t1b1K\left\lceil\frac{t^{1-b}-1}{K}\right\rceil we get using Lemma 3, for some fixed λ]1,λ0[\lambda\in]1,\lambda_{0}[,

and choosing bb such that b<11λb<1-\frac{1}{\lambda}, the following hypothesis on gg holds:

We show through an induction that for all 2lK2\leq l\leq K, if tt is larger than some deterministic constant Nμ1,μ2,bN_{\mu_{1},\mu_{2},b} specified in the base case,

for some function ff such that t11jtbf(μ1,μ2,b,j,t)<\sum_{t\geq 1}\sum_{1\leq j\leq t^{b}}f(\mu_{1},\mu_{2},b,j,t)<\infty. For l=Kl=K we get

Step 4: The Base Case of the induction

Note that on the event EjE_{j} only suboptimal arms are played during Ij,1\mathcal{I}_{j,1}. Hence at least one suboptimal arm must be played t1b1K2\lceil\frac{t^{1-b}-1}{K^{2}}\rceil times.

There exists some deterministic constant Nμ1,μ2,bN_{\mu_{1},\mu_{2},b} such that for tNμ1,μ2,bt\geq N_{\mu_{1},\mu_{2},b}, t1b1K2Cln(t)\lceil\frac{t^{1-b}-1}{K^{2}}\rceil\geq C\ln(t) (the constant depends only on μ1\mu_{1} and μ2\mu_{2} because C=C2C=C_{2}). So when tNμ1,μ2,bt\geq N_{\mu_{1},\mu_{2},b}, at least one suboptimal arm must be saturated by the end of Ij,1\mathcal{I}_{j,1}. Hence, for tNμ1,μ2,bt\geq N_{\mu_{1},\mu_{2},b}

Step 5: The Induction

As an inductive hypothesis we assume that for some 2lK12\leq l\leq K-1 if tNμ1,μ2,bt\geq N_{\mu_{1},\mu_{2},b} then

Then, making use of the inductive hypothesis,

To complete the induction we therefore need to show that:

On the event (EjFj,lcFj,l1)(E_{j}\cap F_{j,l}^{c}\cap F_{j,l-1}), there are exactly l1l-1 saturated arms at the beginning of interval Ij,l\mathcal{I}_{j,l} and no new arm is saturated during this interval. As a result there cannot be more than KCln(t)KC\ln(t) interruptions during this interval, and so we have

Let Sl\mathcal{S}_{l} denote the set of saturated arms at the end of Ij,l\mathcal{I}_{j,l} and introduce the following decomposition:

To deal with term (B), we introduce for kk in {0,,nj,l1}\{0,\dots,n_{j,l}-1\} the random intervals Jk\mathcal{J}_{k} as the time range between the kthk^{th} and (k+1)st(k+1)^{st} interruption in Ij,l\mathcal{I}_{j,l}. For knj,lk\geq n_{j,l} we set Jk=\mathcal{J}_{k}=\varnothing. Note that on the event in the probability (B) there is a subinterval of Ij,l\mathcal{I}_{j,l} of length t1b1CK2ln(t)\left\lceil\frac{t^{1-b}-1}{CK^{2}\ln(t)}\right\rceil during which there are no interruptions. Moreover on this subinterval of Ij,l\mathcal{I}_{j,l}, for all a1a\neq 1, θa,sμ2+δ2\theta_{a,s}\leq\mu_{2}+\delta_{2}. (This holds for unsaturated arms as well as for saturated arms since their samples are smaller than the maximum sample of a saturated arm.) Therefore,

Now, we have to bound the probability that θ1,sμ2+δ\theta_{1,s}\leq\mu_{2}+\delta for all ss in an interval of size t1b1CK2ln(t)\frac{t^{1-b}-1}{CK^{2}\ln(t)} included in Ij\mathcal{I}_{j}. So we apply Lemma 3 to get:

Choosing the same bb as in (9), we get that t11jtbf(μ1,μ2,b,j,t)<+\sum_{t\geq 1}\sum_{1\leq j\leq t^{b}}f(\mu_{1},\mu_{2},b,j,t)<+\infty. It follows that for this value of bb, (12) holds and the induction is complete.

Step 8: Conclusion

Let bb be the constant chosen in Step 2. From the decomposition (8) and the two upper bounds (10) and (11), we get, for tNμ1,μ2,bt\geq N_{\mu_{1},\mu_{2},b}:

Recalling (7), summing over the possible values of jj and tt we obtain:

for some constant Cμ1,μ2,b<C_{\mu_{1},\mu_{2},b}<\infty.

4 Proof of Lemma 3

On the interval the J\mathcal{J} (included in Ij\mathcal{I}_{j} by hypothesis), the posterior distribution π1,s=π1,τj\pi_{1,s}=\pi_{1,\tau_{j}} is fixed and θ1,s\theta_{1,s} is, when conditioned on S1,τjS_{1,\tau_{j}}, an i.i.d. sequence with common distribution Beta(S1,τj+1,jS1,τj+1)\text{Beta}(S_{1,\tau_{j}}+1,j-S_{1,\tau_{j}}+1). Hence,

where we use the link between the tail of Beta and Bernoulli distribution mentioned above. Using the independence of the θ1,s\theta_{1,s} gives

An exact computation of this expectation leads to

To simplify notation, from now on let y=μ2+δy=\mu_{2}+\delta. Using, as in , that Fj+1,yB(s)=(1y)Fj,yB(s)+yFj,yB(s1)(1y)Fj,yB(s)F_{j+1,y}^{B}(s)=(1-y)F_{j,y}^{B}(s)+yF_{j,y}^{B}(s-1)\geq(1-y)F_{j,y}^{B}(s), we get:

Using the fact that for syj,Fj,yB(s)12s\geq\lceil yj\rceil,F^{B}_{j,y}(s)\geq\frac{1}{2} (since the median of a binomial distribution with parameters jj and yy is yj\lceil yj\rceil or yj\lfloor yj\rfloor), we get

It is easy to show that for every λ>1\lambda>1,x>0,xλexp(x)(λe)λ\forall x>0,x^{\lambda}\exp(-x)\leq\left(\frac{\lambda}{e}\right)^{\lambda} This allows us to upper-bound the exponential for all λ>1\lambda>1, using Cλ=(λe)λC_{\lambda}=\left(\frac{\lambda}{e}\right)^{\lambda},by:

Now, inspired by Agrawal and Goyal’s work (proof of Lemma 3) we compute:

Let Rλ(μ1,y)=μ1(1y)λyλ(1μ1)R_{\lambda}(\mu_{1},y)=\frac{\mu_{1}(1-y)^{\lambda}}{y^{\lambda}(1-\mu_{1})}. There exists some λ1>1\lambda_{1}>1 such that, if λ<λ1\lambda<\lambda_{1}, Rλ>1R_{\lambda}>1. More precisely,

where dλ(y,μ1)=yln(yλμ1)+(1y)ln((1y)λ1μ1)d_{\lambda}(y,\mu_{1})=y\ln\left(\frac{y^{\lambda}}{\mu_{1}}\right)+(1-y)\ln\left(\frac{(1-y)^{\lambda}}{1-\mu_{1}}\right). Rearranging we can write

which is an affine function of λ\lambda with negative slope (yln(y)+(1y)ln(1y)<0y\ln(y)+(1-y)\ln(1-y)<0 for all y(0,1)y\in(0,1)) and d1(y,μ1)=K(y,μ1)>0d_{1}(y,\mu_{1})=K\left(y,\mu_{1}\right)>0. Hence, for fixed 0<y<μ110<y<\mu_{1}\leq 1 this function is positive whenever

Clearly, λ2(μ1,y)>1\lambda_{2}(\mu_{1},y)>1 and we choose λ0=min(λ1,λ2)\lambda_{0}=\min(\lambda_{1},\lambda_{2}). After some calculation one can show that λ2λ1\lambda_{2}\leq\lambda_{1}, and therefore that

To obtain the constants used in the statement of the lemma we define dλ,μ1,μ2:=dλ(y,μ1)d_{\lambda,\mu_{1},\mu_{2}}:=d_{\lambda}(y,\mu_{1})

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=10000T=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 2 displays for several algorithms an estimation of the distribution of the cumulative regret based on N=50000N=50000 trials, for a horizon T=20000T=20000 in a 10-armed bandit problem with

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 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 kk rewards in nn draws,

The other algorithms displayed in Figure 2 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.

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 N1,tN_{1,t} rather than its expectation. This is a valuable result which justifies the complexity of the proof of Proposition 2. 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 , 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.

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 Community’s Seventh Framework Programme (FP7/2007-2013) under grant agreements n◦ 216886 (PASCAL2), and n◦ 270327 (CompLACS).

References