Two Bernoulli arms start with uniform priors. Arm A has been pulled times with successes and failure. Arm B has been pulled once with success. Give each arm's posterior, mean and variance. What is the probability that Thompson sampling picks B next? Why is this different from a greedy choice?
Reinforcement learning, Multi-armed bandits
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you can update Beta posteriors and see that Thompson sampling explores in proportion to the chance that an arm is best.
Key idea
With a prior and successes and failures, the posterior is . Thompson sampling draws one sample from each arm's posterior and plays the arm with the largest sample. So it picks each arm with the probability that the arm is the best under the posterior.
Steps
- Posterior for A: . Posterior for B: .
- Means : A has and B has . They are equal, so a greedy agent has no preference between them.
- Variances : A has and B has . B is more uncertain.
- Probability that B is picked: . The density of is , so . Hence .
- For , . So .
- Interpret: B is picked slightly more than half the time because its posterior is wider and can give a high sample. Exploration is automatic and shrinks as the posteriors narrow.
Common mistakes
- Using the posterior mean as the sample. That is the greedy choice, with no exploration.
- Updating the posterior of an arm that was not pulled. Only the pulled arm's posterior changes after an observation.
- Forgetting the prior. adds one pseudo-success and one pseudo-failure to the counts.
How long your answer should be
Half a page; 5 minutes.
Last checked on 4 December 2026.
Read this
Previous in Reinforcement learning: A trajectory of three steps has rewards and critic values . The episode ends after step 3, so the next value is . With and , what are the TD errors and the generalised advantage estimates ?
Next in Reinforcement learning: A linear value function is with . The agent moves from to with , where and . With and , compute the semi-gradient TD(0) update, and compare with the residual-gradient update. Why is TD(0) called a "semi-gradient" method?