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?

Reinforcement learning, Monte Carlo methods
Level L2 Elementary. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can compute returns of an episode and know how first-visit and every-visit Monte Carlo differ when a state repeats.

Key idea

Monte Carlo estimates V(s) as the average of observed returns Gt after visits to s. First-visit uses only the first visit to s in each episode. Every-visit uses all visits.

Steps

  1. List the time steps: t=0 is A with reward 2, t=1 is B with reward 0, t=2 is A with reward 4, t=3 is C with reward −1. After t=3 the episode ends.
  2. Work backwards with Gt=rt+1+γGt+1: G3=−1, G2=4+0.5×(−1)=3.5, G1=0+0.5×3.5=1.75, G0=2+0.5×1.75=2.875.
  3. First-visit for A: only t=0 counts, so V(A)=G0=2.875.
  4. Every-visit for A: average of t=0 and t=2, so V(A)=(2.875+3.5)/2=3.1875.
  5. B and C are visited once, so both methods agree: V(B)=1.75 and V(C)=−1.
  6. Add the remark that both estimates converge to V(s) as the number of episodes grows. First-visit returns are independent across episodes, so that estimate is unbiased. Every-visit returns from one episode are correlated, so that estimate is biased but still consistent.

Common mistakes

How long your answer should be

A small table of returns, then the estimates; about 3 minutes.

Last checked on 4 December 2026.

Read this

Previous in Reinforcement learning: A deterministic world has a terminal goal G and two states A and B, each with one action, "right". Right from B gives reward 1 and ends at G. Right from A gives reward 0 and moves to B. Start with Q=0 everywhere, α=0.5, γ=0.9. The agent experiences (B,right,1,G) and then (A,right,0,B), each with one Q-learning update, and stores them in a model. Then Dyna-Q does two planning updates, replaying (B,right) first and (A,right) second. What are Q(A,right) and Q(B,right) after each stage, and what did planning achieve?
Next in Reinforcement learning: 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?