Thompson Sampling

Thompson sampling (posterior sampling) samples an environment from the posterior and plays its optimal action, so exploration comes from posterior randomness. The note covers its Bayesian regret O(√(kn log n)) for any prior, via the key identity that the played action and the optimal action have the same conditional law, which reduces the analysis to UCB's. The frequentist analysis views Thompson sampling as stochastic follow-the-perturbed-leader with per-arm perturbation distributions, and bounds pull counts by an optimism term Σ(1/G₁ₛ − 1) plus an over-sampling term Σ 𝕀{Gᵢₛ > 1/n}; this gives asymptotic optimality (2/Δᵢ) and O(√(nk log n)) for Gaussian Thompson sampling with a flat prior, with higher regret variance than AdaUCB in experiments. Linear Thompson sampling has Bayesian regret O(d√n log n), and its computational advantage is that it needs only a linear optimisation, whereas LinUCB needs a bilinear one. The information-theoretic analysis bounds Bayesian regret by information ratio × information gain; the posterior over the optimal action is a martingale whose expected Bregman divergence telescopes, giving √(kn log k/2) against Bayesian adversaries and √(2kn) with the Tsallis potential. Notes cover information-directed sampling, BayesUCB, sensitivity to misspecified priors, the variance inflation needed for frequentist linear guarantees, and minimax adversarial bounds via Sion's theorem.

· 17 min read · 3,380 words

Corresponds to Lattimore & Szepesvári, Chapter 36.

Motivation: where it all began

IntuitionSample a world, then act optimally in it

Thompson (1933) proposed the first bandit algorithm, for two Bernoulli arms, with hand-calculated evidence only. Choose a prior over environments. Each round, sample an environment from the posterior and play its optimal action.

  • When the posterior is diffuse, samples vary a lot and the algorithm explores.
  • When the posterior concentrates, samples agree and it exploits.

Exploration is automatic and proportional to uncertainty, with no confidence-level tuning. The algorithm was largely ignored for eight decades, then rediscovered around 2010 (Graepel, Granmo, Chapelle–Li, …). It is now near-optimal in many settings and often very practical.

WarningRandomisation has a cost

Randomisation is essential against adversaries and sometimes useful in stochastic settings (SETC, TopRank). But injecting noise can raise the variance of the regret. What Thompson sampling gains or loses through its randomness is still not fully understood.

AnalysisSettingResult
Bayesianfinite-armed, any priorBRn=O(knlog⁡n)\mathrm{BR}_n = O(\sqrt{kn\log n}); O(kn)O(\sqrt{kn}) with refined intervals
FrequentistGaussian, flat priorasymptotically optimal ∑2/Δi\sum2/\Delta_i; O(nklog⁡n)O(\sqrt{nk\log n})
BayesianlinearO(dnlog⁡n)O(d\sqrt n\log n), matching LinUCB
Information-theoreticBayesian adversarialknlog⁡k/2\sqrt{kn\log k/2}; 2kn\sqrt{2kn} with the Tsallis potential

Thompson sampling for finite-armed bandits

AlgorithmThompson sampling (Algorithm 23)

Input: a Bayesian bandit environment (E,B(E),Q,P)(\mathcal E,\mathfrak B(\mathcal E),Q,P) (Chapter 34). For t=1,…,nt = 1, \ldots, n:

  1. sample νt∼Q(⋅∣A1,X1,…,At−1,Xt−1)\nu_t\sim Q(\cdot\mid A_1,X_1,\ldots,A_{t-1},X_{t-1});
  2. play At=arg⁡max⁡iμi(νt)A_t = \arg\max_i\mu_i(\nu_t).

Formally, πt(a∣ht−1)=Q(Ba∣ht−1)\pi_t(a\mid h_{t-1}) = Q(B_a\mid h_{t-1}) with Ba={ν:a=arg⁡max⁡bμb(ν)}B_a = \{\nu : a = \arg\max_b\mu_b(\nu)\} (systematic tie-breaking): play each arm with its posterior probability of being optimal.

NoteThree equivalent views (Note 1, Exercise 36.1)

  1. play aa with probability P(A∗=a∣history)\mathbb P(A^* = a\mid\text{history}) (Thompson’s original view);
  2. sample an environment and play its best arm (Algorithm 23);
  3. if arm means are independent under the posterior: sample each arm’s mean and play the largest.

These are different push-forwards of the same posterior. They define the same policy, but approximate Thompson sampling (for example in RL) differs depending on which object is approximated. Non-Bayesian ways to induce exploration can also be cheaper.

Bayesian regret

