Simple Algorithm
Reinforcement Learning · Fixed Point · 26 min

Discounting & Horizons

What γ really means, the effective horizon, and the trouble with discounting.

The discount factor is usually introduced as a device that keeps sums finite. It is really several things at once: the chance that the world goes on, an interest rate, a dial on variance and on how badly a learned model can be overfitted, and, as γ→1\gamma \to 1, a bridge to the average-reward criterion. This lesson takes each reading seriously, proves what happens as γ→1\gamma \to 1, and ends with a mismatch at the heart of deep RL: agents trained with γ=0.99\gamma = 0.99 and judged by undiscounted scores.

What you’ll learn

  • Derive the termination and interest-rate readings of γ\gamma, and show that discounted and randomly terminated returns agree in mean but not in variance.
  • Explain where the factors of 1/(1−γ)1/(1-\gamma) in bounds come from, and state Jiang et al.'s result that planning with a smaller γ\gamma can beat the true one when the model is estimated.
  • Prove the Laurent expansion Vγπ=gπ/(1−γ)+hπ+O(1−γ)V^\pi_\gamma = g^\pi/(1-\gamma) + h^\pi + O(1-\gamma) and the existence of Blackwell-optimal policies.
  • Write hyperbolic discounting as a mixture of exponential discounts, and analyze what a discounted objective optimizes when performance is measured without discounting.

Four readings of γ

Derivationγ as the probability that the world goes on
  1. G~=∑k≥01[N>k] Rk+1\tilde G = \sum_{k \ge 0} \mathbf 1[N > k]\, R_{k+1}

    Let the episode continue after each reward with probability γ\gamma, independently of everything else, and let NN be the number of rewards collected, so that Pr⁡(N>k)=γk\Pr(N > k) = \gamma^k. The total undiscounted reward is

  2. E[G~]=∑k≥0Pr⁡(N>k) E[Rk+1]=∑k≥0γk E[Rk+1]=E[G0]\E[\tilde G] = \sum_{k\ge0} \Pr(N > k)\,\E[R_{k+1}] = \sum_{k\ge0}\gamma^k\,\E[R_{k+1}] = \E[G_0]

    Independence lets each indicator's expectation factor out, so for bounded rewards the expected total equals the expected discounted return:

  3. E[N]=11−γ,Var⁡[N]=γ(1−γ)2,Var⁡[G0]=0\E[N] = \frac{1}{1-\gamma},\qquad \Var[N] = \frac{\gamma}{(1-\gamma)^2},\qquad \Var[G_0] = 0

    The distributions differ. With a reward of 1 on every step, G0=1/(1−γ)G_0 = 1/(1-\gamma) exactly, while G~=N\tilde G = N is geometric with the same mean and a large variance:

So "discounting is termination" holds for expected values, and therefore for every algorithm that needs only expected values, such as value iteration and TD learning. It fails for anything that looks at the distribution of the return, such as risk-sensitive or distributional RL. At γ=0.99\gamma = 0.99 the standard deviation of NN is about 99.5, nearly as large as its mean of 100.

ReadingWhat γ\gamma isConsequence
SurvivalThe probability that the episode goes on for another stepExpected values equal those of a random horizon with mean 1/(1−γ)1/(1-\gamma)
Interestγ=1/(1+ρ)\gamma = 1/(1+\rho) for an interest rate ρ\rho per stepA reward now can be reinvested; γ=0.99\gamma = 0.99 is an interest rate of about 1% per step
Variance controlA dial on how far returns reachA smaller γ\gamma gives shorter, less noisy return estimates and faster contraction, at the price of a bias toward the short term; in generalized advantage estimation, γ\gamma and λ\lambda are tuned for exactly this trade-off (Schulman et al., 2016)
Complexity controlA limit on which policies planning can produceWith an estimated model, a smaller planning γ\gamma can reduce overfitting (next step)

Where 1/(1−γ) comes from, and when a smaller γ is better

