5.1.6Reinforcement Learning Foundations

Discount factor and returns

2,267 words10 min readdifficulty · medium1 backlinks

WHAT are we defining?

  • γ=0\gamma = 0myopic agent: only the immediate reward Rt+1R_{t+1} matters.
  • γ1\gamma \to 1far-sighted agent: distant rewards count almost as much as near ones.

WHY do we discount at all?

Three independent reasons, all pointing the same way:

  1. Mathematical convergence. In tasks that never end (continuing tasks), R\sum R could be infinite. Discounting with γ<1\gamma < 1 keeps the sum finite (proved below).
  2. Uncertainty about the future. Think of γ\gamma as a "survival probability" — at each step there's a chance the process stops. Reward you might never live to collect should count less.
  3. Preference / economics. Like interest rates: money (reward) now can be reinvested, so it is genuinely worth more than the same amount later.

HOW: derive the bounded-return result from scratch

Claim: If every reward is bounded, RRmax|R| \le R_{\max}, and 0γ<10 \le \gamma < 1, then GtG_t is finite.

Step 1 — Bound each term. Gt=k=0γkRt+k+1k=0γkRt+k+1k=0γkRmax|G_t| = \left|\sum_{k=0}^{\infty}\gamma^k R_{t+k+1}\right| \le \sum_{k=0}^{\infty}\gamma^k |R_{t+k+1}| \le \sum_{k=0}^{\infty}\gamma^k R_{\max} Why this step? Triangle inequality moves the absolute value inside, then we replace every reward by its worst case RmaxR_{\max}.

Step 2 — Sum the geometric series. Let S=k=0γk=1+γ+γ2+S = \sum_{k=0}^{\infty}\gamma^k = 1 + \gamma + \gamma^2 + \cdots. Multiply by γ\gamma: γS=γ+γ2+    SγS=1    S=11γ\gamma S = \gamma + \gamma^2 + \cdots \implies S - \gamma S = 1 \implies S = \frac{1}{1-\gamma} Why this step? Subtracting a shifted copy telescopes all the middle terms — the classic geometric-series trick, valid because γ<1\gamma<1 makes γk0\gamma^k\to0.

Step 3 — Combine.   GtRmax1γ  \boxed{\;|G_t| \le \frac{R_{\max}}{1-\gamma}\;} So the return is finite. Notice: as γ1\gamma \to 1, this bound blows up — long horizons need care.


Figure — Discount factor and returns

Effective horizon (the 80/20 of γ\gamma)

The weights γk\gamma^k shrink geometrically. Two related "horizon" numbers show up — don't confuse them:

1. The 11γ\tfrac{1}{1-\gamma} scale. This is the value of k=0γk\sum_{k=0}^\infty \gamma^k (total weight) and the characteristic scale over which weights decay to 1/e1/e-ish. It's the number usually quoted as the rough planning horizon.

2. The true mean step you look at. Normalize the weights into a probability distribution P(k)=(1γ)γkP(k)=(1-\gamma)\gamma^k (they sum to 1). Its mean index is E[k]=k=0k(1γ)γk=γ1γ.\mathbb{E}[k] = \sum_{k=0}^{\infty} k\,(1-\gamma)\gamma^k = \frac{\gamma}{1-\gamma}. Why this step? Using kkγk=γ(1γ)2\sum_k k\,\gamma^k = \dfrac{\gamma}{(1-\gamma)^2} and multiplying by the normalizer (1γ)(1-\gamma) gives γ1γ\dfrac{\gamma}{1-\gamma} — note the extra γ\gamma in the numerator, so the mean is one less than 11γ\tfrac{1}{1-\gamma}.

  Hscale=11γ(weight scale),E[k]=γ1γ(mean step)  \boxed{\;H_{\text{scale}}=\frac{1}{1-\gamma}\quad\text{(weight scale)},\qquad \mathbb{E}[k]=\frac{\gamma}{1-\gamma}\quad\text{(mean step)}\;}

γ\gamma 11γ\frac{1}{1-\gamma} (scale) γ1γ\frac{\gamma}{1-\gamma} (mean step) reads roughly as
0.90.9 1010 99 "next ~10 steps"
0.990.99 100100 9999 "next ~100 steps"
0.50.5 22 11 "very short-sighted"

Worked examples


Common mistakes (Steel-manned)


Flashcards