TheoremTheorem 36.1 — Bayesian regret of Thompson sampling

If every PνiP_{\nu i} is 1-subgaussian (after centring) with mean in [0,1][0,1], then for any prior,

BRn(TS,Q)≤Cknlog⁡n\mathrm{BR}_n(\mathrm{TS},Q)\le C\sqrt{kn\log n}

Refined (MOSS-type) confidence bounds give CknC\sqrt{kn} (Exercise 36.4; Bubeck–Liu 2013).

ImportantThe key identity

Under the Bayesian measure, given the history,

P(A∗=⋅∣Ft−1)=P(At=⋅∣Ft−1)a.s.(36.1)\mathbb P(A^* = \cdot\mid\mathcal F_{t-1}) = \mathbb P(A_t = \cdot\mid\mathcal F_{t-1})\quad\text{a.s.} \tag{36.1}

The optimal arm A∗A^* is random through ν\nu, and Thompson sampling plays an arm with the same posterior law (Exercise 36.3). So any history-measurable function UtU_t satisfies E[Ut(A∗)∣Ft−1]=E[Ut(At)∣Ft−1]\mathbb E[U_t(A^*)\mid\mathcal F_{t-1}] = \mathbb E[U_t(A_t)\mid\mathcal F_{t-1}], which lets UCB’s analysis run unchanged.

ProofUCB analysis via probability matching

Step 1: Insert a UCB. Let Ut(i)=clip[0,1](μ^i(t−1)+2log⁡(1/δ)/(1∨Ti(t−1)))U_t(i) = \mathrm{clip}_{[0,1]}\big(\hat\mu_i(t-1) + \sqrt{2\log(1/\delta)/(1\vee T_i(t-1))}\big), which is Ft−1\mathcal F_{t-1}-measurable. By (36.1),

E[μA∗−μAt∣Ft−1]=E[μA∗−Ut(A∗)∣Ft−1]+E[Ut(At)−μAt∣Ft−1]\mathbb E[\mu_{A^*} - \mu_{A_t}\mid\mathcal F_{t-1}] = \mathbb E[\mu_{A^*} - U_t(A^*)\mid\mathcal F_{t-1}] + \mathbb E[U_t(A_t) - \mu_{A_t}\mid\mathcal F_{t-1}]

so BRn=E[∑t(μA∗−Ut(A∗))+∑t(Ut(At)−μAt)]\mathrm{BR}_n = \mathbb E\big[\sum_t(\mu_{A^*} - U_t(A^*)) + \sum_t(U_t(A_t) - \mu_{A_t})\big] (36.2).

Step 2: The good event. EE is the event that every confidence interval holds, with P(Ec)≤2nkδ\mathbb P(E^c)\le2nk\delta (Exercise 36.2). On EE:

  • optimism: the first sum is at most 0, since Ut(i)≥μiU_t(i)\ge\mu_i;
  • width: Ut(i)−μi≤8log⁡(1/δ)/(1∨Ti(t−1))U_t(i) - \mu_i\le\sqrt{8\log(1/\delta)/(1\vee T_i(t-1))}, so ∑t(Ut(At)−μAt)≤∑i∫0Ti(n)8log⁡(1/δ)sds=∑i32Ti(n)log⁡(1/δ)≤32nklog⁡(1/δ)\sum_t(U_t(A_t) - \mu_{A_t})\le\sum_i\int_0^{T_i(n)}\sqrt{\frac{8\log(1/\delta)}s}ds = \sum_i\sqrt{32T_i(n)\log(1/\delta)}\le\sqrt{32nk\log(1/\delta)}

Step 3: on EcE^c the regret is at most 2n2n. Take δ=n−2\delta = n^{-2}.

∎

IntuitionThompson sampling is “UCB in expectation”

UCB plays the arm with the largest confidence bound. Thompson sampling plays arms in proportion to the probability of being best. In the Bayesian analysis these are interchangeable: any optimistic index, in expectation over the posterior, is as large at AtA_t as at A∗A^*. Thompson sampling never computes the index, yet inherits its guarantees for any prior (Russo–Van Roy 2014).


Frequentist analysis

WarningWhy frequentist analysis is harder

For a fixed ν\nu, the optimal arm is not random, so (36.1) fails: AtA_t is random but A∗A^* isn’t. A different argument is needed.

AlgorithmStochastic follow-the-perturbed-leader (Algorithm 24)

