Apply one TD(0) update to a state-value array. First compute the temporal-difference error:
δ=r+γV(snext)−V(s)Then update only the current state:
Vnew(s)=V(s)+αδHere, r is the observed reward, γ is the discount factor, and α is the learning rate. Do not modify the input. Return the updated values as a NumPy array.
Input: V = [0, 0, 0], s = 0, r = 1, s_next = 1, alpha = 0.5, gamma = 0.9
Output: [0.5, 0, 0]
Explanation: The next-state estimate is zero, so the TD target is 1 and the halfway update sets V(0) to 0.5.
Input: V = [0.2, 0.8], s = 0, r = 0, s_next = 1, alpha = 1.0, gamma = 0.5
Output: [0.4, 0.8]
Compute target = r + gamma * values[s_next].
Copy with np.asarray(V, dtype=float).copy() before updating index s.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number
Accepts: number
Accepts: number
Accepts: number
Apply one TD(0) update to a state-value array. First compute the temporal-difference error:
δ=r+γV(snext)−V(s)Then update only the current state:
Vnew(s)=V(s)+αδHere, r is the observed reward, γ is the discount factor, and α is the learning rate. Do not modify the input. Return the updated values as a NumPy array.
Input: V = [0, 0, 0], s = 0, r = 1, s_next = 1, alpha = 0.5, gamma = 0.9
Output: [0.5, 0, 0]
Explanation: The next-state estimate is zero, so the TD target is 1 and the halfway update sets V(0) to 0.5.
Input: V = [0.2, 0.8], s = 0, r = 0, s_next = 1, alpha = 1.0, gamma = 0.5
Output: [0.4, 0.8]
Compute target = r + gamma * values[s_next].
Copy with np.asarray(V, dtype=float).copy() before updating index s.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number
Accepts: number
Accepts: number
Accepts: number