Factors of 1/(1−γ)1/(1-\gamma) pervade the theory, each one a horizon's worth of accumulation. Values are bounded by Rmax⁡/(1−γ)R_{\max}/(1-\gamma). Value iteration contracts at rate γ\gamma, so it needs about ln⁡(1/ε)/(1−γ)\ln(1/\varepsilon)/(1-\gamma) sweeps, since γk≤ε\gamma^k \le \varepsilon once k≥ln⁡(1/ε)/ln⁡(1/γ)k \ge \ln(1/\varepsilon)/\ln(1/\gamma). A greedy policy derived from a value estimate within ε\varepsilon of V⋆V^\star in the max norm loses at most 2γε/(1−γ)2\gamma\varepsilon/(1-\gamma). A model error per step compounds into a value error with a factor 1/(1−γ)21/(1-\gamma)^2, and sample-complexity bounds carry higher powers still.

In their experiments on 1,000 random MDPs with 10 states, 2 actions and γeval=0.99\gamma_{\mathrm{eval}} = 0.99, with models estimated from 5 to 50 trajectories of length 10, the loss was U-shaped in the planning γ\gamma. The best γ\gamma rose with the amount of data but stayed well below 0.99, and cross-validation could find it. The discount used for planning or learning is therefore a hyperparameter, distinct from the discount that defines the objective.

Check your understanding

Why can planning with γ=0.6\gamma = 0.6 in an estimated model give a better policy, measured with γeval=0.99\gamma_{\mathrm{eval}} = 0.99, than planning with 0.99 itself?

  1. Smaller discounts make value iteration converge to the true values faster
  2. The evaluation discount is usually overestimated
  3. A smaller γ\gamma restricts the set of policies planning can return, so the planner has less room to exploit errors in the estimated model: it trades bias for variance
  4. With γ=0.6\gamma = 0.6 the estimated model becomes exact
Show the answer

C. A smaller γ\gamma restricts the set of policies planning can return, so the planner has less room to exploit errors in the estimated model: it trades bias for variance

Planning with γ=0.99\gamma = 0.99 in M^\hat M optimizes over long chains of estimated transitions, so the resulting policy fits the model's errors. A shorter horizon limits which policies can come out (∣ΠR,γ∣\abs{\Pi_{R,\gamma}} grows with γ\gamma), at the cost of the bias term. As data accumulate, the model improves and the best planning γ\gamma moves up toward γeval\gamma_{\mathrm{eval}}.

γ → 1: gain, bias and Blackwell optimality

Fix a stationary policy π\pi of a finite MDP and write P=PπP = P^\pi and r=rπr = r^\pi. The Cesàro limit P⋆=lim⁡N→∞1N∑t=0N−1PtP^\star = \lim_{N\to\infty}\frac1N\sum_{t=0}^{N-1}P^t always exists for a finite stochastic matrix and satisfies PP⋆=P⋆P=P⋆P⋆=P⋆PP^\star = P^\star P = P^\star P^\star = P^\star. The gain gπ=P⋆rg^\pi = P^\star r is the long-run average reward from each state. The bias hπ=Hrh^\pi = H r, built from the deviation matrix H=(I−P+P⋆)−1(I−P⋆)H = (I - P + P^\star)^{-1}(I - P^\star), measures the transient advantage of starting in one state rather than another.

DerivationProof sketch
  1. Vγπ=∑t≥0γtPtr=∑t≥0γtP⋆r+∑t≥0γt(Pt−P⋆)r=gπ1−γ+∑t≥0γt(Pt−P⋆)rV^\pi_\gamma = \sum_{t\ge0}\gamma^t P^t r = \sum_{t\ge0}\gamma^t P^\star r + \sum_{t\ge0}\gamma^t\big(P^t - P^\star\big) r = \frac{g^\pi}{1-\gamma} + \sum_{t\ge0}\gamma^t\big(P^t - P^\star\big) r

    Split every power of PP into its limit and a deviation, using PtP⋆=P⋆P^t P^\star = P^\star:

  2. lim⁡γ↑1 ∑t≥0γt(Pt−P⋆)=H\lim_{\gamma\uparrow1}\ \sum_{t\ge0}\gamma^t\big(P^t - P^\star\big) = H

    If the chain is aperiodic, Pt−P⋆→0P^t - P^\star \to 0 geometrically, the remaining series converges absolutely, and at γ=1\gamma = 1 it equals the deviation matrix. For periodic chains the same limit holds in the Abel sense (Puterman, 1994, App. A).

  3. Finally, (I−γP)−1(I-\gamma P)^{-1} is a rational function of γ\gamma, and its only singularity at γ=1\gamma = 1 is the simple pole captured by the first term (eigenvalue 1 of a stochastic matrix is semisimple). The remainder is therefore analytic at γ=1\gamma = 1 and vanishes there at rate O(1−γ)O(1-\gamma). ■\blacksquare