Per-arm distribution functions Fi(1)F_i(1). Each round:

  1. sample θi(t)∼Fi(t)\theta_i(t)\sim F_i(t) independently;
  2. play At=arg⁡max⁡iθi(t)A_t = \arg\max_i\theta_i(t);
  3. update only the played arm: FAt(t+1)=Update(FAt(t),At,Xt)F_{A_t}(t+1) = \mathrm{Update}(F_{A_t}(t),A_t,X_t).

With a product prior and Bayesian updates this is Thompson sampling. The key property is that an arm’s distribution changes only when it is played. Let FisF_{is} be arm ii‘s distribution after ss plays, defined for all ss through the reward-stack model. This is the stochastic cousin of FTPL (and Exp3 is FTPL with Gumbel noise).

TheoremTheorem 36.2 — Pull-count bound for perturbed leaders

Let arm 1 be optimal, i>1i > 1, ε∈R\varepsilon\in\mathbb R, and Gis=1−Fis(μ1−ε)G_{is} = 1 - F_{is}(\mu_1 - \varepsilon), the probability that arm ii‘s sample exceeds μ1−ε\mu_1 - \varepsilon after ss plays. Then

E[Ti(n)]≤1+E∑s=0n−1(1G1s−1)⏟optimal arm not optimistic enough+E∑s=0n−1I{Gis>1/n}⏟suboptimal arm still plausible(36.3)\mathbb E[T_i(n)]\le1 + \underbrace{\mathbb E\sum_{s=0}^{n-1}\Big(\frac1{G_{1s}} - 1\Big)}_{\text{optimal arm not optimistic enough}} + \underbrace{\mathbb E\sum_{s=0}^{n-1}\mathbb I\{G_{is} > 1/n\}}_{\text{suboptimal arm still plausible}} \tag{36.3}

IntuitionThe perturbation scale trades the two terms

  • First term: how hard it is for the optimal arm’s sample to be (nearly) optimistic. Larger perturbation variance makes it smaller (more exploration).
  • Second term: how long a suboptimal arm’s sample can still look as good as μ1\mu_1. Smaller variance makes it smaller (less exploration).

Balancing the two is the exploration–exploitation trade-off, here set by the spread of the posterior.

ProofProof of Theorem 36.2: compare playing ii with playing 1 when ii‘s sample is low

Let Ei(t)={θi(t)≤μ1−ε}E_i(t) = \{\theta_i(t)\le\mu_1 - \varepsilon\} and split E[Ti(n)]=E∑tI{At=i,Ei(t)}+E∑tI{At=i,Eic(t)}\mathbb E[T_i(n)] = \mathbb E\sum_t\mathbb I\{A_t = i,E_i(t)\} + \mathbb E\sum_t\mathbb I\{A_t = i,E_i^c(t)\} (36.4).

