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 sequential decision policy for bandits and related online-learning problems. It represents uncertainty about reward-model parameters with a posterior distribution, samples one plausible parameter setting, and chooses the action with highest expected reward under that sample.

Equivalently, each action is selected with the posterior probability that it is optimal. Poorly known actions are explored when sampled beliefs make them look best; actions with strong evidence of high reward are exploited more often. New context–action–reward observations update the posterior before later decisions.

The policy’s simplicity hides important modeling choices: likelihood and prior, contextual features, nonstationarity, delayed outcomes, and the accuracy of approximate posterior sampling. Its randomization is epistemic rather than arbitrary—the distribution of actions is coupled to uncertainty about optimality.

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.

Structural Signature

Sig role-phrases:

  • Reward model and prior. Represents uncertain expected outcomes of actions, optionally conditioned on context. Constitutive Bayesian belief model. If altered: Without a prior and likelihood the policy is no longer Thompson sampling in its standard form.
  • Observed action–reward history. Updates the parameter posterior using evidence gathered through interaction. Constitutive learning state. If altered: Ignoring new outcomes prevents uncertainty from contracting and policy behavior from adapting.
  • Posterior sample. Draws one plausible parameter realization at each decision round. Identity-bearing randomization. If altered: Using only the posterior mean becomes a greedy Bayesian policy rather than probability matching.
  • Sample-optimal action. Maximizes expected reward under the sampled model and current context. Identity-bearing decision rule. If altered: Sampling an action without solving the sampled decision problem breaks the posterior optimality relation.

What It Is Not

  • Not uniform exploration. Actions are randomized according to posterior plausibility, not equal chance.
  • Not posterior-mean greediness. The policy samples a model rather than optimizing only average expected rewards.
  • Not generic probability matching. Class base-rate prediction lacks the sequential reward posterior and optimal-action event.
  • Not UCB. UCB adds deterministic optimism bonuses instead of drawing posterior models.

Scope of Application

The policy applies to repeated decisions with observable feedback and a probabilistic model linking contexts and actions to rewards.

  • 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.

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.

Abstract Reasoning

  1. Define a reward model and prior that reflect the action and context structure.
  2. Update the posterior from observed context–action–reward tuples without treating chosen actions as exogenous evidence about the environment.
  3. Draw a parameter or model realization from the current posterior.
  4. Choose the action maximizing expected reward under that realization.
  5. Monitor calibration, regret, nonstationarity, and approximation error as data accumulate.

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.

Examples

Canonical

For two Bernoulli website variants with Beta posteriors, the system samples one conversion rate for each and displays the variant with the larger sampled rate.

Mapped back: reward model and prior → Beta–Bernoulli rates; observed action–reward history → impressions and conversions; posterior sample → one rate per variant; sample-optimal action → show the larger draw.

Applied / In Practice

A contextual recommender samples its posterior model coefficients for the current user and selects the item with greatest sampled expected engagement.

Mapped back: reward model and prior → contextual reward model; observed action–reward history → past user-item outcomes; posterior sample → sampled coefficient vector; sample-optimal action → highest predicted item.

Structural Tensions

T1: exploration vs. exploitation. Uncertain actions receive trials in proportion to their posterior chance of being best. Diagnostic: Does the posterior represent uncertainty well enough to allocate exploration?

T2: model fidelity vs. online tractability. Rich reward models improve representation but make posterior sampling costly. Diagnostic: What approximation error changes action probabilities?

T3: adaptive reward vs. causal evaluation. The policy’s own choices determine which outcomes are observed. Diagnostic: How are selection and delayed feedback handled in evaluation?

Structural–Framed Character

Thompson sampling is strongly structural and decision-framed. Evaluative weight: cumulative reward and regret define performance. Human-practice-bound: model, prior, reward, and constraints are chosen. Institutional origin: Bayesian statistics and online learning stabilize it. Vocabulary travels: posterior sampling and optimization travel. Import versus recognize: literal use requires sample-optimal Bayesian action. Its character: uncertainty-calibrated randomization through sampled optimal worlds.

Structural Core vs. Domain Accent

Skeletal core. Sample one plausible state of the uncertain environment and act optimally as if that state were true.

Domain-bound accent. Beliefs are Bayesian reward-model posteriors, actions form a bandit decision, and feedback updates future allocation.

Why not prime. Sampling under uncertainty is portable, but the named policy is a specific sequential Bayesian decision rule.

This entry is a kind of Algorithm.

  • Sampling. A posterior draw realizes one plausible reward model.
  • Updating. Feedback revises the belief state.
  • Optimization. Each sampled model induces a best action.
  • The approved root remains.

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

Not to Be Confused With

  • Upper confidence bound. Tell: UCB chooses optimistic bounds rather than a sampled posterior model.
  • Epsilon-greedy. Tell: Its exploration probability is externally scheduled rather than posterior-matched.
  • Probability matching in classification. Tell: Matching class base rates lacks sequential reward learning.
  • Bayesian model averaging. Tell: Averaging predictions differs from sampling one model and optimizing it.

References

  • Frozen Wikipedia discovery revision: https://en.wikipedia.org/wiki/Thompson_sampling (revision 1362198073).