Predict before you look

Change the example so that stay in s2s_2 pays 1.5 instead of 2. Above which discount factor is going from s1s_1 better than staying?

Show the answer

0.67

Going is worth 1.5γ/(1−γ)1.5\gamma/(1-\gamma) and staying 1/(1−γ)1/(1-\gamma), so going wins when 1.5γ>11.5\gamma > 1, that is γ>2/3≈0.67\gamma > 2/3 \approx 0.67. In Laurent terms, going has gain 1.5 against 1 but bias −1.5-1.5 against 0: the gain wins once 0.51−γ>1.5\frac{0.5}{1-\gamma} > 1.5, which is the same condition.

DerivationProof
  1. For a deterministic stationary π\pi, Cramer's rule applied to (I−γPπ)V=rπ(I - \gamma P^\pi)V = r^\pi makes every Vγπ(s)V^\pi_\gamma(s) a rational function of γ\gamma. So is every difference Vγπ(s)−Vγπ′(s)V^\pi_\gamma(s) - V^{\pi'}_\gamma(s), and a rational function that is not identically zero has finitely many zeros in (0,1)(0,1).

  2. There are finitely many deterministic stationary policies, hence finitely many differences. Choose γ0\gamma_0 above all their zeros: on (γ0,1)(\gamma_0, 1) each difference is identically zero or keeps a constant sign.

  3. Pick γ1∈(γ0,1)\gamma_1 \in (\gamma_0, 1) and a deterministic stationary π⋆\pi^\star optimal at γ1\gamma_1; one exists (Policies & Why Simple Ones Suffice). For every deterministic stationary π\pi, Vγπ⋆−Vγπ≥0V^{\pi^\star}_\gamma - V^\pi_\gamma \ge 0 at γ1\gamma_1, so it is ≥0\ge 0 on all of (γ0,1)(\gamma_0, 1). Deterministic stationary policies suffice at every γ\gamma, so π⋆\pi^\star is optimal throughout. The gain and bias statements follow by comparing Laurent expansions term by term. ■\blacksquare

The theorem says nothing about how close to 1 the threshold γ0\gamma_0 is, and in general it can be arbitrarily close. Grand-Clément and Petrik (2023) derive an upper bound on the smallest valid threshold, which they call the Blackwell discount factor: above it, every discounted-optimal policy is Blackwell- and average-optimal, which reduces those criteria to solving a single discounted MDP.

Hyperbolic discounting, and the evaluation mismatch

People often prefer $100 today to $110 tomorrow, yet prefer $110 in 31 days to $100 in 30 days: a preference reversal. Exponential discounting cannot produce one, because comparing γt⋅100\gamma^t \cdot 100 with γt+1⋅110\gamma^{t+1} \cdot 110 is the same as comparing 100 with 110γ110\gamma at every tt; it is time-consistent. Hyperbolic discounting, d(t)=1/(1+kt)d(t) = 1/(1+kt), does produce reversals. With k=1k = 1 per day, today's choice is 100100 against 110/2=55110/2 = 55, while thirty days out it is 100/31≈3.23100/31 \approx 3.23 against 110/32≈3.44110/32 \approx 3.44.

