Returns and Episodes
A return combines the rewards after a particular time into one score. An episode is a sequence of interactions that ends, such as one game or one trip to Goal.
Episodic and continuing tasks
Section titled “Episodic and continuing tasks”| Task type | What happens | Examples |
|---|---|---|
| Episodic | The task reaches a terminal state. | A maze attempt, a game, balancing a pole until it falls |
| Continuing | The task has no natural ending. | Thermostat control, ongoing server scheduling |
For an episode ending at time , is terminal and is the last reward. The undiscounted return is:
If rewards continue forever, simply adding them may not produce a finite number. Discounting provides one useful objective for continuing tasks and can also be used in episodic tasks.
Discounted return
Section titled “Discounted return”With discount factor :
- : only the next reward counts.
- : later rewards count, but receive progressively less weight.
- : all rewards count equally, provided the return is well-defined, such as an episode with bounded rewards and a bounded number of steps.
For an infinite discounted sum, bounded rewards and ensure a finite return. The next section explains how the infinite-sum notation also handles episodes.
The timing is easy to misread: has weight 1, has weight , and has weight . With , the third upcoming reward receives weight .
The gridworld route
Section titled “The gridworld route”For Start → Hall → Goal, the rewards are −1 and +5. At :
The first reward is −1, but the return is 3.5. A longer route, Start → B → C → D → Goal, has return:
Both routes reach the same goal. The longer one pays more movement costs and receives the positive reward later.
Compute returns backward
Section titled “Compute returns backward”Separate the next reward from the remaining return:
Suppose , the rewards are , , , , and , and the episode ends at . Start with terminal return and work backward:
| Time | Calculation | Return |
|---|---|---|
| 5 | No rewards remain. | |
| 4 | ||
| 3 | ||
| 2 | ||
| 1 | ||
| 0 |
This recursion avoids repeatedly summing the same future rewards. It also provides the idea behind the Bellman equations in section 3.5.
An infinite reward sequence
Section titled “An infinite reward sequence”Suppose , every reward after that equals 7, and . The geometric-series identity applies for :
One step later, the return includes only the sequence of sevens:
The recursion checks the result: .
Try it
Section titled “Try it”For the two-step gridworld route, change to 0.5. Its return becomes . Then set : the future goal reward disappears from the objective, leaving return −1.
Reference
Section titled “Reference”Sutton, R. S. & Barto, A. G. Reinforcement Learning: An Introduction, 2nd ed., chapter 3, section 3.3. The explanations and small worked examples here are written for these notes.
Previous: 3.2 Goals and Rewards · Next: 3.4 Unified Notation for Episodic and Continuing Tasks