Compute a one-step temporal difference error

Keep each reward, discount and value next to its number. · 186 words

A temporal difference (TD) error measures how surprising a reward and next state are compared with the agent's current value estimate. The value V(s) predicts discounted future reward from state s. The TD target is r + gamma V(s'), where r is the immediate reward, s' is the next state, and gamma discounts distant rewards. For a museum robot, r=2 points for returning a book, gamma=0.9, V(s)=5, and V(s')=6. Its target is 2 + 0.9(6) = 7.4, so delta = 7.4 - 5 = 2.4. The positive error means the outcome was better than predicted.

To learn, use the update V(s) <- V(s) + alpha delta, where alpha is the learning rate. With alpha=0.1, the robot's estimate becomes 5 + 0.1(2.4) = 5.24. This method is one-step because it uses the reward now and an estimate for the next state rather than waiting for the whole episode. Compare a tour bus with r=-1 for a late arrival, gamma=0.9, V(s)=4, and V(s')=3. Here delta = -1 + 0.9(3) - 4 = -2.3. The negative error means the trip was worse than predicted, so the estimate should decrease.

Check your recall

In the museum robot example, what are the TD target, TD error, and updated value after one update with alpha=0.1?

Check your answer

The TD target is 7.4, the TD error is 2.4, and the updated value is 5.24.

Sources and credits

Original KeyTouch lesson. Background reading · UC Berkeley · Introduction to Artificial Intelligence.