One episode with visits states A, B, A, C in that order and then ends. The rewards received after leaving each state are respectively. What are the returns from each time step and the first-visit and every-visit Monte Carlo estimates of , and 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 as the average of observed returns after visits to . First-visit uses only the first visit to in each episode. Every-visit uses all visits.
Steps
- List the time steps: is A with reward , is B with reward , is A with reward , is C with reward . After the episode ends.
- Work backwards with : , , , .
- First-visit for A: only counts, so .
- Every-visit for A: average of and , so .
- B and C are visited once, so both methods agree: and .
- Add the remark that both estimates converge to 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
- Dividing the return by the episode length instead of averaging the returns of the visits.
- Using for the second visit of A. The return includes the later reward of , discounted.
- Updating before the episode ends. Monte Carlo needs complete episodes to know the returns.
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 and ends at G. Right from A gives reward and moves to B. Start with everywhere, , . The agent experiences and then , each with one Q-learning update, and stores them in a model. Then Dyna-Q does two planning updates, replaying first and second. What are and after each stage, and what did planning achieve?
Next in Reinforcement learning: In state there are three actions with and the policy is -greedy with (random choice uniform over all three actions). The agent took action in with , got , and moved to . With and , compute the Expected SARSA update. How does it compare to SARSA and Q-learning, and why does it have lower variance than SARSA?