Averaging sampled returns
The value of a state is the expected return from it, . An episode that follows and visits at time gives one sample of that return: where is the final time step of the episode. MC prediction estimates by the average of the returns observed after visits to . By the law of large numbers, the average converges to as the number of visits grows (Sutton & Barto, 2018). The name comes from this averaging of random samples.
First-visit and every-visit MC
A state can be visited more than once in the same episode. First-visit MC averages, in each episode, only the return that follows the first visit to . Every-visit MC averages the returns that follow every visit. Both converge to . In first-visit MC the returns from different episodes are independent samples of , so the estimate is unbiased and its standard error falls as with the number of returns.Incremental updates
You do not need to store every return. The mean of numbers follows from the mean of the first : With the return that follows a visit to as the new sample, the estimate is updated after each episode: where counts the returns seen from . With this is the sample average, which weights every return equally. A constant step size gives constant- MC instead. It is an exponentially weighted average that favors recent returns, which helps when the environment changes over time (Sutton & Barto, 2018).Properties of MC prediction
The MC target is unbiased, but its variance can be large. is an unbiased sample of . It is also a sum of every reward until the end of the episode, and each of those rewards is random, so long episodes give noisy targets and need many samples. MC does not bootstrap. Each state’s estimate uses only the returns that followed that state, never the estimate of another state as dynamic programming does. The cost of estimating one state’s value therefore does not grow with the number of states, which makes MC a good fit when you need the values of only a few states. The navigation MDP section uses this property. It estimates the value of a go-to-goal controller on a simulated TurtleBot3 from the returns of rollouts, at a grid of start positions facing the goal, without a table of transition probabilities. MC does not rely on the Markov property. The average of the sampled returns is the right answer whenever the episodes follow . Because MC never uses the estimate at the next state, it is not misled when the state does not summarize the past, for example when the agent’s observation hides part of the true state.Action values
Estimating action values , the expected return after taking in and following afterwards, works the same way, with one average per state-action pair. Action values are what model-free control needs. Improving a policy from requires the dynamics to look one step ahead, while improving it from only requires . Key references: (Sutton & Barto, 2018)References
- Sutton, R., Barto, A. (2018). Reinforcement Learning: An Introduction. Link
Found an error on this page? Report an issue.