DerivationHyperbolic discounting is a mixture of exponentials
  1. ∫01γkt dγ=11+kt\int_0^1 \gamma^{kt}\,d\gamma = \frac{1}{1+kt}

    Integrate exponential discounts over γ\gamma (Fedus et al., 2019):

  2. Qdπ(s,a)=Eπ[∑t≥0d(t) Rt+1 ∣ s,a]=∫01w(γ) Qγπ(s,a) dγQ^{\pi}_{d}(s,a) = \E_\pi\Big[\sum_{t\ge0} d(t)\,R_{t+1}\,\Big|\,s, a\Big] = \int_0^1 w(\gamma)\,Q^{\pi}_{\gamma}(s,a)\,d\gamma

    More generally, a discount function d(t)=∫01w(γ) γt dγd(t) = \int_0^1 w(\gamma)\,\gamma^t\,d\gamma gives each policy a value that is the same mixture of its ordinary discounted values, so it can be learned by training value functions for many γ\gamma at once:

  3. ∫0∞1k e−λ/k  e−λt dλ=11+kt\int_0^\infty \tfrac1k\, e^{-\lambda/k}\; e^{-\lambda t}\,d\lambda = \frac{1}{1+kt}

    Sozou (1998) gave the survival reading: if the per-step hazard rate λ\lambda is unknown, with an exponential prior of mean kk, the probability of surviving to time tt is hyperbolic. Hyperbolic discounting is exponential discounting under uncertainty about the hazard.

Fedus, Gelada, Bengio, Bellemare and Larochelle (2019) approximated the integral with value heads for 10 discount factors up to 0.99. On a sample of 19 Atari games their hyperbolic agent beat the Rainbow baseline on 14, but it did not differ significantly from an agent that learned the same set of horizons and acted with a single γ\gamma. The gain came mainly from learning many horizons as an auxiliary task, not from acting hyperbolically.

The mismatch. Deep RL agents are usually trained on a discounted return with γ≈0.99\gamma \approx 0.99 and then compared by their undiscounted episode scores. Blackwell's theorem says the two criteria share an optimal policy once γ\gamma is close enough to 1, but not how close, and with function approximation it does not apply at all. In continuing tasks there is a sharper observation (Sutton & Barto, §10.4). Average each policy's discounted values over its own stationary distribution μπ\mu_\pi; every future step then has the same expected reward, the average reward rˉ(π)\bar r(\pi) of a unichain policy:

∑sμπ(s) Vγπ(s)=∑t≥0γt∑sμπ(s) Eπ[Rt+1∣S0=s]=rˉ(π)1−γ\sum_s \mu_\pi(s)\,V^\pi_\gamma(s) = \sum_{t\ge0}\gamma^t \sum_s \mu_\pi(s)\,\E_\pi\big[R_{t+1}\mid S_0 = s\big] = \frac{\bar r(\pi)}{1-\gamma}
This natural objective ranks policies by average reward whatever γ\gamma is. Naik et al. (2019) argue from it that, with function approximation in continuing tasks, discounting does not define a well-posed optimization problem, and recommend the average-reward criterion.

Policy-gradient code shows the same tension. Most implementations weight states by how often they are visited, without the factor γt\gamma^t that the gradient of the discounted objective requires, so the update is not the gradient of that objective; Nota and Thomas (2020) showed it is not the gradient of any function (see The Policy Gradient Theorem in Depth).

Key takeaways

  • Discounting equals random termination with continuation probability γ\gamma in expectation, not in distribution: with constant rewards the terminated return has variance γ/(1−γ)2\gamma/(1-\gamma)^2.
  • Factors of 1/(1−γ)1/(1-\gamma) in bounds count horizons of accumulation; value iteration needs about ln⁡(1/ε)/(1−γ)\ln(1/\varepsilon)/(1-\gamma) sweeps unless termination ends episodes sooner.
  • With an estimated model, planning with γ<γeval\gamma < \gamma_{\mathrm{eval}} trades bias for less overfitting, and the best planning γ\gamma rises with data (Jiang et al., 2015).
  • Vγπ=gπ/(1−γ)+hπ+O(1−γ)V^\pi_\gamma = g^\pi/(1-\gamma) + h^\pi + O(1-\gamma); in finite MDPs a stationary deterministic policy is optimal for all γ\gamma close enough to 1, and it maximizes the gain, then the bias.
  • Hyperbolic discounting is a mixture of exponential discounts, and a discounted objective weighted by the stationary distribution ranks policies by average reward whatever γ\gamma is.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

A reward of 1 arrives on every step. Compare the discounted return G0G_0 with γ=0.9\gamma = 0.9 and the undiscounted total G~\tilde G of an episode that continues after each step with probability 0.9.

  1. The same mean, 10, and the same variance
  2. The same mean, 10; G0G_0 has variance 0 and G~\tilde G has variance 90
  3. G~\tilde G has the larger mean
  4. Different means: 10 and 9
Show the answer

