Bayesian Bandits
The Bayesian approach to bandits. Statistical decision theory covers loss, dominance, admissibility, minimax versus Bayes-optimal policies, and how they relate. Posteriors are introduced via a two-marble example and then made rigorous with regular conditional distributions, posterior densities, and the non-uniqueness of posteriors and why it matters to frequentists. Conjugate priors cover Gaussian–Gaussian, Beta–Bernoulli and one-parameter exponential families, where the log-partition function's Bregman divergence is the KL divergence; posterior sequences form Markov chains. The Bayesian bandit environment and its product-form posteriors lead to Bayesian regret, Bayes-optimal policies, and the gap between Bayesian and frequentist guarantees. Further topics: the sup over priors equals minimax regret (Sion); the Bayes-optimal regret's √(kn) worst case and o(√n) for any fixed prior; optimal stopping via the Snell envelope and the Wald–Bellman equation; one-armed Bayesian bandits as optimal stopping, solved by backwards induction on sufficient statistics (Bernoulli exactly, Gaussian approximately); and discounted retirement games, the Gittins index as a fair charge, the Gittins index theorem via prevailing charges and interleavings, Varaiya's algorithm, and where index policies break.
Corresponds to Lattimore & Szepesvári, Chapters 34–35.
Motivation: average over environments instead of worst-casing them
IntuitionWhy go Bayesian
A policy that is optimal in one environment is usually not optimal in another, so some trade-off between environments is unavoidable. The frequentist answers so far were worst-case (minimax) and instance-dependent bounds for “reasonable” policies. The Bayesian answer: encode beliefs as a prior over environments and minimise expected loss under it. Bayesian methods dominated bandit research from about 1950 to 1980. The authors aren’t interested in Bayesian-versus-frequentist debates, only in the pros and cons of problem definitions and methods.
Statistical decision theory
DefinitionLoss, dominance, admissibility, minimax
Environments , policies , and a loss .
- is dominated if some has for all , strictly for some .
- Admissible (Pareto optimal) = not dominated.
- Minimax optimal: . Robust, but potentially costly on average.
- Bayes optimal for a prior : (an integral in general).
ExampleWhich policy would you choose?
With and four policies: one is dominated, one is minimax (flat at a moderate loss), and two are admissible, each excellent on part of . Minimax buys robustness at the cost of average performance. The Bayesian chooses by weighting environments, which is hard to criticise when the prior is really known and the user is risk-neutral, and often sensible even when it isn’t. Compare the multi-objective view of regret over a class.
TheoremAdmissibility versus Bayes optimality (Exercises 34.12–34.15)
- A uniquely Bayes-optimal policy is admissible. So is any Bayes-optimal policy when is countable and the prior has full support. In general, a Bayes-optimal policy is admissible on .
- A Bayes-optimal policy can be inadmissible, because it may behave badly on prior-null events.
- Conversely: with finitely many environments and a convex loss set, every Pareto-optimal policy is Bayes optimal for some prior. The proof uses the supporting hyperplane theorem: the prior is the hyperplane’s normal. In multi-criteria optimisation this is “every Pareto point minimises a convex combination of the criteria”. The same holds for -armed Bernoulli bandits (Exercise 34.15).
- Many classical results go “admissible ⟺ Bayes (or limits of Bayes)”, but counterexamples exist (Berger 1985).
RemarkToo binary
Admissibility is a blunt notion: a policy that is barely dominated is not worthless, especially when the optimal policy is intractable. A more useful view evaluates policy schemas, such as Thompson sampling, across whole families of problems: is the schema near Bayes- or minimax-optimal everywhere? Most bandit algorithm design is really schema design.
Posteriors
ExampleTwo marbles
A bag holds either two white marbles () or one white and one black (), each with prior probability . Draw one marble blindly. The likelihoods are and . By Bayes’ rule,
and . The hypotheses are part of the probability space: that is the Bayesian move.
DefinitionPrior, model, joint measure
Hypothesis space , prior on it, and a model that is a probability kernel from to the outcome space . The joint law is on , and is its -marginal. An observation is a measurable map on . The posterior is a kernel from observations to .
WarningNaive Bayes’ rule fails on null events
is undefined when , which is the usual case: with prior and , every point has probability 0. Defining gives an object unique only almost surely, which need not be a measure.
TheoremTheorem 34.1 — Posteriors exist (Borel hypothesis space)
If is a Borel space, there is a probability kernel with for all outside a single null set, unique for -almost every . This is the regular conditional distribution theorem in Bayesian notation.
FormulaPosterior density
With and (jointly measurable densities always exist when all ; Note 8),
When a dominating measure exists and the denominator is positive, (34.2) defines a valid posterior (Exercise 34.4); the denominator vanishes only on a -null set.
WarningNon-uniqueness matters to frequentists (Example 34.2)
Take the prior and the observation exactly. For any countable and any measure , the kernel equal to off and on is a valid posterior. A Bayesian doesn’t care, since has prior probability 0. A frequentist proves results for a fixed , which may well lie in , so the version of the posterior must be specified. In practice there is a canonical choice (continuous densities, the Gaussian posterior for Gaussian models), and “sensible choices yield sensible posteriors”. Related: the Borel–Kolmogorov paradox (Jaynes §15.7).
Conjugate priors
DefinitionConjugate pair
A prior family is conjugate to a model if the posterior stays in the family. This is crucial for computation: Bayesian algorithms need posteriors that can be computed or sampled efficiently, which tempers the advantage of a freely chosen prior.
| Model | Conjugate prior | Posterior after observing |
|---|---|---|
| , known | ||
| , both unknown | Gaussian–inverse-gamma | same family |
| , unique (Exercise 34.2) | ||
| (not an exponential family) | Pareto | Pareto |
IntuitionPrecisions add
The Gaussian posterior mean is a precision-weighted average of the prior mean and the data, and the posterior precision is the sum of the precisions. : the prior is certain and nothing is learned. : the prior is washed away after a single sample. : one observation reveals . : data is useless.
DefinitionSingle-parameter exponential family
With a base measure , sufficient statistic and natural-parameter map ,
on . It is regular if is nonempty and open, and non-singular if .
| Example | , | Family | ||
|---|---|---|---|---|
| 34.3 | , | |||
| 34.4 | , | |||
| 34.5 | , | , the same family reparameterised |
TheoremConjugate priors for exponential families
With , the prior density (34.4) has posterior of the same form with
acts as a pseudo-count and as a pseudo-mean. For Bernoulli, , which is .
TheoremExponential-family facts (Exercise 34.5, canonical )
- , and the MGF is .
- (34.12): the relative entropy is the Bregman divergence of the log-partition function .
- Chernoff: if , then , the exponential-family form of the large-deviation rate and of KL-UCB’s confidence intervals.
DefinitionSufficient statistic (Note 9)
is sufficient if doesn’t depend on : once you know , carries no more information about . Fisher–Neyman: with a common dominating measure, sufficiency is equivalent to the factorisation . The exponential family’s is sufficient in this sense.
Sequential posteriors
FormulaPredictive distribution and the Markov view
If is the posterior after , the tower rule gives
which reduces to for i.i.d. models: the posterior summarises everything useful for prediction. Under regularity, is a (time-inhomogeneous) Markov chain.
ExampleTwo posterior Markov chains
- Beta–Bernoulli (Example 34.6): with , and with probability (a Pólya urn).
- Gaussian (Example 34.7): prior , model , with and . Here .
Bayesian bandits
Definition-armed Bayesian bandit environment
A tuple : a measurable space of environments, a prior , and a kernel from to giving each arm’s reward distribution. With policy , random elements satisfy:
- ;
- : the policy doesn’t see ;
- .
Existence follows from Ionescu–Tulcea (Exercise 34.9); write . Rewards are now dependent through the shared random . The kernel notation (rather than Chapter 4’s tuples) ensures that regret is measurable in (Exercise 34.7).
FormulaBandit posterior
If all with densities , the canonical density gives
The policy terms cancel, exactly as in the divergence decomposition: the posterior depends on the actions only through which arms produced which rewards. The denominator is almost surely nonzero (Exercise 34.11).
ExampleBeta–Bernoulli bandits (Examples 34.8–34.9)
, , and a product prior. The posterior is again a product:
with the successes and the pulls of arm . Each arm’s Beta is updated only from its own data.
DefinitionBayesian regret and Bayes-optimal policy
Minimising Bayesian regret is equivalent to maximising , the Bayes-optimal policy. It need not exist, but -optimal policies always do. Deterministic policies suffice (Exercise 34.10).
ExampleBayes-optimal regret can be strictly positive (Exercise 34.8)
Prior on two Bernoulli arms. Round 1 is a coin flip from the learner’s point of view, so every policy pays : . Zero Bayesian regret would require knowing ‘s best arm in advance. (Example worked here.)
WarningBayesian regret is less informative than frequentist regret
for all implies , but a Bayesian regret bound says nothing about any particular . This argues for analysing Bayesian algorithms in the frequentist sense, not against using them.
TheoremWorst prior = minimax (Note 6; Sion; Exercise 34.16)
With , which is bilinear in a distribution over policies and a prior , Sion’s theorem gives . For Bernoulli bandits, with a suitable topology on priors,
The minimax regret equals the Bayesian regret under the least favourable prior. This bridges the adversarial and Bayesian views (Chapter 36).
RemarkBayesian interpretations of familiar algorithms (Note 5)
- Ridge regression is the posterior mean under a Gaussian model with prior , the same Gaussian prior behind the method of mixtures.
- Exponential weights under log loss is Bayesian mixture prediction. Experts give predictive distributions. With prior , the Bayes-optimal forecast is the posterior mixture (34.10), and the posterior is exactly exponential weights with on cumulative log loss. With a uniform prior, , so the regret is at most for every sequence (Exercise 34.6). This is mixture coding in learning-theory clothing. For general losses the learning rate must be much more conservative.
Bayesian optimal regret (Chapter 35)
TheoremHow large is ?
For Bernoulli bandits:
- Worst prior: . The upper bound comes from MOSS, the lower bound from the prior implicit in the Assouad-style proof (Exercise 15.2).
- Theorem 35.1 (fixed prior): for every , , but some prior has for all .
- Regular priors: (Lai 1987).
Contrast: for each fixed the regret is . Averaging over a prior with mass near is what produces the extra growth. The bad prior puts mass at least on .
ProofFirst part (Exercise 35.1 hint)
Use a policy with . Split into and its complement. On , . On , , and , where ties cost nothing. Choose slowly.
∎
Optimal stopping
DefinitionFinite-horizon optimal stopping and the Snell envelope
For adapted integrable , solve over stopping times (35.1). The Snell envelope is
the best value achievable from time on.
TheoremTheorem 35.2 — Stop when the envelope touches
is optimal. Proof idea (Exercise 35.2): is a supermartingale, it is a martingale while you shouldn’t stop, and optional stopping finishes the argument (Theorem 3.8).
DefinitionMarkov optimal stopping
For an infinite horizon, use Markov structure: a chain with kernel and reward . The value function is (35.2).
TheoremTheorem 35.3 — Wald–Bellman equation
If exists a.s. and is integrable, then
, and any that stops when exceeds the continuation value and continues when it is below is optimal; either choice is fine at indifference, e.g. . The conditions hold for ergodic chains with bounded utility, and for discounted reward sums. The proof is measure-theoretically delicate (Peskir–Shiryaev; Exercise 35.3).
IntuitionDynamic programming
Optimal stopping is dynamic programming: trade memory (value functions) for computation. The challenge is always the size of the state space on which the value function lives, so we look for sufficient statistics that shrink it.
One-armed Bayesian bandits
DefinitionSetting
Two arms: arm 2 is a Dirac at a known , arm 1 is uncertain with a prior. By Exercise 4.11, for a known horizon, retirement policies (play arm 1 until some time, then arm 2 forever) dominate all others, and deterministic ones suffice (Exercise 34.10). Retirement policies correspond bijectively to stopping times for arm 1’s reward stream :
The Bayesian one-armed bandit is an optimal stopping problem.
TheoremProposition 35.4 — Bayes-optimal retirement
If is integrable, retire at (Snell envelope with ). Equivalently, with the value to go ,
Retire at the first with : continue only while exploring is worth at least the sure payoff. If a sufficient statistic exists, then (Exercise 35.4).
AlgorithmBernoulli rewards, Beta prior: exact backwards induction
With and (the posterior mean): and
Compute for from down to 1. This is , versus for a frequentist stopping rule.
ExampleExperiment 35.1 — Bayesian versus frequentist retirement
, , uniform prior. Frequentist rule: retire at the first with and (35.4, a KL confidence test). The Bayes-optimal rule has lower prior-averaged regret. The frequentist rule stops later because of its conservative interval, so it wins for and loses more for . Both are asymmetric even though the prior is symmetric: the problem itself is asymmetric.
AlgorithmGaussian rewards: approximate dynamic programming
Arm 1 is with prior . After observations the posterior is with
The posterior variance is deterministic, so the state is just the posterior mean: , with and
The posterior mean moves by a Gaussian increment whose variance is the drop in posterior variance, . There is no closed form, but is increasing, convex, tends to at , and has slope at (Lemma 35.5). Approximate it piecewise quadratically on a grid , matching the endpoints and midpoint of each cell, so that the Gaussian integrals are analytic; use below and the linear asymptote above . Cost .
RemarkUndiscounted one-armed Gittins index (Notes 7–8)
With horizon , the index solves the one-armed problem: retire at the first with . Using for arms is no longer Bayes optimal, but works well and, for Gaussians, enjoys UCB-like frequentist regret (Lattimore 2016). Asymptotically the index behaves like the KL-UCB upper confidence bound (Burnetas–Katehakis 1997): optimism emerges from Bayesian optimality.
The Gittins index
WarningWhy arms are hard
Backwards induction on the joint sufficient statistics of all arms grows exponentially with . The finite-horizon Bayes-optimal policy is generally not an index policy. Gittins showed that changing the objective to geometrically discounted infinite-horizon reward makes the optimal policy an index policy, where each arm’s index depends only on that arm’s own state.
The discounted retirement game
DefinitionRetirement game and Gittins index
A Markov chain on a Borel space with kernel and reward . Each round, either retire or pay a fixed charge to collect . With discount ,
assuming (Assumption 35.6). and is decreasing in . The Gittins index (fair charge) is the largest charge at which you would still play at least once:
(equivalence: Exercise 35.6).
| Component | Detail |
|---|---|
| Signature | , per arm, using only that arm’s chain |
| Meaning (35.9) | best achievable discounted average reward rate over a stopping time |
| Meaning (35.8) | the per-round fee that makes you indifferent to starting |
LemmaLemma 35.7 — Structure of the retirement game
- (Wald–Bellman).
- If , the max is attained by continuing: .
- attains the supremum in (35.9): play while the index stays above the charge you started with.
The index theorem
DefinitionDiscounted bandit with Markov payoffs
independent chains on a common space with a common kernel (no loss of generality: take a disjoint union). Each round, observe all states, play , receive . Only the played chain moves; the others are frozen. Maximise .
ExampleBayesian Bernoulli bandits as Markov chains (Example 35.8)
State = Beta posterior parameters, starting at . Transition to with probability , or to with probability . Reward , the posterior mean. The state is the sufficient statistic and the reward is the posterior expected reward. A product prior makes the chains independent, and a frozen arm’s posterior doesn’t change: exactly the setting above (Exercise 35.8).
TheoremTheorem 35.9 — Gittins index theorem
Under Assumption 35.6 for every chain, the Gittins index policy (ties arbitrary) maximises the expected discounted reward over all policies. For discounted Bayesian bandits with a product prior, it is Bayes optimal.
ProofPrevailing charges and interleavings
Notation: the prevailing charge of arm is , the lowest index seen so far, which is non-increasing.
Part 1: Reward ≤ prevailing charge, with equality for Gittins. For each arm , . Split arm ‘s plays into excursions that start whenever its index drops to a new low . During an excursion, , so by Lemma 35.7(b), . Summing over the excursion telescopes (frozen chains make consecutive plays of arm consecutive states), and since and , each excursion contributes at most 0. The Gittins policy plays each excursion to completion, exactly the optimal stopping time of Lemma 35.7(c), so its contribution is exactly 0.
Part 2: Interleaving decreasing sequences. Let , arm ‘s prevailing charge after of its own plays. Its law doesn’t depend on the policy, and each is decreasing. Any policy collects the interleaving , and by Hardy–Littlewood (Lemma 35.10) the discounted sum of an interleaving of decreasing sequences is maximised by greedily taking the largest available head. For Gittins, . For any , , the same value.
∎
IntuitionWhy an index can be optimal
Each arm can be summarised by a single “fair price per unit of discounted time”. Because discounting is geometric and idle arms are frozen, an arm’s future value stream doesn’t depend on when you play it, only on the order. Greedily playing the highest prevailing charge then maximises the discounted sum, by the rearrangement inequality.
WarningThe index theorem is brittle (Notes 6, 9)
- Geometric discounting is essential. With a non-exponential , an arm’s index can change while you play other arms, which breaks the interleaving argument, and the optimal policy needn’t be an index policy.
- Multiple plays per round: the theorem fails.
- Restless bandits (all chains move, Whittle 1988): not index-optimal in general.
- Finite horizon, no discounting: generally intractable. This is widely believed, though no lower bound on the complexity is known. Small cases are feasible: , Beta–Bernoulli is about states, storable on disk, which may be worth it in mission-critical applications.
- Prior misspecification: Bayesian methods exploit their assumptions fully, which makes them brittle when the prior is wrong. Overly aggressive confidence is very costly in bandits.
RemarkDiscounting
Discounting models time preference (pizza tomorrow beats pizza next year), formalised by Samuelson (1937), who himself doubted its normative and descriptive value. It is rare in frequentist bandits but common in reinforcement learning, where it brings technical advantages. Discounted Markov-payoff bandits are special discounted MDPs (Chapter 38).
Computing the Gittins index: Varaiya’s algorithm
AlgorithmVaraiya’s algorithm (finite state space)
With transition matrix , reward vector , and for a continuation set , . By Lemma 35.7(c), state ‘s optimal stopping time stops on leaving the continuation region , so
Compute indices in decreasing order:
- the top state is , with (stop after one step);
- given the set of the states with the largest indices, the next is , and that ratio is its index.
Cost with Gauss–Jordan elimination. For moderate , truncating the sums (and pruning states unreachable before discounting makes them irrelevant) works well. Infinite state spaces are often discretised using their topology. Better algorithms exist (Chakravorty–Mahajan survey; Niño-Mora; Sonin), as do continuous-time and free-boundary approximations.
RemarkHistory
The first fully Bayesian analysis is the finite-horizon one-armed bandit by backwards induction (Bradt et al. 1956). The Gittins index appeared in 1979, with at least four proofs: Gittins, Whittle (1980), Weber (1992), Tsitsiklis (1994), surveyed by Frostig–Weiss (1999). Books: Gittins et al. (2011), Berry–Fristedt (1985, full of counterintuitive exact-Bayes results), Presman–Sonin (1990). Burnetas and Katehakis (2003) showed Bayes-optimal one-armed rules are asymptotically frequentist-style retirement rules.
Quick reference
| Object | Statement | Note |
|---|---|---|
| Admissible | not dominated | Bayes-optimal (unique / full support) ⇒ admissible |
| Pareto ⇒ Bayes | finite , convex loss set | supporting hyperplane = prior |
| Posterior existence | regular conditional distribution | Borel ; unique a.e. |
| Posterior density | defines a version | |
| Non-uniqueness | arbitrary on prior-null sets | matters for frequentist use |
| Gaussian conjugate | precisions add; precision-weighted means | |
| Beta–Bernoulli | unique | |
| Exponential family | ; conjugate | KL = Bregman of |
| Bandit posterior | policy cancels | |
| Bayesian regret | weaker than frequentist bounds | |
| Worst prior | Sion | |
| Rates | ; fixed : ; regular : | |
| Snell envelope | stop at | |
| Wald–Bellman | Markov stopping | |
| One-armed | retirement = optimal stopping; recursion | Bernoulli |
| Gittins index | fair charge | |
| Index theorem | optimal | geometric discount, frozen arms |
| Varaiya |
Facts to keep to hand
- The Bayesian move puts the environment in the probability space. The prior trades off environments, and Bayes rules are (nearly) the admissible ones. The least favourable prior’s Bayes regret equals the minimax regret.
- Posteriors need care, but rarely bite. Regular conditional distributions guarantee existence and densities give formulas. Non-uniqueness on null sets only matters when a frequentist analyses a fixed environment. Conjugate families (exponential families, with KL = Bregman of ) keep posteriors finite dimensional.
- Bayesian regret is an average, not a guarantee. It is for any prior and about for regular ones, but it bounds no individual instance. Bayesian algorithms deserve frequentist analysis.
- Bayes optimality is dynamic programming. One-armed problems are optimal stopping on sufficient statistics: exact for Beta–Bernoulli, approximate for Gaussians. Many arms are intractable, except that geometric discounting with frozen arms collapses everything to per-arm Gittins indices, by an interleaving (rearrangement) argument.
References
- Lattimore & Szepesvári, Bandit Algorithms — Chapters 34–35
- Ghosal & van der Vaart, Fundamentals of Nonparametric Bayesian Inference (2017) — rigorous posteriors
- Gittins, Glazebrook & Weber, Multi-armed Bandit Allocation Indices (2011)
- Peskir & Shiryaev, Optimal Stopping and Free-Boundary Problems (2006)