Estimate the value function using Monte Carlo first-visit returns from episode data.
Return from time t:
Gt=rt+γrt+1+γ2rt+2+⋯First-Visit MC Value:
V(s)=average of all first-visit returns for state sepisodes: list of episodes - each episode is list of (state, reward) tuplesgamma: float - discount factorn_states: int - number of states (labeled 0..n_states-1)Input: episodes=[[(0,1),(1,2),(2,3)]], γ=1, n_states=3
Output: V = [6.0, 5.0, 3.0]
Input: episodes=[[(0,1),(0,-5),(0,2)]], γ=1, n_states=1
Output: V = [-2.0] (only first visit counts)
Process each episode backward to compute returns: Gt=rt+γGt+1.
Use a set to track visited states per episode to ensure first-visit only.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number
Estimate the value function using Monte Carlo first-visit returns from episode data.
Return from time t:
Gt=rt+γrt+1+γ2rt+2+⋯First-Visit MC Value:
V(s)=average of all first-visit returns for state sepisodes: list of episodes - each episode is list of (state, reward) tuplesgamma: float - discount factorn_states: int - number of states (labeled 0..n_states-1)Input: episodes=[[(0,1),(1,2),(2,3)]], γ=1, n_states=3
Output: V = [6.0, 5.0, 3.0]
Input: episodes=[[(0,1),(0,-5),(0,2)]], γ=1, n_states=1
Output: V = [-2.0] (only first visit counts)
Process each episode backward to compute returns: Gt=rt+γGt+1.
Use a set to track visited states per episode to ensure first-visit only.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number