Skip to content

Thompson Sampling

A Bayesian bandit policy that samples a plausible reward model from the current posterior and chooses the action optimal under that sample, thereby probability-matching exploration to uncertainty.

Core Idea

Thompson sampling is a Bayesian policy for sequential decisions under uncertain rewards. At each round it samples one plausible reward model from the current posterior, then chooses the action with the highest expected reward under that sample; this makes action frequencies track the posterior chance of being optimal. Equivalently, each action is selected with the posterior probability that it is optimal. Equivalently, each action is selected with the posterior probability that it is optimal.

How would you explain it like I'm…

Imagine-and-Pick Game

Imagine a row of toy machines that give out stickers, and you don't know which gives the most. Each turn, you make a guess about how good each machine is, using what you've seen so far, and play the one your guess says is best. Machines you're unsure about sometimes get picked, so you keep learning, but the ones that clearly work well get picked most.

Choosing by Imagining What's Best

Thompson sampling is a smart way to choose between options when you're not sure which is best, like picking which of several game machines pays out most. You keep track of what you believe about each option, including how unsure you are. Each turn, you randomly imagine one possible version of the truth based on those beliefs, then pick the option that would be best in that imagined version. After seeing the result, you update your beliefs. Options you know little about get tried sometimes, while options proven to be good get chosen most often.

Posterior Sampling for Bandits

Thompson sampling is a Bayesian strategy for repeated decisions, such as 'multi-armed bandit' problems where you choose among options with unknown payoffs. It keeps a posterior distribution, a probability description of what the reward parameters might be given the data so far. At each step it draws one sample from that distribution, treats it as if it were true, and picks the action with the highest expected reward under it. This is the same as choosing each action with the probability that it's actually the best one. So uncertain options get explored when a sample makes them look good, while options with strong evidence get exploited more often. The randomness isn't arbitrary; it reflects genuine uncertainty, and results depend on modeling choices like the prior and likelihood.

 

Thompson sampling is a Bayesian sequential decision policy for bandit and related online-learning problems. It represents uncertainty about reward-model parameters with a posterior distribution; at each round it samples one plausible parameter setting from the posterior and selects the action with the highest expected reward under that sample. Equivalently, each action is chosen with the posterior probability that it is optimal. This couples exploration to uncertainty: poorly known actions are tried when sampled beliefs make them look best, while actions with strong evidence of high reward are exploited more often. Each new context-action-reward observation updates the posterior before subsequent decisions. Its apparent simplicity conceals consequential modeling choices: the likelihood and prior, contextual features, nonstationarity, delayed outcomes, and the fidelity of approximate posterior sampling. The randomization is epistemic, distributing choices according to uncertainty about optimality, rather than arbitrary noise.

Scope of Application

The policy applies to repeated decisions with observable feedback and a probabilistic model linking contexts and actions to rewards. The policy applies to repeated choices where contexts, actions, rewards, and a posterior update can be specified.

  • Multi-armed bandits. Uncertain arm reward rates are learned while rewards accumulate.
  • Contextual recommendation. Posterior models condition expected reward on user or situation features.
  • Online experiments. Traffic allocation shifts toward better variants while retaining uncertainty-driven exploration.
  • Advertising. Creative or bid choices learn from sequential response.
  • Approximate Bayesian control. Sampling methods make complex posterior models usable online.

Clarity

Specify the reward, horizon, action set, context, likelihood, prior, posterior-update rule, and sampling approximation. Distinguish Bayesian regret claims from frequentist guarantees and check whether feedback is delayed, censored, nonstationary, or action-dependent. Report randomized allocation when evaluating outcomes. The closest near miss sets the boundary: Upper-confidence-bound selection is the closest near miss: it explores actions with optimistic confidence bonuses rather than sampling a plausible model and acting optimally within it.

Manages Complexity

One posterior sample converts a difficult integration over all possible models into an ordinary optimization under one plausible world. Repetition automatically directs effort toward actions that are both promising and uncertain, coupling inference and control without a separate exploration schedule. The central exploration–exploitation tradeoff is this: Uncertain actions receive trials in proportion to their posterior chance of being best. A second model fidelity–online tractability tension matters because Rich reward models improve representation but make posterior sampling costly.

Abstract Reasoning

Use three linked moves: define a reward model and prior that reflect the action and context structure; update the posterior from observed context–action–reward tuples without treating chosen actions as exogenous evidence about the environment; draw a parameter or model realization from the current posterior. As a collapse test, the case exits when action randomization is not induced by posterior uncertainty about which action is optimal. A fourth check is to choose the action maximizing expected reward under that realization.

Knowledge Transfer

The posterior-sampling policy transfers from Bernoulli bandits to contextual, combinatorial, and some control settings when a coherent model and sample-optimal action can be computed. Randomized choice without posterior optimality is only analogy. No canonical parent prime is currently asserted; broader structural comparisons remain related-prime analogies until separately adjudicated in the DAG. A posterior draw realizes one plausible reward model.

Relationships to Other Abstractions

Local relationship map for Thompson SamplingParents appear above the current abstraction, mutual partners to the right, and children below. Node labels state whether each abstraction is prime or domain-specific; colors identify relation types.Thompson SamplingDOMAINPrime abstraction: Algorithm — is a kind ofAlgorithmPRIME

Current abstraction Thompson Sampling Domain-specific

Parents (1) — outgoing typed relations

  • Thompson Sampling is a kind of Algorithm Prime

    Thompson Sampling is a domain-specific kind of algorithm under its frozen identity and differentia.

Hierarchy path (1) — routes to 1 parentless root

Neighborhood in Abstraction Space

Thompson Sampling sits in a moderately populated region (52nd percentile for distinctiveness): it has near-neighbors but no dense thicket of look-alikes.

Family — Strategic Decision Biases & Mechanisms (29 abstractions)

Nearest neighbors

Computed from structural-signature embeddings · 2026-11-14