An Analysis of Ensemble Sampling
Abstract
Ensemble sampling serves as a practical approximation to Thompson sampling when maintaining an exact posterior distribution over model parameters is computationally intractable.
In this paper, we establish a regret bound that ensures desirable behavior when ensemble sampling is applied to the linear bandit problem.
This represents the ﬁrst rigorous regret analysis of ensemble sampling and is made possible by leveraging information-theoretic concepts and novel analytic techniques that may prove useful beyond the scope of this paper
Introduction
Thompson sampling (TS) is a popular heuristic for balancing between exploration and exploitation in bandit learning.
In its basic form, TS maintains a posterior distribution over model parameters.
When the prior distribution and likelihood function exhibit conjugacy properties, the posterior distribution can be maintained through computationally tractable Bayesian inference.
However, many practical contexts call for more complex models for which exact Bayesian inference becomes computationally intractable.
For such contexts, ensemble sampling (ES) can serve as a practical approximation to TS [Lu and Van Roy, 2017].
Instead of the posterior distribution, ES maintains an ensemble of statistically plausible models that can be updated in an efﬁcient incremental manner.
The corresponding discrete distribution represents an approximation to the posterior distribution.
At the start of each timestep, a model is sampled uniformly from the ensemble and an action is selected to optimize expected reward with respect to the sampled model.
Each model is initially sampled from the prior distribution and evolves through an updating process that adapts to observations and random perturbations.
While a growing literature [Osband et al., 2016, Russo et al., 2018, Osband et al., 2018, Lu et al., 2018, Osband et al., 2019, Dwaracherla et al., 2020, Osband et al., 2022b] presents applications of
ES, there has been no rigorous theory that ensures desirable behavior similar to that enjoyed by TS.
A regret bound for ES applied to linear-Gaussian bandits is provided by Lu and Van Roy [2017], but a ﬂaw in the associated analysis has brought this result into question.
Since the publication of that paper, several researchers have tried to remedy the analysis or otherwise establish performance guarantees for ES, but these efforts have gone without success.
We offer in this paper the ﬁrst rigorous regret analysis of ES.
Like Lu and Van Roy [2017], we study ES applied to linear-Gaussian bandits.
This serves as a simple sanity check for the approach.
We establish a Bayesian regret bound (Theorem 1) that consists of two terms.
The ﬁrst term is identical to a Bayesian regret bound established for TS.
The second term accounts for posterior mismatch and can be made arbitrarily small by increasing the ensemble size.
Our analysis leverages information-theoretic concepts and novel analytic techniques that may prove useful beyond the scope of this paper.
As a stepping stone in our analysis, we establish a general Bayesian regret bound that applies to any learning algorithm for linear bandits (Theorem 2).
In particular, this regret bound is based on the Hellinger distance between the action selection distribution of the learning algorithm and the 36th Conference on Neural Information Processing Systems (NeurIPS 2022). posterior distribution of the optimal action at each timestep.
We believe that this Bayesian regret bound is of independent interest and might be useful in analyzing other learning algorithms, such as other approximate TS algorithms.
Note that for linear-Gaussian bandits considered in this paper, Kalman ﬁltering offers a tractable means to exact inference and, as such, an approximation method like ES is not required.
However, it is worth mentioning that the analysis in this paper also offers insight into more complex models that call for approximate inference.
For example, consider a neural network with very wide hidden layers.
A recent research thrust (e.g., Jacot et al.
[2018], Lee et al.
[2017]) highlights that, under suitable technical conditions, training such a neural network via stochastic gradient descent (SGD) approximates Gaussian process inference.
Our result extends directly to ﬁnite-armed Gaussian process bandits.
This suggests that ES applied with neural networks that are trained via SGD can be effective in complex bandit problems, though formalizing this extension requires signiﬁcant technical work, which we leave for future research.
The remainder of this paper is organized as follows: Section 2 reviews related work, and Sectionformulates the considered linear bandit problem and describes the ensemble sampling algorithm.
Section 4 presents the main result of this paper: a Bayesian regret bound for ES applied to linear bandits.
Before diving into the analysis, we deﬁne some notation used in this paper in Section 5.
Then we motivate and derive a general regret bound in Section 6, and apply it to analyzing ES in Section 7.
Finally, we conclude the paper and discuss future directions in Section 8.
Related work
Thompson sampling [Thompson, 1933, Chapelle and Li, 2011, Russo et al., 2018] is a commonly used heuristic for balancing exploration and exploitation in bandits [Lattimore and Szepesvári, 2020] and reinforcement learning [Sutton and Barto, 2018].
However, the basic form of Thompson sampling can be computationally intractable unless the prior distribution and likelihood function exhibit conjugacy properties.
To overcome this computational challenge, variants of approximate versions of TS have been developed (see Chapter 5 of Russo et al.
[2018]), including approximate TS using Laplace approximation [Chapelle and Li, 2011], bootstrapping [Eckles and Kaptein, 2019, Kveton et al., 2019], variational inference [Urteaga and Wiggins, 2018, Yu et al., 2020], Markov chain Monte Carlo [Casella and George, 1992, Roberts and Tweedie, 1996], hypermodels [Dwaracherla et al., 2020], and optimal transport [Zhang et al., 2019].
Ensemble sampling is also an approximate version of Thompson sampling, and was formally proposed by Lu and Van Roy [2017].
It has been one of the most popular methods in approximate Bayesian inference and has wide applications in sequential decision making.
For example, variations of ES have been applied to (deep) reinforcement learning [Osband et al., 2016, 2018, 2019], online recommendation [Lu et al., 2018, Hao et al., 2020, Zhu and Van Roy, 2021], multi-agent reinforcement learning [Dimakopoulou and Van Roy, 2018], behavioral sciences [Eckles and Kaptein, 2019], and marketing strategies [Yang et al., 2020].
Recently, Osband et al.
[2022b] has developed a testbed to compare and rank agents for uncertainty modeling, including variants of the ensemble agents.
A lot of work has attempted to analyze ensemble sampling, but none of them has been successful.
In their original paper, Lu and Van Roy [2017] try to analyze ES in linear-Gaussian bandits, but there is a mistake in the ﬁnal step of the analysis where they compare the regret of ES to that of TS.
In particular, in the proof of Lemma 8, the hypothetical actions selected by TS are deﬁned on the histories of ES, instead of TS.
Therefore, the cumulative regret incurred by these hypothetical TS actions is not equal to the cumulative regret of applying TS throughout all timesteps, while the paper incorrectly claims that they are equal.
In addition to Lu and Van Roy [2017], Phan et al.
[2019] aims to analyze general approximate TS with approximation errors measured in ↵ -divergence for K -armed bandit.
To demonstrate the main result, Phan et al.
[2019] uses ES as an example, but also inherits the technical ﬂaw in Lu and Van Roy [2017].
In addition, though Phan et al.
[2019] shows that the approximate version of TS with uniform sampling achieves sublinear regret, this result mainly beneﬁts from this forced exploration.
There are also papers aiming to analyze bandit algorithms with approximate inference.
A recent paper [Huang et al., 2022] studies an upper-conﬁdence-bound (UCB) type algorithm for bandit problems with approximate inference.
Another recent paper [Ash et al., 2021] proposes and analyzes an ensemble based UCB algorithm for bandit problems.
Kveton et al.
[2020] studies linear bandits in the frequentist setting and provides a general regret bound that is tailored to analyzing randomized algorithms with good concentration and anti-concentration properties, but it could not be directly applied to analyzing ES due to ES’s discrete and incremental update nature.
Preliminaries
We begin by introducing a formulation of the linear bandit and an ensemble sampling algorithm suited for this environment.
3.1 Linear bandit
The linear bandit [Abbasi-Yadkori et al., 2011, Lattimore and Szepesvári, 2020] has received much attention in the bandit learning literature.
It serves as a simple didactic environment, often used to sanity-check agent designs.
In this spirit, we will analyze ES as applied to the linear bandit.
We consider linear bandits with a Gaussian prior distribution and Gaussian noises.
An instance is characterized by a tuple E =
( A , µ 0 , ⌃ 0 ,  2 ) , where A ⇢ R d is a ﬁnite action set, µ 0 and ⌃ 0 are the prior mean vector and covariance matrix, and  2 is the noise variance.
Note that actions are vectors of dimension d .
Let K = |A| denote the cardinality of the action set.
The prior distribution over the coefﬁcient vector ✓ 2 R d , P ( ✓ 2 · ) , is multivariate Gaussian N ( µ 0 , ⌃ 0 ) .
Rewards are generated by a random sequence ( R t : t = 1 , 2 , . . . )
of K -dimensional vectors, which is i.i.d.
conditioned on ✓ .
In particular, for each t and a ,
[Equation] where W t =
( W t,a ) a 2 A is a K -dimensional vector with each element distributed N (0 ,  2 ) .
An agent interacts with the linear bandit as follows: at each timestep t = 0 , 1 , . .
, the agent executes an action A t ; then it observes a reward R t +1 ,A t .
Note that only the reward associated with the executed action is observed through what is termed bandit feedback .
The agent’s experience through time t is encoded by a history H t =
( A 0 , R 1 ,A 0 , . . .
, A t  1 , R t,A t  1 ) .
The agent’s objective is to maximize expected reward over some duration T :
[Equation]
This is equivalent to minimizing the Bayesian regret:
[Equation]
where A ⇤ ⇠ unif  arg max a 2 A a > ✓ .
Note that in both Equations (1) and (2), the expectations integrate over random reward realizations, algorithmic randomness, and the coefﬁcient vector ✓ .
Note that A ⇤ is also a random variable since it depends on ✓ and the uniform sampling among maximizers, which breaks ties.
3.2 Ensemble sampling
In the absence of conjugacy properties that enable efﬁcient Bayesian inference, TS in its exact form becomes computationally infeasible.
ES serves as a practical approximation to TS [Lu and Van Roy, 2017], often suitable for such contexts.
The key idea behind ES is to maintain an ensemble of statistically plausible models that can be updated in an efﬁcient incremental manner and to treat the discrete distribution represented by this ensemble of models as an approximation to the posterior distribution.
The algorithm begins by sampling M models from the prior distribution, where M is a hyperparameter.
At the start of each timestep, a model is sampled uniformly from the ensemble and an action is selected to optimize the immediate expected reward with respect to the sampled model.
Then, each model is updated incrementally based on the observed reward and a random perturbation.
Algorithm 1 presents the associated pseudo-code for ES.
1: Input : P ( ✓ 2 · ) and M 2: Sample : ˜ ✓ 0 , 1 , . . .
, ˜ ✓ 0 ,M ⇠ P ( ✓ 2 · ) 3: for t = 0 , . . .
, T  1 do 4:
Sample : m ⇠ unif { 1 , . . .
, M } 5:
Execute : A t ⇠ unif ⇢ arg max a 2 A a > ˜ ✓ t,m  6:
Observe : R t +1 ,A t 7:
Update : ˜ ✓ t, 1: M ! ˜ ✓ t +1 , 1: M 8: end for
The posterior distribution at time t + 1 is Gaussian with covariance matrix and mean vector ⌃ [Equation] =
[Equation]
and µ
[Equation]
While this highlights conjugacy properties of a sort that allow for efﬁcient Bayesian inference and thus tractable implementation of exact TS, the linear bandit with Gaussian prior distribution and likelihood function serves as a useful context for studying the behavior of ES in relation to TS.
Like [Lu and Van Roy, 2017], we consider a version of ES that updates each m -th model according to
[Equation]
where ˜ W t +1 = ( ˜ W t +1 ,m ) m 2 [ M ] ⇠ N (0 ,  2 I ) is an a M -dimensional vector with each element distributed N (0 ,  2 ) .
Regret bound for ensemble sampling
In this section, we establish the following Bayesian regret bound for ES (Algorithm 1) when it is applied to linear bandits described in Section 3.1:
Theorem 1.
Under ES Algorithm (Algorithm 1),
[Equation]
where H ( A ⇤ ) is the Shannon entropy of the optimal action A ⇤ under the prior, and
[Equation]
Note that ◆ = O (1) and Lemma 7 in Appendix A shows ⌘ = O ( p
[Equation]
{ d, log K } [Equation] , so
[Equation]
Theorem 1 represents the ﬁrst rigorously proved regret bound that ensures some degree of robustness in application of ES to a nontrivial bandit problem.
One limitation is that the second term ( b ) in our
Bayesian regret bound depends on K since our current analysis uses the method of (ﬁnite) types
[Cover and Thomas, 2006].
This might not be tight for linear bandit, and we conjecture that the second term ( b ) can be improved to be independent of K .
Another limitation is that the result applies only to the linear bandit with Gaussian prior distribution and likelihood function, which admits tractable application of exact TS.
Nevertheless, this result represents a beginning to the theory of ES, suggesting that the approach is sound and the analysis might be extended to broader problem classes in the future.
In the remainder of this section, we compare our regret bound to others presented in closely related literature.
Comparison with the regret bound for TS
The regret bound in Theorem 1 consists of two terms.
The ﬁrst term ( a ) is exactly the regret bound achieved by TS with exact posterior
[Russo and Van Roy, 2016].
Note that H ( A ⇤ ) is the entropy of the optimal action A ⇤ and we always have H ( A ⇤ )  log K .
As discussed in Russo and Van Roy [2016], this ﬁrst term ( a ) is order optimal and improves upon the worst-case regret bound achieved by other algorithms such as upper conﬁdence bound algorithms since H ( A ⇤ )
⌧ log K when the prior is informative.
On the other hand, the second term ( b ) is an incremental term and accounts for posterior mismatch.
Note that as the number of models used by ES M ! 1 , the second term ( b ) converges to 0 and the regret bound in Theorem 1 reduces to that of TS with exact posterior.
Moreover, as long as M  KT/d , the regret bound in Theorem 1 has the same order as that of TS in terms of d and T (up to logarithmic factors).
Comparison with the regret bound in Lu and Van Roy [2017]
In Theorem 1, the upper bound is on the Bayesian regret where the prior over ✓ is N ( µ 0 , ⌃ 0 ) , and the regret also takes expectation over ✓ .
Lu and Van Roy [2017] studies ES in the frequentist setting where unknown ✓ is ﬁxed, and tries to upper bound the frequentist regret of ES by that of TS plus some approximation error term due to posterior mismatch, similar to the second term ( b ) in our Bayesian regret bound.
However, there are some technical issues in the analysis, as is discussed in Section 2.
Theorem 3 in Lu and Van Roy [2017] suggests that for any ✏ > 0 , when the number of models M = ˜ ⇥ ( K/ ✏ 2 ) (where ˜ ⇥ hides the logarithmic factors), the approximation error term is ✏  ( ✓ ) T where  ( ✓ ) = max a 2 A a > ✓  min a 2 A a > ✓ , while the second term ( b ) in our Bayesian regret bound in Theoremis linear in ⌘ = O ( p min { d, log K } ) .
To make the second term ( b ) scale as ˜ O ( ✏ T ) where ˜ O hides the logarithmic factors, the number of required models M is still ˜ ⇥ ( K/ ✏ 2 ) .
Notation
Before proceeding, we deﬁne some notation including Kullback–Leibler divergence, Hellinger distance, Shannon entropy and mutual information.
5.1 Kullback–Leibler divergence and Hellinger distance
For two probability distributions P and Q , the Kullback–Leibler (KL) divergence between P and Q is deﬁned as
[Equation]
if P is absolutely continuous with respect to Q ; otherwise, deﬁne d KL ( P k Q ) =
+
Note that in general d KL ( P k Q ) 6 = d KL ( Q k P ) .
The Hellinger distance between P and Q is deﬁned as
[Equation]
which is symmetric in P and Q .
In the special case of discrete distributions P = ( p 1 , . . . , p n ) and
Q = ( q 1 , . .
. , q n ) , the KL divergence and Hellinger distance between P and Q can be written as
[Equation]
5.2 Measures in information theory
Consider a discrete random variable X whose support is a ﬁnite set X and general random variable
Y and Z .
The Shannon entropy of X is deﬁned as
[Equation]
The entropy of X conditional on Y =
y is
[Equation]
and the conditional entropy of X given Y is,
[Equation]
x 2 X P ( X = x | Y ) log P ( X = x | Y ) ⇤ , where the expectation is taken with respect to the marginal distribution of Y .
The mutual information between X and Y is
[Equation]
which is the KL divergence between the joint distribution of X and Y and the product of the marginal distributions, and the conditional mutual information between X and Y given Z is
[Equation]
where the expectation is taken with respect to the marginal distribution of Z .
General regret bound
In this section, we derive a general Bayesian regret bound for any learning algorithm (Theorem 2), based on the Hellinger distance between the (conditional) action-selection distribution speciﬁed by the algorithm and the posterior distribution of the optimal action A ⇤ , and use it to establish the Bayesian regret bound for ES in Theorem 1.
We believe that our Bayesian regret bound is of independent interest and might be used to analyze other bandit algorithms, such as variants of approximate TS algorithms, in the future.
To simplify the exposition, we ﬁrst deﬁne some shorthand notation to simplify the exposition of this paper.
First, we use subscript t to denote conditioning on H t , speciﬁcally, we deﬁne
[Equation]
In addition, we deﬁne probability distributions p t and p t over action set A as
[Equation]
Given the history H t , p t is the conditional distribution of action A t and p t is the posterior distribution of the optimal action A ⇤ .
Both p t and p t are speciﬁed by the algorithm.
Note that under TS, given the history H t , p t and p t are the same, but they are not under other algorithms.
We conjecture that for approximate TS algorithms, when the approximation is accurate, p t is close to p t .
We have the following Bayesian regret bound for any learning algorithm:
Theorem 2.
Under any learning algorithm,
[Equation]
where ◆ and ⌘ are deﬁned in Equation (5) .
The regret bound in Theorem 2 holds for any learning algorithm.
Note H ( A ⇤ ) is the entropy of the optimal action A ⇤ and we always have H ( A ⇤ )  log K .
The ﬁrst term matches the regret bound for
TS derived in Russo and Van Roy [2016].
In the second term, [-(cid:80) T − 1 t =
-]P [Equation] E [ d 2H
[Equation] p [Equation] p t )] quantiﬁes the cumulative distance between the conditional distribution of the action A t and the posterior distribution the optimal action A ⇤ .
Under TS with exact posterior, d 2H ( p t k p t ) =
due to the posterior matching property of TS, i.e., p t = p t .
Moreover, for approximate TS algorithms, if the approximation is accurate, d 2H ( p t k p t ) should be small.
Regret bound in terms of KL divergence between p t and p t
It is sometimes more convenient to analyze the KL divergence between p t and p t .
Since the squared Hellinger distance is symmetric and upper bound by the KL divergence, we obtain the regret upper bound with the approximation error in terms of two forms of KL divergence between p t and p t . Fact 1 (Lemma 2.4 in Tsybakov [2009]) . For two probability distributions P and Q , we have [Equation]
Corollary 1.
Under any learning algorithm,
[Equation]
We will show in Section 7 that for ensemble sampling, d KL ( p t k p t ) can be bounded in terms of the number of models M .
It is noteworthy that in some other problems, it is more convenient to bound the other form d KL ( p t k p t ) .
One such example is the regret bound developed in Wen et al.
[-Upper bound on constant η in Theorem 2 and Corollary 
-]
6.1 Proof of Theorem
We deﬁne the per-period “main regret term" G t and “approximation error term" D t as follows,
[Equation]
Lemma 1.
The cumulative regret can be written as follows,
[Equation]
Proof.
By the tower property of conditional expectation, [Equation] where
[Equation]
where the second equality uses R t +
=
( R t +1 , 1 , . . .
, R t +1 ,K ) is independent of the action A t .
Next we are going to upper bound[-(cid:80) T − 1 t =
-]
{+P T  1 t =
+} E [ G t ] and[-(cid:80) T − 1 t =
-]
P
T  1 t =
E [ D t ] , respectively.
We ﬁrst upper bound each main regret term G t by the mutual information between the optimal action A ⇤ and action-reward pair ( A t , R t +1 ,A t ) conditioning on a given history H t .
Lemma 2.
With ◆ deﬁned in Equation (5) , for t = 0 , . . , T  1 ,
[Equation]
where I t ( A ⇤ ; ( A t , R t +1 ,A t )) is the mutual information between A ⇤ and ( A t , R t +1 ,A t ) conditioning on a given history at timestep t .
This result generalizes Proposition 5 and Corollary 1 in Russo and Van Roy [2016] for the case such that A t and A ⇤ are not identically distributed given the history.
Proof of Lemma 2. We write the action set A
= { a 1 , . .
. , a K } .
Fix t and deﬁne M 2 R K ⇥ K by
[Equation]
Then G t deﬁned in Equation (6) can written as G t = Trace(M) . On the other hand, I t ( [Equation]
⇤
[Equation] A [Equation] R t +
[Equation]
A t )
[Equation]
t
[Equation]
A ⇤
[Equation]
A
[Equation]
A
[Equation]
R
[Equation]
A
[Equation]
a j ) d KL ( P t ( R t +1 ,a i 2 ·| A ⇤ =
a j ) k
P t ( R t +1 ,a i 2 · )) , where the ﬁrst equality uses the chain rule of mutual information (Fact 2); the second and fourth ones follow from that conditioned on the history H t , A t is jointly independent of A ⇤ and R t +1 =
( R t +1 , 1 , . . .
, R t +1 ,K ) ; the ﬁfth equality uses the KL divergence form of mutual information (Fact 3).
{+By the updating rule on covariance matrix in Equation (3), conditioned on H t , ✓ ⇠ N ( µ t , ⌃ t ) with ⌃ t  ⌃ 0 , so for any i 
+}
[ K ] ,
[Equation]
a
[Equation]
where a > i ⌃ t a i  a > i ⌃ 0 a i  max a 2 A a > ⌃ 0 .
{+This implies that R t +1 ,a i is sub-Gaussian with variance proxy max a 2 A a > ⌃ 
+}
a +  2 .
Then by Lemma 10, we have
[Equation]
Then by Fact 4,
G 2 t
I
[Equation]
Now we show that Rank( M )  d .
Deﬁne ⌫ =
E t [ ✓ ] and ⌫ j = E
[Equation]
[Equation]
Then for any i, j 2 [ K ] ,
[Equation]
i
[Equation] and thus [Equation] Since M is the product of one K ⇥ d matrix and the other d ⇥ K matrix, Rank( M )  d .
Now we are ready to bound
P
[Equation]
[ G t ] and derive the ﬁrst term of the regret bound in Theorem 2. Lemma 3. With ◆ deﬁned in Equation (5) , the following inequality holds: [Equation]
The proof is (almost) the same as that of Proposition 1 in Russo and Van Roy [2016], and is left to
Appendix B. The remaining task is to upper bound E
[ D t ] where D t is the approximation error term deﬁned in Equation (7).
By analyzing (potentially) unbounded prior and noises, we have the following lemma.
Lemma 4.
With ⌘ deﬁned in Equation (5) , for t = 0 , . .
, T  1 ,
[-E [ D t ] ≤ η (cid:113) E [ d 2H ( p t ∥ p t )] . Summing over timestep t gives the second term of the regret bound in Theorem 2, i.e., (cid:80) T − 1 t =
 E [ D t ] ≤ η (cid:80) T − 1 t =
-][Equation]
Proof.
Fix t .
[Equation]
where the ﬁrst inequality applies the Cauchy–Schwarz inequality; the second inequality uses the Jensen’s inequality as well as the deﬁnition of Hellinger distance; the second equality uses A t is independent of R t +1 =
( R t +1 , 1 , . . .
, R t +1 ,K ) .
Taking expectation on both sides, we have
[Equation]
where the second inequality uses the Cauchy–Schwarz inequality and the tower property of conditional expectation and the last equality holds since W t +1 ,A ⇤ , W t +1 ,A t ⇠ N (0 ,  2 ) are independent noises.
Approximation error under ensemble sampling
In this section, we are going to bound the cumulative approximation error
[Equation]
)] in Corollary 1 for ensemble sampling, where p t is the conditional distribution of the chosen action A t and p t is the posterior distribution of the optimal action A ⇤ .
The whole section is devoted to proving the following Lemma 5 on per-period approximation error.
Summing over timestep t yields gives the second term of the regret bound in Theorem 1.
Lemma 5.
Under ensemble sampling (Algorithm 1), for all t = 0 , . . .
, T  1 ,
[Equation]
Before proving this result, we ﬁrst discuss the behavior of ensemble sampling.
Ensemble sampling uniformly samples a model m 2 { 1 , . . .
, M } , and then chooses the action A t uniformly from the set ˜
A t,m , arg max a 2 A a > ˜ ✓ t,m .
We deﬁne the following approximation of p t ( a ) :
[Equation]
where | ˜
A t,m | is the cardinality of the set ˜
A t,m (with probability one, | ˜
A t,m | = 1 ).
ES is a simple variant of approximate TS.
At time t , TS would sample an action from the posterior distribution of the optimal action A ⇤ , while ES would sample an action from the approximation ˆ p t .
Notice that the history H t does not include independent random perturbation ˜ W t ⇠ N (0 ,  2 I ) used in updating
M models (see Equation (4)).
Therefore, given history H t , ˆ p t ( a ) is still a random variable, and its expectation is the conditional probability of sampling action a , i.e., E t
[ˆ p t ( a )] =
p t ( a ) .
By convexity of KL divergence, the per-period approximation error
[Equation]
Taking expectation of both sides gives E [ d KL ( p t k p t )]  E [ d KL (ˆ p t k p t )] , and we are going to upper bound E [ d KL (ˆ p t k p t )] .
Note that the relationship between the expectation and cumulative distribution function can be written as
[Equation]
The following result can be used to upper bound each P ( d KL (ˆ p t k p t ) > ✏ ) in the above integral.
Lemma 6 (Lemma 4 in Lu and Van Roy [2017]) .
Let ✏ > 0 .
For t = 0 , . . .
, T  1 ,
[Equation]
Taking expectation over ✓ gives P ( d KL (ˆ p t k p t ) > ✏ )  ( t + 1) K ( M + 1) K e  M ✏ .
Consider any threshold   0 .
The integral in Equation (8) can be decomposed and bounded as follows.
[Equation]
Taking derivative of RHS gives optimal  ⇤ = K [ [Equation] +
[Equation]
+log
[Equation] M + [Equation] ] M .
Plugging in  ⇤ yields
[Equation]
This completes the proof of Lemma 5.
Summing over timestep t yields the upper bound on cumulative approximation error, which implies the regret bound for ensemble sampling in Theorem 1.
Concluding remarks
We have presented the ﬁrst rigorous analysis for ensemble sampling and developed the regret bound in Theorem 1 for linear bandits.
The regret bound approaches that for Thompson sampling as the ensemble size increases.
It is worth mentioning that ES is developed for broader and more challenging bandit and reinforcement learning problems, and the linear bandit serves only as a simple sanity check.
In particular, ES can be used to approximate TS in the absence of conjugacy properties, when it is intractable to maintain and sample from the exact posterior.
As discussed in Section 2, a substantial literature has been devoted to research in this direction.
It is also noteworthy that in many practical problems, ES with a moderate number of models (e.g.  30 models) outperforms other state-of-the-art benchmarks [Lu and Van Roy, 2017, Lu et al., 2018, Osband et al., 2019].
As a stepping stone, we have also established a general regret bound in Theorem 2 that applies to any learning algorithm for linear bandits .
This general regret bound may be of independent interest, since it is particularly useful for analyzing other varieties of approximate TS (e.g. approximate TS with epistemic neural networks
[Osband et al., 2022a]).
To establish a regret bound for an approximate TS algorithm based on Theorem 2, one only need to bound the Hellinger distance between the algorithm’s sampling distribution and the true posterior distribution over the optimal action.
Finally, we believe that Theorem 2 could be generalized to any bandit problem based on the concept of information ratio proposed in Russo and Van Roy [2016], as long as the information ratio can be appropriately bounded.
These problems include online learning with full information feedback [Shalev-Shwartz, 2012] and “graph" information feedback [Alon et al., 2015], combinatorial semibandits [Kveton et al., 2015, Wen et al., 2015], and pure exploration problems [Bubeck et al., 2009,
Russo, 2016, Komiyama et al., 2021].
We also conjecture that the results of this paper can be extended to generalized linear bandits [Filippi et al., 2010, Dong et al., 2019] and episodic reinforcement learning [Osband et al., 2013], but leave these extensions to future work.