Thompson Sampling for 1-Dimensional Exponential Family Bandits
Nathaniel Korda, Emilie Kaufmann, Remi Munos
Introduction
An algorithm, , for a -armed bandit problem is a (possibly randomised) method for choosing which distribution to sample from next, given a history of previous arm choices and obtained rewards, : each reward is drawn from the distribution . We denote by the distribution over induced by the history : at time the agent using picks arm with probability . The agent’s goal is to design an algorithm with low regret:
This quantity measures the expected performance of algorithm compared to the expected performance of an optimal algorithm given knowledge of the reward distributions, i.e. sampling always from the distribution with the highest expectation.
Since the early 2000s the “optimisim in the face of uncertainty” heuristic has been a popular approach to this problem, providing both simplicity of implementation and finite-time upper bound on the regret (e.g. ). However in the last two years there has been renewed interest in the Thompson Sampling heuristic (TS). While this heuristic was first put forward to solve bandit problems eighty years ago in , it was not until recently that theoretical analyses of its performance were achieved . In this paper we take a major step towards generalising these analyses to the same level of generality already achieved for “optimistic” algorithms.
Unlike optimistic algorithm which are often based on confidence intervals, the Thompson Sampling algorithm uses Bayesian tools and puts a prior distribution on each . A posterior distribution, , is then maintained according to the rewards observed in . At each time a sample is drawn from each posterior and then the algorithm chooses to sample . Therefore is the posterior probability that given the history .
Our Contributions
TS has proved to have impressive empirical performances, very close to those of state of the art algorithms such as DMED and KL-UCB . Furthermore recent works have shown that in the special case where each is a Bernoulli distribution , TS using a uniform prior over the arms is asymptotically optimal in the sense that it achieves the asymptotic lower bound on the regret provided by Lai and Robbins in (that holds for univariate parametric bandits). In this paper, we show this optimality property also holds for -dimensional exponential families if the algorithm uses the Jeffrey’s prior:
Suppose that the rewards distributions belong to a -dimensional canonical exponential family and that is the Jeffrey’s prior. Then,
where is the Kullback-Leibler divergence between and .
This theorem follows directly from Theorem 2. In the proof of this result we provide in Theorem 4 a finite-time, exponential concentration bound for posterior distributions of exponential family random variables, something that to the best of our knowledge is new to the literature and of interest in its own right. Our proof also exploits the explicit connection between the Jeffreys prior, Fisher information and the Kullback-Leibler divergence in exponential families.
Related Work
Another line of recent work has focused on distribution-independent bounds for Thompson Sampling. establishes that for Thompson Sampling for bounded rewards (with the classic uniform prior on the underlying Bernoulli parameter). go beyond the Bernoulli model, and give an upper bound on the Bayes risk (i.e. the regret averaged over the prior) independent of the prior distribution. For the parametric multi-armed bandit with arms described above, their result states that the regret of Thompson Sampling using a prior is not too big when averaged over this same prior:
Building on the same ideas, have improved this upper bound to . In our paper, we rather see the prior used by Thompson Sampling as a tool, and we want therefore to obtain garantees for any given problem parametrized by .
also use Thompson Sampling in more general models, like the linear bandit model. Their result is a bound on the Bayes risk that does not depend on the prior, whereas Agrawal and Goyal give in a first regret bound for this model. Linear bandits consider a possibly infinite number of arms whose mean rewards are linearly related by a single, unknown coefficient vector. Once again, the analysis in encounters the problem of describing the concentration of posterior distributions. However by using a conjugate normal prior, they can employ explicit the concentration bounds available for Normal distributions to complete their argument.
Paper Structure
In Section 2 we describe important features of the one-dimensional canonical exponential families we consider, including closed-form expression for KL-divergences and the Jeffrey’s prior. Section 3 gives statements of the main results, and provides the proof of the regret bound. Section 4 proves the posterior concentration result used in the proof of the regret bound.
Exponential Families and Jeffreys Priors
A distribution is said to belong to a one-dimensional canonical exponential family if it has a density with respect to some reference measure of the form:
showing in particular that is strictly convex. The mean function is differentiable and stricly increasing, since we can show that
In particular, this shows that is one-to-one in .
In an exponential family, a direct computation show that the Kullback-Leibler divergence can be expressed as a Bregman divergence of the normalisation function, F:
Jeffreys prior in Exponential Families
In the Bayesian literature, a special “non-informative” prior, one which is invariant under re-parametrisation of the parameter space, is sometimes considered. It is called the Jeffrey’s prior, and it can be shown to be proportional to the square-root of the Fisher information . In the special case of the canonical exponential family, the Fisher information takes the form , hence the Jeffrey’s prior for the model (2) is
Under the Jeffrey’s prior, the posterior on after observations is given by
When , the prior is called proper. However, stasticians often use priors which are not proper: the prior is called improper if and any observation makes the corresponding posterior (4) integrable.
Some Intuition for choosing the Jeffreys Prior
In the proof of our concentration result for posterior distributions (Theorem 4) it will be crucial to lower bound the prior probability of an -sized KL-divergence ball around each of the parameters . Since the Fisher information , choosing a prior proportional to ensures that the prior measure of such balls are .
Examples and Pseudocode
Algorithm 1 presents pseudocode for Thompson Sampling with the Jeffreys prior for distributions parametrized by their natural parameter . But as the Jeffreys prior is invariant under reparametrization, if a distribution is parametrised by some parameter , the algorithm can use the Jeffrey’s prior on , drawing samples from the posterior on . Note that the posterior sampling step (in bold) is always tractable using, for example, a Hastings-Metropolis algorithm.
Some examples of common exponential family models are given in Figure 1, together with the posterior distributions on the parameter that is used by TS with Jeffreys prior. In addition to examples already studied in for which , we also give two examples of more general canonical exponential families, namely the Pareto distribution with known min value and unknown tail index , , for which , and the Weibul distribution with known shape and unknown rate parameter, , for which . These last two distributions are not covered even by the work in , and belong to the family of heavy-tailed distributions.
For the Bernoulli model, one note futher that the use of the Jeffreys prior is not covered by the previous analyses. These analyses make an extensive use of the uniform prior, through the fact that the coefficient of the Beta posteriors they consider have to be integers.
Results and Proof of Regret Bound
An exponential family -armed bandit is a -armed bandit for which the reward distributions are known to be elements of an exponential family of distributions . We denote by the distribution of arm and its mean by .
Assume that for all , and that is taken to be the Jeffrey’s prior over . Then for every there exists a constant depending on and on the problem such that the regret of Thompson Sampling using the Jeffrey’s prior satisfies
We give here the main argument of the proof of the regret bound, which proceed by bounding the expected number of draws of any suboptimal arm. Along the way we shall state concentration results whose proofs are postponed to later sections.
Step 0: Notation
We denote by the -th observation of arm and by the number of times arm is chosen up to time . is i.i.d. with distribution . Let be the vector of first observations from arm . is therefore the vector of observations from arm available at the beginning of round . Recall that , respectively , is the posterior, respectively the prior, on at round of the algorithm.
For all and such that , we introduce
Step 1: Concentration Results
We state here the two concentration results that are necessary to evaluate the probability of the above events.
Let be an i.i.d sequence of distribution and . Then
The two following inequalities that will be useful in the sequel can easily be deduced from Lemma 3. Their proof is gathered in Appendix A with that of Lemma 3. For any arm ,
The second result tells us that concentration of the empirical sufficient statistic around its mean implies concentration of the posterior distribution around the true parameter:
Let be the Jeffreys’ prior. There exists constants , , and s.t., ,
whenever and are such that .
Step 2: Lower Bound the Number of Optimal Arm Plays with High Probability
The main difficulty adressed in previous regret analyses for Thompson Sampling is the control of the number of draws of the optimal arm. We provide this control in the form of Proposition 5 which is adapted from Proposition 1 in whose proof, an outline of which is given in Appendix D, explores in depth the randomised nature of Thompson Sampling. In particular, we show that the proof in can be significantly simplified, but at the expense of no longer being able to describe the constant explicitly:
For any there exists a constant such that
Step 3: Decomposition
The idea in this step is to decompose the probability of playing a suboptimal arm into principle and negligible components and control these components with the results from Steps 1 and 2:
The terms (B) and (C) are about concentration of the posterior on the suboptimal arm. An upper bound on term (C) is given in (6), whereas a bound on term (B) follows from Lemma 6 below. Although the proof of this lemma is standard, and bears a strong similarity to Lemma 3 of , we provide it in Appendix C for the sake of completeness.
For all actions and for all , such that
where is the smallest integer such that for all
and is the constant from Theorem 4.
When we have seen enough observations on the optimal arm, term (A) also becomes a result about the concentration of the posterior, but this time for the optimal arm:
For any , one can choose such that . Then, with such that the function
is decreasing for , is bounded by
So far, we have shown that for any and for any choice of and such that , there exists a constant such that
The constant is of course increasing (dramatically) when goes to zero, to , or to zero. But one can choose close enough to and small enough, such that
Posterior Concentration: Proof of Theorem 4
The argument rests on the following Lemma, whose proof can be found in Appendix B
Step 2: Upper bounding the numerator of (10)
We first note that on the leading term in the exponential is . Indeed, from (3) we know that
which, by strict convexity of , is strictly increasing in for any fixed . Now since is one-to-one and continuous, is an interval whose interior contains , and hence, on ,
So for such that we can bound the numerator of (10) by:
where we have used that is a probability distribution, and that, since is increasing, .
Step 3: Lower bounding the denominator of (10)
To lower bound the denominator, we reduce the integral on the whole space to a KL-ball, and use the structure of the prior to lower bound the measure of that KL-ball under the posterior obtained with the well-chosen observation . We introduce the following notation for KL balls: for any , we define
We have (since is strictly convex). Therefore, there exists such that for , on ,
Using this inequality we can then bound the denominator of (10) whenever and :
Finally we turn our attention to the quantity
Now since the KL divergence is convex in the second argument, we can write . So, from the convexity of we deduce that
As as , the set is compact. The map is continuous on the compact . Thus, it follows that
is an upper bound on the denominator of (13).
Now by the continuity of , and the continuity of in both coordinates, there exists an such that for all
Finally, for , we have a lower bound on the numerator of (13):
Puting everything together, we get
that there exist constants and such that for every satisfying , and for every , one has
Note that when the prior is proper we do not need to introduce the observation , which significantly simplifies the argument. Indeed in this case, in (11) we can use in place of which is already a probability distribution. In particular, the quantity (13) is replaced by , and so the constants and are not needed.
Conclusions
We have shown that choosing to use the Jeffrey’s prior in Thompson Sampling leads to an asymptotically optimal algorithm for bandit models whose rewards belong to a -dimensional canonical exponential family. The cornerstone of our proof is a finite time concentration bound for posterior distributions in exponential families, which, to the best of our knowledge, is new to the literature. With this result we built on previous analyses and avoided Bernoulli-specific arguments. Thompson Sampling with Jeffreys prior is now a provably competitive alternative to KL-UCB for exponential family bandits. Moreover our proof holds for slightly more general problems than those for which KL-UCB is provably optimal, including some heavy-tailed exponential family bandits.
Our arguments are potentially generalisable. Notably generalising to -dimensional exponential family bandits requires only generalising Lemma 3 and Step 3 in the proof of Theorem 4. Our result is asymptotic, but the only stage where the constants are not explicitly derivable from knowledge of , , and is in Lemma 9. Future work will investigate these open problems. Another possible future direction lies the optimal choice of prior distribution. Our theoretical guarantees only hold for Jeffreys prior, but a careful examination of our proof shows that the important property is to have, for every ,
which could hold for prior distributions other than the Jeffreys prior.
References
Appendix A Concentration of the Sufficient Statistics: Proof of Lemma 3, and Inequalities (6) and (7)
The proof of Lemma 3 follows from the classical Cramér-Chenoff technique (see ). For any .
where we have used the Markov inequality, and where
Now we optimize in by choosing that maximizes
is differentiable in and its minimum, , satisfies i.e.
(Note that since is increasing). Finally, we get
The same reasoning leads to the upper bound
where is such that . ∎
which gives inequality (6). To proof (7), we write:
Appendix B Extracting the KL-divergence: Proof of Lemma 7
where denotes the posterior distribution on after observation and
denotes the empirical KL-divergence obtained from the observations . Introducing
Indeed, for that for any
Appendix C Proof of Lemma 6
From Theorem 4 we know that, for ,
Let be the smallest integer such that for all
we have that for all and such that
Appendix D Controling the Number of Optimal Plays: Outline Proof of Proposition 5
The proof of this proposition is quite detailed, and essentially the same as the proof given for Proposition 1 in , which we will sometimes refer to. However, in generalising to the case of exponential family bandits we show how to avoid the need to explicity calculate posterior probabilities that lead to Lemma 4 in . While simplifying the proof we loose the ability to specify the constants explicitly, and so the analysis becomes asymptotic, but holds for every .
We introduce the interval : on the event , is included in and no draw of arm 1 occurs on . We also introduce for each arm .
The idea of the rest of the analysis is based on the following remark. If on a subinterval of size arm 1 is not drawn and all the samples of the suboptimal arms fall below , then for all , . On , the sequence is i.i.d. with distribution , and hence,
At this point, an asymptotic result, telling that the posterior on concentrates to a Dirac in (the Bernstein-Von-Mises theorem, see ) , leads to
There exists a constant , such that for every (random) interval included in and for every positive function , one has
For every , there exist constants and such that for ,
The rest of the proof proceeds by finding a subinterval of on which all the samples of all the suboptimal arms indeed fall below the corresponding thresholds . This is done exactly as in and we recall the main steps of the proof below. Before that, we need to introduce the notion of saturated, suboptimal action.
Let be fixed. For any , an action is said to be saturated at time if it has been chosen at least times, i.e. . 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 process of saturation on the event . We start by decomposing the interval into subintervals:
Now for each interval , we introduce:
: the event that by the end of the interval at least suboptimal actions are saturated;
: the number of interruptions during this interval.
We use the following decomposition to bound the probability of the event :
Note that the quantities and all depend on , however we suppress this dependency for notational convenience. However, we keep in mind that we bound the different probabilities for , so that Lemma 10 applies.
On the event , only saturated suboptimal arms are drawn on the interval . Using Lemma 10, we get
for as in Lemma 9. The second last inequality comes from the fact that if arm 1 is not drawn, the sample must be smaller than some sample and therefore smaller than .
A similar argument to that employed in Step 2 can be used in an induction to show that for all , if is larger than some deterministic constant specified in the base case,
We refer the reader to for a precise description of the induction. For we then get
Step 4: Conclusion
Putting Steps 2 and 3 together we obtain that for ,