First part. Let At′=arg⁡max⁡j≠1θj(t)A_t' = \arg\max_{j\ne1}\theta_j(t). Since θ1(t)\theta_1(t) is conditionally independent of the others:

  • P(At=1,Ei(t)∣Ft−1)≥G1T1 P(At′=i,Ei(t)∣Ft−1)\mathbb P(A_t = 1, E_i(t)\mid\mathcal F_{t-1})\ge G_{1T_1}\,\mathbb P(A_t' = i, E_i(t)\mid\mathcal F_{t-1}) (arm 1’s sample beats μ1−ε\mu_1 - \varepsilon, which beats everyone else);
  • P(At=i,Ei(t)∣Ft−1)≤(1−G1T1) P(At′=i,Ei(t)∣Ft−1)\mathbb P(A_t = i, E_i(t)\mid\mathcal F_{t-1})\le(1 - G_{1T_1})\,\mathbb P(A_t' = i, E_i(t)\mid\mathcal F_{t-1}).

So P(At=i,Ei∣Ft−1)≤(1G1T1(t−1)−1)P(At=1∣Ft−1)\mathbb P(A_t = i, E_i\mid\mathcal F_{t-1})\le\big(\frac1{G_{1T_1(t-1)}} - 1\big)\mathbb P(A_t = 1\mid\mathcal F_{t-1}). Summing over tt, each value T1(t−1)=sT_1(t-1) = s occurs in only one round in which arm 1 is played, giving the ∑s(1/G1s−1)\sum_s(1/G_{1s} - 1) term (36.6).

Second part. In rounds where arm ii‘s current G>1/nG > 1/n, count plays of ii: at most ∑sI{Gis>1/n}\sum_s\mathbb I\{G_{is} > 1/n\}. In the other rounds, P(Eic(t))≤1/n\mathbb P(E_i^c(t))\le1/n, so they contribute at most 1 in total (Exercise 36.5).

∎

TheoremTheorem 36.3 — Gaussian Thompson sampling is asymptotically optimal

With Fi(1)=δ∞F_i(1) = \delta_\infty (forces one initial play of each arm) and Fi(t)=F_i(t) = the CDF of N(μ^i(t),1/Ti(t))\mathcal N(\hat\mu_i(t), 1/T_i(t)) (a flat-prior Gaussian posterior), on Gaussian bandits ν∈ENk(1)\nu\in\mathcal E^k_N(1):

lim⁡n→∞Rnlog⁡n=∑i:Δi>02Δi,Rn≤Cnklog⁡n\lim_{n\to\infty}\frac{R_n}{\log n} = \sum_{i:\Delta_i>0}\frac2{\Delta_i},\qquad R_n\le C\sqrt{nk\log n}

ProofSketch (Exercise 36.6)

(a) Optimism of the optimal arm. E∑s(1/G1s−1)≤cε2log⁡1ε\mathbb E\sum_s(1/G_{1s} - 1)\le\frac c{\varepsilon^2}\log\frac1\varepsilon, a constant. The sample N(μ^1s,1/s)\mathcal N(\hat\mu_{1s},1/s) exceeds μ1−ε\mu_1 - \varepsilon unless μ^1s\hat\mu_{1s} is far below μ1\mu_1, which is exponentially unlikely in sε2s\varepsilon^2. Use the Gaussian tail lower bound 1−Φ(y)≥2/π e−y2/2/(y+y2+4)1 - \Phi(y)\ge\sqrt{2/\pi}\,e^{-y^2/2}/(y + \sqrt{y^2 + 4}).

(b) Over-sampling. E∑sI{Gis>1/n}≤2log⁡n(Δi−ε)2+o(log⁡n)\mathbb E\sum_s\mathbb I\{G_{is} > 1/n\}\le\frac{2\log n}{(\Delta_i - \varepsilon)^2} + o(\log n). For a Gaussian sample with variance 1/s1/s to exceed μ1−ε\mu_1 - \varepsilon with probability above 1/n1/n, roughly μ^is+2log⁡n/s≳μ1−ε\hat\mu_{is} + \sqrt{2\log n/s}\gtrsim\mu_1 - \varepsilon: exactly UCB’s condition, so s≲2log⁡n/(Δi−ε)2s\lesssim2\log n/(\Delta_i - \varepsilon)^2.

(c) Combine with the regret decomposition and let ε→0\varepsilon\to0. This matches the Lai–Robbins constant of asymptotically optimal UCB.

∎

ExampleExperiment 36.1 — Thompson sampling versus AdaUCB

Two Gaussian arms with means (1/5,0)(1/5, 0), n=2000n = 2000, 10510^5 runs: expected regret 23.8 for AdaUCB, 29.9 for Thompson sampling (both beat Chapter 7’s UCB). Thompson sampling’s regret distribution has a much heavier upper tail: its second moment is far larger. It is better than simple UCB, but worse in both mean and variance than sophisticated UCB variants.

WarningFrequentist caveats (Notes 3, 5)

  • Not minimax optimal for Gaussians: the worst case is Θ(nklog⁡k)\Theta(\sqrt{nk\log k}) (Agrawal–Goyal 2013), versus MOSS’s nk\sqrt{nk}.
  • The prior matters a lot. In classical statistics a bad prior is washed away by data. In bandits, a prior that underestimates an arm can mean it is (almost) never played, so no data ever corrects the belief (Exercise 36.16). Even for Gaussians with unknown variance, some natural priors are asymptotically optimal and others aren’t (Honda–Takemura 2014).
  • Where it is optimal: Beta–Bernoulli Thompson sampling is asymptotically optimal like KL-UCB (Kaufmann et al. 2012; Agrawal–Goyal 2013), and so are one-parameter exponential families with suitable priors (Korda et al. 2013).

RemarkBayesUCB (Note 4)

Instead of sampling, play the arm with the largest posterior quantile (a Bayesian upper confidence bound). It has excellent theory and practice (Kaufmann et al. 2012; Kaufmann 2018), and is a deterministic cousin of Thompson sampling.


Thompson sampling for linear bandits

AlgorithmLinear Thompson sampling (Algorithm 25)

E⊆Rd\mathcal E\subseteq\mathbb R^d, with rewards 1-subgaussian with mean ⟨θ,a⟩\langle\theta,a\rangle. Each round: sample θt\theta_t from the posterior, play At=arg⁡max⁡a∈A⟨a,θt⟩A_t = \arg\max_{a\in\mathcal A}\langle a,\theta_t\rangle, observe XtX_t.

TheoremTheorem 36.4 — Bayesian regret of linear Thompson sampling

If ∥θ∥2≤S\lVert\theta\rVert_2\le S and ∣⟨a,θ⟩∣≤1\lvert\langle a,\theta\rangle\rvert\le1 almost surely under the prior, and sup⁡a∥a∥2≤L\sup_a\lVert a\rVert_2\le L, then

BRn≤2+22dnβ2log⁡(1+nS2L2d),β=1+2log⁡n+dlog⁡(1+nS2L2d)\mathrm{BR}_n\le2 + 2\sqrt{2dn\beta^2\log\Big(1 + \frac{nS^2L^2}d\Big)},\qquad\beta = 1 + \sqrt{2\log n + d\log\Big(1 + \frac{nS^2L^2}d\Big)}

That is O(dnlog⁡n)O(d\sqrt n\log n) for fixed S,LS, L, matching LinUCB’s Corollary 19.3.

ProofSame trick with the ellipsoidal UCB

Let Ut(a)=⟨a,θ^t−1⟩+β∥a∥Vt−1−1U_t(a) = \langle a,\hat\theta_{t-1}\rangle + \beta\lVert a\rVert_{V_{t-1}^{-1}} with Vt=I/S2+∑s≤tAsAs⊤V_t = I/S^2 + \sum_{s\le t}A_sA_s^\top. The self-normalised bound gives ∥θ^t−1−θ∥Vt−1≤β\lVert\hat\theta_{t-1} - \theta\rVert_{V_{t-1}}\le\beta for all tt (event EE) except with probability 1/n1/n, which costs at most 2. On EtE_t, using probability matching Et−1Ut(A∗)=Et−1Ut(At)\mathbb E_{t-1}U_t(A^*) = \mathbb E_{t-1}U_t(A_t) and optimism, Et−1[IEt⟨A∗−At,θ⟩]≤Et−1[IEt(Ut(At)−⟨At,θ⟩)]≤2β∥At∥Vt−1−1\mathbb E_{t-1}[\mathbb I_{E_t}\langle A^* - A_t,\theta\rangle]\le\mathbb E_{t-1}[\mathbb I_{E_t}(U_t(A_t) - \langle A_t,\theta\rangle)]\le2\beta\lVert A_t\rVert_{V_{t-1}^{-1}}. Truncate at 2, apply Cauchy–Schwarz over tt, and use the elliptical potential lemma.

∎

ImportantThe real advantage: computation

Thompson sampling needs (1) a posterior sample, which is easy for a Gaussian prior with Gaussian noise and generally the subject of a large MCMC literature, and (2) a linear optimisation arg⁡max⁡a⟨a,θt⟩\arg\max_a\langle a,\theta_t\rangle. LinUCB needs a bilinear problem max⁡amax⁡θ~∈C⟨a,θ~⟩\max_a\max_{\tilde\theta\in\mathcal C}\langle a,\tilde\theta\rangle, often intractable for large or continuous action sets. In finite-armed bandits Thompson sampling’s advantages are modest; in linear and structured problems they are substantial.

WarningLinear Thompson sampling: frequentist and asymptotic limits (Notes 2, 6)

  • Frequentist guarantee needs variance inflation. Sample θt∼N(θ^t−1,rVt−1−1)\theta_t\sim\mathcal N(\hat\theta_{t-1}, rV_{t-1}^{-1}) with r=Θ(d)r = \Theta(d) (a pretend noise variance of order dd). That gives O~(d3/2n)\tilde O(d^{3/2}\sqrt n), worse than LinUCB by d\sqrt d (Agrawal–Goyal 2013; Abeille–Lazaric 2017). The analysis needs the samples to be optimistic with constant probability, which requires the inflation. Hamidi–Bayati (2020) showed it is necessary on some instances, even with three fixed actions. Empirically r=1r = 1 often works well.
  • Not asymptotically optimal: like optimism, it under-plays informative but suboptimal actions (clouds looming). When Thompson sampling is near-optimal in general remains open.

Information-theoretic analysis

Setting: Bayesian adversarial bandits. A reward matrix X∈[0,1]n×kX\in[0,1]^{n\times k} is drawn from a prior QQ and kept secret. The learner sees XtAtX_{tA_t}. Actions depend on XX only through the history, so At⊥X∣Ht−1A_t\perp X\mid H_{t-1}. The optimal arm is A∗=arg⁡max⁡a∑tXtaA^* = \arg\max_a\sum_tX_{ta}, and BRn=E∑t(XtA∗−XtAt)\mathrm{BR}_n = \mathbb E\sum_t(X_{tA^*} - X_{tA_t}). Thompson sampling plays P(A∗=⋅∣Ht−1)\mathbb P(A^* = \cdot\mid H_{t-1}). This includes stochastic bandits as a special case (an i.i.d. prior).

TheoremTheorem 36.5 — Thompson sampling against Bayesian adversaries

For any prior on [0,1]n×k[0,1]^{n\times k},

BRn(TS)≤knlog⁡k2\mathrm{BR}_n(\mathrm{TS})\le\sqrt{\frac{kn\log k}2}

TheoremTheorem 36.6 — Regret ≤ √(information ratio × total information)

Let Mt=Pt(A∗=⋅)∈Pk−1M_t = \mathbb P_t(A^* = \cdot)\in\mathcal P_{k-1} be the posterior over the optimal arm, Δt=XtA∗−XtAt\Delta_t = X_{tA^*} - X_{tA_t} the instantaneous regret, and FF convex. If

Et−1[Δt]≤β Et−1[DF(Mt,Mt−1)]a.s.\mathbb E_{t-1}[\Delta_t]\le\sqrt{\beta\,\mathbb E_{t-1}\big[D_F(M_t,M_{t-1})\big]}\quad\text{a.s.}

then BRn≤nβ diamF(Pk−1)\mathrm{BR}_n\le\sqrt{n\beta\,\mathrm{diam}_F(\mathcal P_{k-1})}.

ProofThe posterior is a martingale, so expected Bregman divergences telescope

Step 1: MtM_t is a martingale: Et−1[Mt]=Mt−1\mathbb E_{t-1}[M_t] = M_{t-1}. For convex FF (using directional derivatives, Fatou, and Jensen),

Et−1[DF(Mt,Mt−1)]≤Et−1[F(Mt)]−F(Mt−1)(36.8)\mathbb E_{t-1}\big[D_F(M_t,M_{t-1})\big]\le\mathbb E_{t-1}[F(M_t)] - F(M_{t-1}) \tag{36.8}

since the linear term vanishes in expectation.

Step 2: by the assumption and Cauchy–Schwarz, BRn≤E∑tβEt−1DF≤βn E∑tEt−1DF\mathrm{BR}_n\le\mathbb E\sum_t\sqrt{\beta\mathbb E_{t-1}D_F}\le\sqrt{\beta n\,\mathbb E\sum_t\mathbb E_{t-1}D_F}.

Step 3: by (36.8) the sum telescopes to E[F(Mn)]−F(M0)≤diamF(Pk−1)\mathbb E[F(M_n)] - F(M_0)\le\mathrm{diam}_F(\mathcal P_{k-1}).

∎

IntuitionRegret only where you learn

The information ratio β≈(expected regret)2/(information gained)\beta\approx(\text{expected regret})^2/(\text{information gained}) says that each round’s regret is paid for by learning about the optimal action. The total learnable information is bounded by the potential’s range (log⁡k\log k for negentropy: you can’t learn more than the entropy of A∗A^*). A small information ratio plus finite total information gives small regret. With negentropy, Et−1D(Mt∥Mt−1)\mathbb E_{t-1}D(M_t\Vert M_{t-1}) is the mutual information It−1(A∗;(At,XtAt))I_{t-1}(A^*;(A_t,X_{tA_t})), the information gain about the optimal arm, hence the name.

LemmaLemma 36.7 — Thompson sampling’s information ratio is at most k/2k/2

If Xti∈[0,1]X_{ti}\in[0,1], Thompson sampling with any prior satisfies

Et−1[Δt]≤k2 Et−1[D(Pt(A∗∈⋅),Pt−1(A∗∈⋅))]\mathbb E_{t-1}[\Delta_t]\le\sqrt{\frac k2\,\mathbb E_{t-1}\big[D(\mathbb P_t(A^*\in\cdot),\mathbb P_{t-1}(A^*\in\cdot))\big]}

ProofProbability matching, Pinsker, Cauchy–Schwarz

Write pa=Pt−1(At=a)=Pt−1(A∗=a)p_a = \mathbb P_{t-1}(A_t = a) = \mathbb P_{t-1}(A^* = a) (probability matching). Then

Et−1[Δt]=∑apa(Et−1[Xta∣A∗=a]−Et−1[Xta])≤∑apa12D(PXta∣A∗=a,PXta)\mathbb E_{t-1}[\Delta_t] = \sum_ap_a\big(\mathbb E_{t-1}[X_{ta}\mid A^* = a] - \mathbb E_{t-1}[X_{ta}]\big)\le\sum_ap_a\sqrt{\tfrac12D\big(\mathbb P_{X_{ta}\mid A^*=a},\mathbb P_{X_{ta}}\big)}

by Pinsker, since X∈[0,1]X\in[0,1]. Cauchy–Schwarz over kk terms gives at most k2∑apa2D(⋯ )\sqrt{\frac k2\sum_ap_a^2D(\cdots)}. Bound pa2Daap_a^2D_{aa} by the full double sum ∑a,bpapbD(PXta∣A∗=b,PXta)\sum_{a,b}p_ap_bD(\mathbb P_{X_{ta}\mid A^*=b},\mathbb P_{X_{ta}}), which equals the mutual information between A∗A^* and the observation (At,XtAt)(A_t,X_{tA_t}) (by Bayes, Exercise 36.7), i.e. the expected KL from prior to posterior on A∗A^*.

∎

ProofProof of Theorem 36.5

Lemma 36.7 gives β=k/2\beta = k/2 with negentropy, whose diameter on the simplex is log⁡k\log k. Theorem 36.6 gives n⋅k2log⁡k\sqrt{n\cdot\frac k2\log k}.

∎

TheoremVariants (Exercises 36.8–36.10)

  • Full information (Thompson sampling for experts): β=1/2\beta = 1/2, so BRn≤nlog⁡(k)/2\mathrm{BR}_n\le\sqrt{n\log(k)/2}.
  • Information-directed sampling (IDS): choose the action distribution that minimises the information ratio directly, Pt=arg⁡min⁡p(∑apa(Et−1[Xta∣A∗=a]−Et−1Xta))2∑apaEt−1DF(⋅)P_t = \arg\min_p\frac{(\sum_ap_a(\mathbb E_{t-1}[X_{ta}\mid A^* = a] - \mathbb E_{t-1}X_{ta}))^2}{\sum_ap_a\mathbb E_{t-1}D_F(\cdot)}. It has the same knlog⁡k/2\sqrt{kn\log k/2} bound and can beat Thompson sampling in structured problems where informative actions are suboptimal (Russo–Van Roy 2014; frequentist version by Kirschner–Krause).
  • Tsallis potential F(p)=−2∑ipiF(p) = -2\sum_i\sqrt{p_i}, with total variation bounded by Hellinger: BRn≤2kn\mathrm{BR}_n\le\sqrt{2kn} for any prior, with no log⁡k\log k. This is the same potential as the 8kn\sqrt{8kn} INF algorithm. The stability terms of mirror descent and the information ratio are controlled by the same calculations (Zimmert–Lattimore 2019).
  • Any martingale works: the proof only used that MtM_t is a martingale. Other martingales sometimes give better bounds.
  • Linear bandits: information ratio about d/2d/2. For infinite action sets the entropy of A∗A^* can be infinite, so discretise and compare to a near-optimal action, giving O(dnlog⁡(1+n/d))O(d\sqrt{n\log(1 + n/d)}) (Dong–Van Roy 2018).

ImportantFrom Bayesian to adversarial regret: non-constructive minimax bounds (Note 11)

By Sion’s minimax theorem (Exercises 36.11–36.12; Tychonoff for the compactness of deterministic policies),

Rn∗([0,1]n×k)=sup⁡Q finite supportBRn∗(Q)≤nklog⁡k2(and≤2nk)R_n^*([0,1]^{n\times k}) = \sup_{Q\text{ finite support}}\mathrm{BR}_n^*(Q)\le\sqrt{\frac{nk\log k}2}\quad(\text{and}\le\sqrt{2nk})

This is a factor 2 better than Exp3’s Theorem 11.2. But it doesn’t produce an algorithm: it proves a good adversarial policy exists. The technique gave the first near-optimal bounds for adversarial convex bandits (Bubeck et al.; Bubeck–Eldan) and for partial monitoring.

ExampleBinary rewards are the worst case (Exercise 36.13)

Rn∗({0,1}n×k)=Rn∗([0,1]n×k)R_n^*(\{0,1\}^{n\times k}) = R_n^*([0,1]^{n\times k}): run a minimax policy for binary rewards on [0,1][0,1] rewards by feeding it a Bernoulli(xtAt)\mathrm{Bernoulli}(x_{tA_t}) sample of each observed reward. The expected regret is unchanged by linearity. (Reduction worked here.)


History and scope

RemarkHistory

Thompson (1933), two Bernoulli arms, no theory. Rediscovered around 2010. Frequentist analysis: Agrawal–Goyal (2012, 2013, bounded rewards); asymptotic optimality: Kaufmann et al. (2012), Korda et al. (2013). The Bayesian analysis via confidence intervals is due to Russo–Van Roy (2014). Information-theoretic analysis: Russo–Van Roy (2014, 2016), generalised beyond negentropy by Lattimore–Szepesvári (2019). Extensions include combinatorial semi-bandits (Wang–Chen 2018), reinforcement learning (posterior sampling for RL: Osband et al. 2013), and more. Tutorial: Russo et al. (2018). Algorithm 24 admits other perturbation schemes (Kveton et al. 2019).


Quick reference

ObjectStatementNote
Thompson samplingplay arg⁡max⁡iμi(νt)\arg\max_i\mu_i(\nu_t), νt∼\nu_t\sim posteriorequivalently P(A∗=a∣history)\mathbb P(A^* = a\mid\text{history})
Probability matchingP(A∗=⋅∣Ft−1)=P(At=⋅∣Ft−1)\mathbb P(A^* = \cdot\mid\mathcal F_{t-1}) = \mathbb P(A_t = \cdot\mid\mathcal F_{t-1})Bayesian only
Bayesian regretCknlog⁡nC\sqrt{kn\log n} (or CknC\sqrt{kn}) for any priorUCB proof via matching
Perturbed leadersample θi∼Fi\theta_i\sim F_i, update only the played armproduct prior = TS
Pull bound1+E∑(1/G1s−1)+E∑I{Gis>1/n}1 + \mathbb E\sum(1/G_{1s} - 1) + \mathbb E\sum\mathbb I\{G_{is} > 1/n\}optimism vs over-sampling
Gaussian TSN(μ^i,1/Ti)\mathcal N(\hat\mu_i, 1/T_i); Rn/log⁡n→∑2/ΔiR_n/\log n\to\sum2/\Delta_iworst case Θ(nklog⁡k)\Theta(\sqrt{nk\log k})
ExperimentTS 29.9 vs AdaUCB 23.8, TS higher variance
Linear TSBRn=O(dnlog⁡n)\mathrm{BR}_n = O(d\sqrt n\log n)only needs linear optimisation
Frequentist linear TSO~(d3/2n)\tilde O(d^{3/2}\sqrt n) with r=Θ(d)r = \Theta(d) inflationinflation necessary
Information theoremBRn≤nβ diamF\mathrm{BR}_n\le\sqrt{n\beta\,\mathrm{diam}_F}posterior martingale telescopes
TS information ratioβ=k/2\beta = k/2 (negentropy)Pinsker + Cauchy–Schwarz
Bayesian adversarialknlog⁡k/2\sqrt{kn\log k/2}; 2kn\sqrt{2kn} (Tsallis)full info: nlog⁡k/2\sqrt{n\log k/2}
IDSminimise the information ratiosame bounds, better on structure
Minimax via SionRn∗≤nklog⁡k/2R_n^*\le\sqrt{nk\log k/2}non-constructive

Facts to keep to hand

  • Thompson sampling explores by sampling plausible worlds. Exploration scales with posterior uncertainty, with no confidence tuning. It is simple, general and often practical, especially in linear and structured problems where it replaces LinUCB’s bilinear optimisation with a sample and a linear one.
  • Bayesian analysis is UCB analysis in disguise. Probability matching makes AtA_t and A∗A^* exchangeable given the history, so any optimistic index’s analysis transfers to any prior.
  • Frequentist analysis is a perturbation trade-off. Enough spread that the optimal arm is sometimes optimistic, little enough that bad arms stop looking good. Gaussian Thompson sampling attains Lai–Robbins, but it has heavier regret tails, depends on the prior (a bad prior can starve an arm), and linear versions need variance inflation for worst-case guarantees.
  • The information ratio unifies everything. Regret is at most √(information ratio × total information about A∗A^*). For Thompson sampling the ratio is k/2k/2, giving knlog⁡k/2\sqrt{kn\log k/2} for any prior. The Tsallis potential links this to mirror descent’s kn\sqrt{kn}, and via Sion it yields non-constructive minimax bounds for adversarial problems.

References

  • Lattimore & Szepesvári, Bandit Algorithms — Chapter 36
  • Russo & Van Roy, “An information-theoretic analysis of Thompson sampling” (2016)
  • Agrawal & Goyal, “Further optimal regret bounds for Thompson sampling” (2013)
  • Russo, Van Roy, Kazerouni, Osband & Wen, “A Tutorial on Thompson Sampling” (2018)

← All notes