Compute a discounted three-step return

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

A return is the value of a sequence of future rewards. Reinforcement learning often discounts this value because a reward received now is generally more useful than the same reward received later. The discount factor, written gamma, is between 0 and 1. Consider a travel app that chooses whether to offer a traveler an earlier train. After three actions, it receives rewards 4, 2, and 1. The immediate reward is 4, while the three-step return includes all three rewards, with later rewards discounted more heavily.

For rewards R1, R2, and R3, the discounted three-step return is G = R1 + gamma R2 + gamma^2 R3. The exponent grows because a reward two steps ahead is discounted twice. With gamma = 0.5, G = 4 + 0.5(2) + 0.5^2(1) = 4 + 1 + 0.25 = 5.25. The undiscounted sum is 7. With gamma = 0.9, the return becomes 4 + 1.8 + 0.81 = 6.61. A smaller gamma gives distant outcomes less influence. A larger gamma gives them more influence.

Check your recall

Using gamma = 0.5, what is the discounted three-step return for rewards 4, 2, and 1?

Check your answer

G = 4 + 0.5(2) + 0.5^2(1) = 4 + 1 + 0.25 = 5.25.

Sources and credits

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