5.1.6 · D4Reinforcement Learning Foundations

Exercises — Discount factor and returns

3,077 words14 min readBack to topic

Level 1 — Recognition

Can you read the definition and pick out the right pieces?

Recall Solution 1.1

What we do: apply the definition with .

The reward that follows the action at is not . Plugging : Why: the action at time causes the reward ; the reward you already collected getting to is history and never appears in .

Recall Solution 1.2

What we do: compare each against the endpoints and (recall the allowed range ).

  • (a) myopic. Every with is , so only survives.
  • (b) far-sighted. Weights decay only per step, so rewards ~1000 steps out still count.
  • (c) myopic-ish (short-sighted). Weight halves each step; by step 4 it's already .

Level 2 — Application

Plug numbers into the formulas correctly.

Recall Solution 2.1

What we do: factor the constant out; it becomes a pure geometric series (allowed since ). Why: constant reward gives . Notice an infinite stream of 's is worth only — discounting tames infinity into a finite number.

Recall Solution 2.2

What we do: the return is always the infinite sum, but here every reward from onward is , so the infinite tail contributes nothing and truncation is exact: The zero-tail adds nothing, so we keep only the four non-zero terms: Why: the exponent counts steps into the future: gets , gets , and so on. The reward that arrives two steps late is worth only now. The infinite sum notation is still correct — a terminating episode is just an infinite tail of zeros.

Recall Solution 2.3

What we do: start from the end (where ) and fold inward. This is exactly how TD / dynamic programming propagate values.

  • Why: the recursion needs a terminal to launch — without it there is no place to start folding. The answer matches 2.2, as it must.
Recall Solution 2.4

What we do: apply the definition. With every weight , so the return is the plain undiscounted sum of the four rewards: This is finite and well-defined because the episode stops after terms — the infinite tail is all zeros, so causes no divergence. Why it's safe: the danger of is only an infinite number of non-zero terms; a guaranteed-terminating episode has finitely many, so no blow-up. With : Comment: discounting () shrinks the return from to by fading later rewards; treats all four rewards as equally valuable. On a terminating episode both are legitimate — is the "no time-preference" choice.


Level 3 — Analysis

Reason about behaviour, bounds, and horizons.

Recall Solution 3.1

What we do: use with (recall = largest reward magnitude). As : . Why: the denominator , so the bound explodes — long horizons (large ) can let returns grow without limit in continuing tasks (tasks that never terminate). This is the mathematical reason we usually keep .

Recall Solution 3.2

What we do: plug into both formulas. The mean step is the honest average look-ahead: the average of under the normalized weights (defined just above). People quote the weight scale because it's the total (un-normalized) weight and is one larger; the two nearly coincide as . Why: the mean sits one below the scale because .

Recall Solution 3.3

What we do: constant-reward formula .

  • Future A (): ; . Raising increases it.
  • Future B (): ; . Raising decreases it (more negative). Why: amplifies whatever the future is. For positive futures bigger helps; for penalty-laden futures it hurts. "Bigger = bigger return" is only true when the future is positive.

Return to figure s01 at the top of the page: each blue bar there is one discount weight . Exercise 3.2's weight scale is the total blue area, while the mean step is the balance point (green dotted line) of that area — the average once the bars are normalized into a probability distribution. Seeing area-vs-balance-point side by side is exactly why the two horizon numbers differ by one.


Level 4 — Synthesis

Combine multiple pieces; solve inverse problems.

Recall Solution 4.1

What we do: invert . Why: the return-to-reward ratio directly reveals the horizon scale, and (safely inside ).

Recall Solution 4.2

What we do: substitute the reward into the return and recognise a geometric series with ratio . Why: two multiplicative factors per step ( from discounting, from reward growth) merge into a single ratio ; convergence needs . Numbers: , so Sanity: makes rewards grow, so exceeds the constant-reward value . Good.

Recall Solution 4.3

What we do: apply the definition, four non-zero terms then a zero-tail (episode terminates). Compute: ; and , so . Why: even though the jackpot is discounted to (down from ), it dwarfs the small early penalties. Entering is worth it. The lesson: delay shrinks a reward but a big enough reward still dominates.


Level 5 — Mastery

Prove, generalise, and defend design choices.

Recall Solution 5.1

What we do: split off the term, then factor from the rest. Re-index the tail with (so , and runs ): Therefore . Why: the tail is exactly the return starting one step later, scaled by one factor of . This self-reference is the seed of every Bellman equation.

Recall Solution 5.2

Step 1 — valid distribution. ✓ (uses the Geometric series sum, valid because ; the is exactly the normalizer built in Exercise 3.2). Step 2 — the mean. Why: we used the standard identity ; the normalizer cancels one power of , leaving — one less than the scale .

Recall Solution 5.3

The danger of : in a continuing task (one with no terminal state) the sum has infinitely many terms; with the bound is undefined and can diverge to . is only safe when termination is guaranteed (an episodic task, as in Exercise 2.4). This is why the allowed range on this page is . Choosing : require , i.e. . So any (e.g. ) caps . Why: the bound is monotone in ; solving the inequality gives the ceiling on that keeps returns tame. Turning the maximisation of into a well-posed objective is exactly what the Reward hypothesis (all goals = maximising expected cumulative reward) needs.


Recap

Recall One-line summary of every tool used

(return) ::: total discounted future reward, with . ::: recursion, needs terminal to unfold. ::: weight scale (total of all discount weights) / horizon. ::: true mean look-ahead (one less than the scale). ::: return is finite for . on a terminating episode ::: legal — the plain undiscounted sum of finitely many rewards.