B. The same mean, 10; G0G_0 has variance 0 and G~\tilde G has variance 90

G~=N\tilde G = N is geometric with mean 1/(1−γ)=101/(1-\gamma) = 10 and variance γ/(1−γ)2=0.9/0.01=90\gamma/(1-\gamma)^2 = 0.9/0.01 = 90, while G0=10G_0 = 10 exactly. Discounting and random termination agree only in expectation.

Question 2

In the two-state MDP where stay pays 1 in s1s_1, go pays 0 and moves to s2s_2, and stay in s2s_2 pays 2 forever, which policy is Blackwell-optimal, and from which γ0\gamma_0 on?

  1. (stay, stay), from γ0=0.5\gamma_0 = 0.5
  2. (go, stay), from γ0=0.9\gamma_0 = 0.9
  3. (go, stay), from γ0=0.5\gamma_0 = 0.5
  4. No policy is optimal for all γ\gamma close to 1
Show the answer

C. (go, stay), from γ0=0.5\gamma_0 = 0.5

From s1s_1, (go, stay) is worth 2γ/(1−γ)2\gamma/(1-\gamma) and (stay, stay) is worth 1/(1−γ)1/(1-\gamma), so going wins exactly when γ>0.5\gamma > 0.5. In s2s_2 staying is always best. (go, stay) has the higher gain, 2 against 1, which is why it wins as γ→1\gamma \to 1.

Question 3

In Jiang et al.'s bound, what happens to the best planning discount as the number of samples nn per state–action pair grows?

  1. It rises toward γeval\gamma_{\mathrm{eval}}, because the model-error term shrinks like 1/n1/\sqrt n
  2. It falls toward 0
  3. It stays at γeval\gamma_{\mathrm{eval}} whatever nn is
  4. It rises above γeval\gamma_{\mathrm{eval}}
Show the answer

A. It rises toward γeval\gamma_{\mathrm{eval}}, because the model-error term shrinks like 1/n1/\sqrt n

The bias term favors γ\gamma near γeval\gamma_{\mathrm{eval}} and does not depend on nn; the model-error term favors small γ\gamma and decays like 1/n1/\sqrt n. With more data the balance tips toward longer horizons, as their experiments showed.

Question 4

In a continuing task you rank policies by ∑sμπ(s) Vγπ(s)\sum_s \mu_\pi(s)\,V^\pi_\gamma(s), weighting each policy's values by its own stationary distribution. How does the ranking depend on γ\gamma?

  1. Smaller γ\gamma favors more myopic policies
  2. Larger γ\gamma favors policies with a larger bias
  3. The ranking is undefined, because the sum diverges
  4. It does not: the objective equals rˉ(π)/(1−γ)\bar r(\pi)/(1-\gamma), which ranks policies by average reward for every γ\gamma
Show the answer

D. It does not: the objective equals rˉ(π)/(1−γ)\bar r(\pi)/(1-\gamma), which ranks policies by average reward for every γ\gamma

Under its own stationary distribution, every future step of π\pi has expected reward rˉ(π)\bar r(\pi), so the weighted sum is ∑tγtrˉ(π)=rˉ(π)/(1−γ)\sum_t\gamma^t\bar r(\pi) = \bar r(\pi)/(1-\gamma). Discounting rescales the objective but cannot change the ranking (Sutton & Barto, §10.4).

Further reading

  • D. Blackwell, "Discrete dynamic programming," Annals of Mathematical Statistics 33(2), 719–726 (1962).
  • M. L. Puterman, Markov Decision Processes: Discrete Stochastic Dynamic Programming, ch. 8 and 10 (Wiley, 1994).
  • N. Jiang, A. Kulesza, S. Singh & R. Lewis, "The dependence of effective planning horizon on model accuracy," AAMAS, 1181–1189 (2015).
  • W. Fedus, C. Gelada, Y. Bengio, M. G. Bellemare & H. Larochelle, "Hyperbolic discounting and learning over multiple horizons," arXiv:1902.06865 (2019).
  • A. Naik, R. Shariff, N. Yasui, H. Yao & R. S. Sutton, "Discounted reinforcement learning is not an optimization problem," NeurIPS Workshop on Optimization Foundations for RL, arXiv:1910.02140 (2019).