← Back to Reinforcement Learning Mind Map
🎮 Reinforcement LearningID: thompson-sampling

Thompson Sampling

Thompson 采样
🎯Core Definition
Thompson Sampling (TS, probability matching) is a Bayesian exploration algorithm: maintain a posterior over each arm's mean reward; each round sample θa∼Beta(αa+wa,βa+la)\theta_a \sim \text{Beta}(\alpha_a + w_a, \beta_a + l_a) (Beta is the conjugate prior for Bernoulli rewards, waw_a/lal_a being arm aa's cumulative wins/losses) and play the arm with the largest sample. It plays each arm with probability equal to its posterior probability of being optimal — wider (more uncertain) posteriors get explored more, yielding a natural exploration-exploitation trade-off.
💡Use Cases
a default choice for online decisions in industry (ads, recsys, experimentation platforms) for its simplicity, sample efficiency, and empirical edge over UCB; interviews often ask for the Beta posterior update and conjugacy.
⚡Key Problems Solved
UCB's confidence bound is a frequentist construction that underuses priors/reward structure; TS encodes uncertainty directly into selection probabilities via posterior sampling, achieves O(ln⁡T)O(\ln T) regret with strong worst-case guarantees, is more robust to non-stationary rewards, and extends naturally to contextual features (Linear/Logistic TS).
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of Thompson Sampling.
Use Cases
In production engineering, what are the primary use cases for Thompson Sampling and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
1
Derive the Beta posterior: prior Beta(α,β)\text{Beta}(\alpha, \beta) + Bernoulli observations → Beta(α+w,β+l)\text{Beta}(\alpha + w, \beta + l)?
2
Numerical: prior Beta(1,1)\text{Beta}(1,1); arm1 has 8 wins/2 losses, arm2 3 wins/7 losses — write both posteriors and argue which arm the next sample favors.
3
TS vs UCB regret: why does TS often perform better in practice?
4
How does TS degrade under non-stationary rewards, and what fixes exist?
5
The probability-matching property: play probability equals posterior probability of optimality — what does it imply for exploration?
Updated 2026-08-12
🎯
Verify Mastery: Practice Exam Questions for "Thompson Sampling"
Take pitfall multiple-choice questions with derivation options; mistakes are automatically logged.
🚀 Start Card Practice ➔
← Previous CardUCB1 (Upper Confidence Bound)Next Card →Contextual Bandit

🔗 More Reinforcement Learning Knowledge Cards

引用出处: TalentMe 450+ 工业级 AI 架构考点知识库 (Tech Vault) · 遵循 CC-BY-4.0 知识共享协议
URL: https://talentme.airsota.com/resources/tech/roadmap/mindmap/RL/card/thompson-sampling
中文速览与面试要点

Thompson 采样 (Thompson Sampling)

定义: Thompson 采样 (TS, 概率匹配) 是贝叶斯探索算法:为每个臂维护奖励的后验分布,每轮从后验中采样 _a Beta( _a + w_a, _a + l_a)(Bernoulli 奖励下 Beta 先验是共轭先验,w_a/l_a 为臂 a 的累计胜/负次数),然后选择采样值最大的臂。以"当前后验下该臂是最优"的概率选臂 (probability matching):后验越宽(越不确定)的臂越可能被选,天然实现探索-利用权衡。 使用场景: 工业界在线决策的默认算法之一(广告、推荐、实验平台),因为实现简单、样本效率高、实际表现常优于 UCB;面试常考 Beta 后验更新公式与共轭原理。 解决的问题: UCB 的置信上界是频率派构造,对先验知识/奖励分布利用不足;TS 通过后验采样把不确定性直接编码进选择概率,regret 可达 O( T)(最坏情形亦有良好保证),对非平稳奖励 (drifting) 更鲁棒,且能自然扩展到上下文特征 (Linear/Logistic TS)。

核心要点

  • 推导 Beta 后验:先验 Beta( , ) + Bernoulli 观察 → 后验 Beta( + w, + l)?
  • 数值题:先验 Beta(1,1), 臂1 赢 8 输 2、臂2 赢 3 输 7, 写出两个后验并说明下一次采样更可能选哪个臂?
  • TS 与 UCB 的 regret 对比?为什么工业界 TS 实际表现常更好?
  • 非平稳环境 (奖励漂移) 下 TS 如何退化?有哪些修正?
  • probability matching 性质:选臂概率 = 该臂为最优的后验概率, 这对探索意味着什么?