In state s′ there are three actions with Q(s′,⋅)=(2,4,1) and the policy is ε-greedy with ε=0.1 (random choice uniform over all three actions). The agent took action a in s with Q(s,a)=3, got r=1, and moved to s′. With α=0.5 and γ=0.9, compute the Expected SARSA update. How does it compare to SARSA and Q-learning, and why does it have lower variance than SARSA?

Reinforcement learning, Temporal-difference learning
Level L2 Elementary. Length Medium. Nature Th+Mat Both.

What's being asked

Whether you can compute the expectation of Q under the policy and explain how it removes the randomness of the sampled next action.

Key idea

Expected SARSA uses the target r+γ∑a′π(a′∣s′) Q(s′,a′). It takes the exact expectation over the next action instead of sampling one action, so it keeps SARSA's policy but removes the variance from the next-action choice.

Steps

  1. Find the policy probabilities. The greedy action has probability 1−0.1+0.1/3=0.9333 and each other action has 0.0333.
  2. Compute the expected next value: 0.9333×4+0.0333×(2+1)=3.7333+0.1=3.8333.
  3. Target: 1+0.9×3.8333=4.45. Update: Q(s,a)=3+0.5 (4.45−3)=3.725.
  4. Compare with SARSA. Its target is 1+0.9 Q(s′,a′) with the sampled a′. This equals 4.6 if the greedy action is sampled, 2.8 for the first action and 1.9 for the third. Its average is 4.45, but individual updates vary a lot.
  5. Compare with Q-learning: the target is 1+0.9×4=4.6, which assumes a greedy next action.
  6. Explain variance. SARSA's target has the extra randomness of which a′ is drawn, and Expected SARSA averages this out analytically. The cost is one extra sum over actions per update. With ε→0 it becomes Q-learning.

Common mistakes

How long your answer should be

Half a page; 4–5 minutes.

Read this

Previous in Reinforcement learning: One episode with γ=0.5 visits states A, B, A, C in that order and then ends. The rewards received after leaving each state are 2,0,4,−1 respectively. What are the returns from each time step and the first-visit and every-visit Monte Carlo estimates of V(A), V(B) and V(C) from this single episode?
Next in Reinforcement learning: An episode has rewards r1=1, r2=2, r3=0, r4=3 and then ends, with γ=0.9. The current estimates are V(S1)=6, V(S2)=5 and V(S3)=4. What are the n-step returns G0(n) for n=1,2,3,4, and how does n trade off bias and variance?