Two Bernoulli arms start with uniform Beta(1,1) priors. Arm A has been pulled 4 times with 3 successes and 1 failure. Arm B has been pulled once with 1 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 Beta(α,β) prior and s successes and f failures, the posterior is Beta(α+s,β+f). 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

  1. Posterior for A: Beta(1+3,1+1)=Beta(4,2). Posterior for B: Beta(1+1,1+0)=Beta(2,1).
  2. Means α/(α+β): A has 4/6=0.667 and B has 2/3=0.667. They are equal, so a greedy agent has no preference between them.
  3. Variances αβ/((α+β)2(α+β+1)): A has 8/(36×7)=0.0317 and B has 2/(9×4)=0.0556. B is more uncertain.
  4. Probability that B is picked: P(θB>θA). The density of θB is 2x, so P(θB>a)=1−a2. Hence P=1−E[θA2].
  5. For Beta(4,2), E[θ2]=4×56×7=2042=0.476. So P(pick B)=1−0.476=0.524.
  6. 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

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 (1,0,2) and critic values V(s0),V(s1),V(s2)=(3,2,1). The episode ends after step 3, so the next value is 0. With γ=0.9 and λ=0.5, what are the TD errors and the generalised advantage estimates A^0,A^1,A^2?
Next in Reinforcement learning: A linear value function is V^(s)=w⊤ϕ(s) with w=(1,0)⊤. The agent moves from s to s′ with r=2, where ϕ(s)=(1,2)⊤ and ϕ(s′)=(0,1)⊤. With γ=0.9 and α=0.1, compute the semi-gradient TD(0) update, and compare with the residual-gradient update. Why is TD(0) called a "semi-gradient" method?