What is the return GtG_t in RL?
The total discounted future reward from step tt: Gt=k=0γkRt+k+1G_t=\sum_{k=0}^\infty \gamma^k R_{t+k+1}.
Which reward index does GtG_t start from, and why?
From Rt+1R_{t+1} — the reward is received after the action taken at time tt.
What is the discount factor γ\gamma and its range?
A weight in [0,1][0,1] that scales how much future rewards count; each future step multiplies by an extra γ\gamma.
What does γ=0\gamma=0 produce?
A myopic agent that cares only about the immediate reward Rt+1R_{t+1}.
What does γ1\gamma\to 1 produce?
A far-sighted agent that weights distant rewards almost as much as near ones.
Recursive form of the return?
Gt=Rt+1+γGt+1G_t = R_{t+1} + \gamma\,G_{t+1}.
What terminal condition does the return recursion need in an episodic task?
GT=0G_T=0 after the final reward (nothing comes after termination).
Upper bound on Gt|G_t| with bounded reward?
Rmax1γ\dfrac{R_{\max}}{1-\gamma}.
Sum of the geometric series k=0γk\sum_{k=0}^\infty \gamma^k?
11γ\dfrac{1}{1-\gamma} for γ<1|\gamma|<1.
Return of a constant reward +1+1 forever with γ=0.9\gamma=0.9?
1/(10.9)=101/(1-0.9)=10.
What is the decay-scale horizon for a given γ\gamma?
11γ\dfrac{1}{1-\gamma} (total weight / characteristic scale).
What is the mean step index under normalized discount weights?
γ1γ\dfrac{\gamma}{1-\gamma} (one less than the decay scale; they agree as γ1\gamma\to1).
Why discount in continuing tasks?
To keep the infinite reward sum finite (convergent).
Does larger γ\gamma always increase the return?
No — it amplifies the future, so with net-negative future rewards it decreases the return.

Recall Feynman: explain to a 12-year-old

Imagine you're collecting candies. A candy you get right now you can enjoy for sure. A candy someone promises you next week is worth a bit less — maybe you'll move away, maybe they'll forget. So you decide "a next-week candy is worth 90% of a today candy." The week after that, 90% of 90%, and so on. The return is just adding up all your future candies after shrinking the far-away ones. γ\gamma (like 0.90.9) is your "how much do I trust the future" number.

Connections

  • Markov Decision Process — returns are defined over MDP trajectories.
  • Value functions and Bellman equationsv(s)=E[GtSt=s]v(s)=\mathbb{E}[G_t\mid S_t=s] builds directly on Gt=Rt+1+γGt+1G_t = R_{t+1}+\gamma G_{t+1}.
  • Episodic vs continuing tasks — decides whether γ=1\gamma=1 is allowed.
  • Reward hypothesis — what the RtR_t's represent.
  • Geometric series — the math powering convergence and the horizon.
  • Temporal Difference learning — uses the recursive return to bootstrap.

Concept Map

summed into

weights

equals 0 gives

near 1 gives

justify

less than 1 enables

yields

proven finite by

peel first term

leads to

Future rewards

Return Gt

Discount factor gamma

Myopic agent gamma=0

Far-sighted gamma to 1

Why discount

Geometric series sum

Bounded return Rmax over 1-gamma

Recursive form Gt = Rt+1 + gamma Gt+1

Bellman equation

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Reinforcement Learning mein agent sirf abhi ka reward nahi, balki apne poore future ka reward maximize karna chahta hai. Is total future reward ko return GtG_t kehte hain. Lekin problem yeh hai ki future ka reward utna "pakka" nahi hota jitna aaj ka. Isiliye hum ek discount factor γ\gamma (0 se 1 ke beech) lagate hain — har ek step aage jaane par reward ko γ\gamma se multiply kar dete hain. Matlab Gt=Rt+1+γRt+2+γ2Rt+3+G_t = R_{t+1} + \gamma R_{t+2} + \gamma^2 R_{t+3} + \dots. Yaad rakho: reward action ke baad milta hai, isliye counting Rt+1R_{t+1} se start hoti hai — yeh off-by-one bahut students galat karte hain.

γ\gamma ka intuition simple hai: yeh "future par kitna bharosa" ka dial hai. γ=0\gamma=0 matlab agent bilkul lalchi (myopic) — sirf agla reward dekhta hai. γ\gamma ko 1 ke paas le jao to agent door ke reward ki bhi utni hi keemat samajhta hai — patient, long-term planner ban jaata hai. Ek dhyan dene wali baat: log aksar 11γ\frac{1}{1-\gamma} ko "horizon" bolte hain, par yeh actually total weight / decay scale hai. Normalized weights ka asli mean step γ1γ\frac{\gamma}{1-\gamma} hota hai — bilkul ek kam. γ1\gamma\to1 par dono barabar ho jaate hain, isliye loose version chalta rehta hai.

Discount kyu zaroori hai? Kyunki continuing (kabhi na khatam hone wale) tasks mein agar γ=1\gamma=1 rakhoge to reward ka sum infinite ho sakta hai. Geometric series ki madad se prove hota hai ki γk=11γ\sum \gamma^k = \frac{1}{1-\gamma}, aur isse GtRmax1γ|G_t| \le \frac{R_{\max}}{1-\gamma} — yaani return finite reh jaata hai. Example: har step +1+1 reward aur γ=0.9\gamma=0.9 ho to return =10= 10, infinity nahi!

Sabse important baat jo aage kaam aayegi: return ko recursive form mein likh sakte hain — Gt=Rt+1+γGt+1G_t = R_{t+1} + \gamma G_{t+1}. Yeh recursion ek terminal condition (G=0G=0 episode khatam hone ke baad) se start hoti hai. Yehi chhoti si equation aage chalke Bellman equation aur value functions ki neev banti hai. Isko dil se samajh lo, baaki RL aasan ho jaayega.

Go deeper — visual, from zero

Test yourself — Reinforcement Learning Foundations

Connections