MVA · Course notes

Reinforcement Learning

M2 MVA · Semester 2 · Learning · 5 ECTS

Contents

Introduction and overview

Module Reinforcement Learning
Official title Reinforcement Learning
Instructors D. BASU, E. KAUFMANN, O. MAILLARD (master-mva.com, 2026–2027)
Period Semester 2 · period 2 (04/01/2027 – 02/04/2027)
Credits and volume 5 ECTS · 24 h (assumed: master-mva.com lists 8 lectures + 1 written exam; the Université Paris-Saclay row (“Deep reinforcement learning”, semester 1) displays no volume)
Label Learning · domains on master-mva.com: Deep Learning
Language Not displayed; the objective and the titles of the lectures on master-mva.com are written in English
Assessment One written exam (after class 8) and one programming assignment (after class 5) (master-mva.com, “Mode de validation”); no weights are displayed; Université Paris-Saclay: “Evaluation Continue non Intégrale” (partial continuous assessment)
Prerequisites Not displayed
Note on sources master-mva.com places the course in semester 2 with eight lectures; the Université Paris-Saclay programme table lists a row “Reinforcement learning” (5 ECTS) whose course detail is titled “Deep reinforcement learning” and placed in semester 1, with no volume and no programme; these notes follow master-mva.com

Audience: a student with a good M1 in mathematics or computer science who knows Markov chains and gradient descent, and who wants to understand how an agent can learn to act from rewards alone, with guarantees.

Empirical first: on a six-state “river” whose current pushes the swimmer back, the large reward sits at the far bank and a tiny one at the start. Over 2000 episodes of 20 steps, Q-learning with \varepsilon-greedy exploration settles on the tiny reward: its regret is 5929, almost all of the 3.06 available per episode.

The optimistic algorithm UCB-VI (ch. 6), given the same 2000 episodes, has regret 73 and ends with the optimal policy. Exploration, not optimisation, made the difference.

Reinforcement learning studies an agent that interacts with an unknown environment, modelled as a Markov decision process, and learns a policy that maximises its cumulative reward. The course starts from dynamic programming, where the model is known, and moves to learning from samples, to policies and value functions represented by parametric models and deep networks, and to the exploration–exploitation trade-off with its regret and sample-complexity guarantees.

The bandit chapters share their tools with Sequential Learning, and the deep-RL chapter uses the networks of Deep Learning. The linear-quadratic regulator of ch. 5 is the control problem of Robotics.

What you will be able to do

Official objectives and syllabus (2026–2027)

The course description on master-mva.com states that the class aims at providing a comprehensive and modern introduction to reinforcement learning concepts and algorithms. It endeavours to provide a solid formal basis on the foundational notions of reinforcement learning.

The description announces eight lectures and one written exam, with the titles listed below. The Université Paris-Saclay course detail, titled “Deep reinforcement learning”, gives only the type of assessment (“Evaluation Continue non Intégrale”), with no programme of its own.

Official topic Course section
Objective: a comprehensive and modern introduction to RL concepts and algorithms The whole page: tabular algorithms (ch. 2), policy gradient (ch. 3), function approximation (ch. 4), deep RL (ch. 5), exploration (ch. 6–ch. 8)
Objective: a solid formal basis on the foundational notions of RL Theorem 1.7 (Bellman optimality), Theorem 1.11 (policy iteration), Theorem 2.3 (stochastic approximation), Theorem 3.4 (policy gradient), Theorem 4.4 (linear TD), Theorem 6.6 (Lai–Robbins), Theorem 7.3 (average-reward optimality); proofs completed in ch. 9
Lecture 1: MDP and Dynamic Programming ch. 1: Definitions 1.1–1.5, Propositions 1.4 and 1.6, Theorem 1.7, value iteration (Proposition 1.8), Example 1.10, policy iteration (Theorem 1.11), linear programming (Proposition 1.12), finite horizon
Lecture 2: The first algorithms of Reinforcement Learning ch. 2: Monte Carlo evaluation, TD(0) and TD(\lambda), stochastic approximation (Theorem 2.3), Q-learning (Theorem 2.6), SARSA, exploration rules, certainty equivalence
Lecture 3: The Actors: Policy Iteration and Gradient ch. 3: performance difference (Lemma 3.1), approximate policy iteration (Proposition 3.2; conservative policy iteration in ch. 9), policy gradient theorem (Theorem 3.4), REINFORCE and baselines, gradient domination (Proposition 3.7), natural policy gradient, TRPO and PPO
Lecture 4: The Critics: RL with function Approximation ch. 4: projected Bellman equation (Proposition 4.2), linear TD (Theorems 4.3–4.4), LSTD, fitted Q-iteration and error propagation (Proposition 4.6), the deadly triad (Example 4.7), compatible actor–critic (Proposition 4.8)
Lecture 5: Scaling up RL: Towards Deep RL and Continuous MDPs ch. 5: DQN (Algorithm 5.1), overestimation and Double DQN (Proposition 5.2), continuous MDPs (Definition 5.3), LQR (Theorem 5.4), deterministic policy gradient (Theorem 5.5), entropy regularisation and SAC (Proposition 5.6), PPO
Lecture 6: Exploration-Exploitation in RL ch. 6: bandit regret, UCB (Theorem 6.4), Lai–Robbins (Theorem 6.6), Thompson sampling, episodic regret, UCB-VI (Algorithm 6.8, Proposition 6.9, Theorem 6.10), posterior sampling, lower bounds
Lecture 7: Average-reward Reinforcement Learning and Instance Optimal Algorithms ch. 7: gain and bias (Definitions 7.1–7.2), optimality equation (Theorem 7.3), relative value iteration, span and diameter (Proposition 7.5), UCRL2 (Theorem 7.7), regret decomposition (Proposition 7.8), Burnetas–Katehakis bound (Theorem 7.9), KL-UCB and IMED-type algorithms
Lecture 8: Bandit Methods for Pure Exploration and Planning in RL ch. 8: best-arm identification (Definition 8.1), successive elimination (Theorem 8.3), lower bound and characteristic time (Theorem 8.4), Track-and-Stop, sparse sampling (Theorem 8.7), UCT and Monte Carlo tree search, gap-based planning
Organisation: 8 lectures + 1 written exam Session plan, sessions 1–8; exam proposal in Projects and assessment
Assessment: 1 written exam (after class 8) and 1 programming assignment (after class 5); “Evaluation Continue non Intégrale” (Université Paris-Saclay) Projects and assessment: solo subjects sized like the assignment, which the session plan places after session 5
Université Paris-Saclay course detail: “Deep reinforcement learning” ch. 5 (deep Q-networks, deep actor–critic methods), with ch. 10 for current deep-RL research

Every official lecture has a chapter in these notes, in the official order. The extensions beyond the syllabus are the review of ch. 0, the linear-quadratic regulator as the worked continuous MDP of ch. 5, the complements of ch. 9 (proofs of the stochastic approximation theorem and of the Lai–Robbins bound, and a detailed sketch of the UCB-VI regret) and the research directions of ch. 10.

Where this course fits in the programme

Official prerequisites: not displayed. The course uses finite Markov chains, conditional expectations, concentration inequalities, gradients and a little linear programming; ch. 0 reviews them.

Course outline

Session plan

24 h in class (assumed) = 8 sessions of 3 h.

The volume is assumed from the organisation published on master-mva.com (eight lectures and one written exam), with 3 h per lecture; the Université Paris-Saclay programme table displays no volume. The written exam, after the eighth lecture, is not counted in the 24 h. The plan follows the official order of the lectures, one per session; the content of each session is a proposal.

Level 1 = foundations, 2 = core results and algorithms, 3 = advanced and research-level material. The level never goes down from one session to the next.

Session Hours Level Content Practice
1 3 h 1 ch. 0 Review: Markov chains, contractions, Hoeffding, stochastic approximation; ch. 1 MDPs, Bellman equations, value and policy iteration, linear programming Ex. 1, 2; lab: code of ch. 1
2 3 h 2 ch. 2 Monte Carlo and TD evaluation, stochastic approximation, Q-learning, SARSA, exploration rules Ex. 3, 4, 6; lab: code of ch. 2
3 3 h 2 ch. 3 Performance difference, approximate policy iteration, policy gradient theorem, REINFORCE, gradient domination, natural gradient, PPO Ex. 9, 10; lab: code of ch. 3
4 3 h 2 ch. 4 Linear TD and the projected Bellman equation, LSTD, fitted Q-iteration, deadly triad, actor–critic Ex. 8; lab: code of ch. 4
5 3 h 2 ch. 5 DQN, Double DQN, continuous MDPs, LQR, deterministic policy gradient, SAC, PPO in practice; the programming assignment is handed out after this session Ex. 7, 11; lab: code of ch. 5
6 3 h 3 ch. 6 Bandits, UCB, Lai–Robbins, Thompson sampling, regret in episodic MDPs, UCB-VI, posterior sampling Ex. 5, 14, 15; lab: code of ch. 6
7 3 h 3 ch. 7 Gain and bias, optimality equation, relative value iteration, diameter, UCRL2, instance-dependent bounds, KL-UCB Ex. 12; lab: code of ch. 7
8 3 h 3 ch. 8 Best-arm identification, characteristic time, Track-and-Stop, sparse sampling, UCT, planning as pure exploration Ex. 13, 17; lab: code of ch. 8

Self-study, outside the 24 h (about 8 h in total): ch. 9 Complements for self-study (≈ 5 h, with Ex. 16) · ch. 10 Research directions and open problems (≈ 3 h, with Ex. 18).

How to study this module

0. Review: Markov chains, contractions and concentration

Reinforcement learning combines three M1-level tools: Markov chains describe the dynamics, contractions give the existence and computation of value functions, and concentration inequalities with stochastic approximation turn samples into guarantees. This chapter states the facts used later. The Probability and Statistics refresher covers the same ground at a slower pace.

Finite Markov chains

Definition 0.1 — Markov chain, stationary distribution Let \mathcal{S} be a finite set. A sequence (s_t)_{t \ge 0} is a Markov chain with transition matrix P if \mathbb{P}(s_{t+1} = s' \mid s_0, \dots, s_t) = P(s_t, s') .

A probability vector d on \mathcal{S} is stationary if d^\top P = d^\top. The chain is irreducible if every state can be reached from every other one, and aperiodic if the gcd of the return times to each state is 1.

Theorem 0.2 — Ergodic theorem for finite chains An irreducible finite chain has a unique stationary distribution d, with d(s) > 0 for all s. For every function f on \mathcal{S}, almost surely, \frac{1}{T} \sum_{t=0}^{T-1} f(s_t) \xrightarrow[T \to \infty]{} \sum_s d(s) f(s) .

If the chain is also aperiodic, the law of s_t converges to d from any initial state. Proofs: Levin and Peres (2017), ch. 1 and 4.

Contractions and fixed points

Definition 0.3 — Contraction A map T from a normed space (E, \|\cdot\|) to itself is a \gamma-contraction, for some \gamma \in [0, 1), if for all x, y \in E \|Tx - Ty\| \le \gamma\, \|x - y\| . On \mathbb{R}^{\mathcal{S}} the norm will almost always be the sup norm, \|V\|_\infty = \max_s |V(s)|.

Theorem 0.4 — Banach fixed-point theorem If E is complete and T is a \gamma-contraction, then T has a unique fixed point x^\star.

For every x_0, the iterates x_{k+1} = T x_k satisfy \|x_k - x^\star\| \le \gamma^k \|x_0 - x^\star\| .

Proof. By induction, \|x_{k+1} - x_k\| \le \gamma^k \|x_1 - x_0\|. The triangle inequality gives, for m > k, \|x_m - x_k\| \le \sum_{j=k}^{m-1} \gamma^j \|x_1 - x_0\| \le \frac{\gamma^k}{1 - \gamma} \|x_1 - x_0\| , so (x_k) is a Cauchy sequence. Its limit x^\star is a fixed point, because T is continuous.

Two fixed points x, y satisfy \|x - y\| = \|Tx - Ty\| \le \gamma \|x - y\|, hence x = y. Finally, the rate follows from \|x_{k+1} - x^\star\| = \|T x_k - T x^\star\| \le \gamma \|x_k - x^\star\| . ∎

Concentration

Theorem 0.5 — Hoeffding’s inequality Let X_1, \dots, X_n be independent with values in [a, b], and \bar X_n their mean. For every \varepsilon > 0, \mathbb{P}\big( |\bar X_n - \mathbb{E} \bar X_n| \ge \varepsilon \big) \le 2 \exp\!\Big( - \frac{2 n \varepsilon^2}{(b - a)^2} \Big) .

Equivalently, with probability at least 1 - \delta, the deviation is at most (b - a) \sqrt{\frac{\log(2/\delta)}{2n}} .

The proof bounds the moment generating function of a bounded variable (Hoeffding’s lemma) and applies Markov’s inequality to e^{\lambda(\bar X_n - \mathbb{E}\bar X_n)}; see Boucheron, Lugosi and Massart (2013), ch. 2. Every confidence bonus of ch. 6–ch. 8 is a version of this width.

import numpy as np

rng = np.random.default_rng(0)
n, eps, p, reps = 100, 0.1, 0.5, 200_000
heads = rng.binomial(n, p, size=reps)
freq = np.mean(np.abs(heads - n * p) >= n * eps)   # integer counts: no rounding at the boundary
bound = 2 * np.exp(-2 * n * eps**2)
print(f"empirical P(|mean - p| >= {eps}) = {freq:.4f}")
print(f"Hoeffding bound                 = {bound:.4f}")
delta = 0.05                       # half-width of a 95% confidence interval
print(f"95% Hoeffding half-width, n={n}: {np.sqrt(np.log(2/delta)/(2*n)):.3f}")

For 100 fair coins the deviation probability is 0.057 and the bound 0.271: Hoeffding’s inequality is loose by a constant factor, but it holds for any bounded law. The 95 % half-width is 0.136 .

Stochastic approximation

The running mean \bar X_n = \bar X_{n-1} + \frac{1}{n}(X_n - \bar X_{n-1}) is the simplest learning rule: move the estimate a step \alpha_n = 1/n towards the new sample. Robbins and Monro (1951) showed that the same rule finds the root of an unknown function observed with noise.

Theorem 0.6 — Robbins–Monro conditions Let x_{n+1} = x_n + \alpha_n \big( h(x_n) + w_n \big), where (w_n) is a martingale difference noise with bounded conditional variance. Assume that h is Lipschitz, that h(x^\star) = 0, and that (x - x^\star)\, h(x) \le -c\,(x - x^\star)^2 for some c > 0. If the steps satisfy \sum_n \alpha_n = \infty, \qquad \sum_n \alpha_n^2 < \infty , then x_n \to x^\star almost surely. Proof: Kushner and Yin (2003), ch. 5; the vector version used in RL is Theorem 2.3.

The first condition lets the iterates travel any distance; the second makes the accumulated noise \sum_n \alpha_n w_n converge. Steps \alpha_n = n^{-\beta} satisfy both exactly when 1/2 < \beta \le 1.

Key takeaways — chapter 0

  • Irreducible finite chains have a unique stationary distribution, and time averages converge to stationary averages.
  • A contraction has a unique fixed point, reached at a geometric rate by iteration.
  • Hoeffding: with probability 1 - \delta, a mean of n bounded samples is accurate to within \sqrt{\log(2/\delta)/(2n)} times the range.
  • Stochastic approximation needs steps with an infinite sum and a finite sum of squares.

1. Markov decision processes and dynamic programming

When the environment is known, choosing how to act over time is a planning problem. This chapter defines Markov decision processes, shows that optimal behaviour is characterised by a fixed-point equation, and gives the two classical algorithms that solve it.

Markov decision processes and policies

Definition 1.1 — Markov decision process A finite discounted Markov decision process (MDP) is a tuple M = (\mathcal{S}, \mathcal{A}, P, r, \gamma):

  • finite sets of states \mathcal{S} and actions \mathcal{A}, with S = |\mathcal{S}| and A = |\mathcal{A}|;
  • a transition kernel: P(s' \mid s, a) is the probability of moving to s' after playing a in s;
  • a reward function r(s, a) \in [0, 1], the mean reward of playing a in s;
  • a discount factor \gamma \in [0, 1).

The agent observes s_t, plays a_t, receives a reward r_t \in [0, 1] of mean r(s_t, a_t) and moves to s_{t+1} \sim P(\cdot \mid s_t, a_t). Its return is the discounted sum G = \sum_{t \ge 0} \gamma^t r_t \in \Big[0, \frac{1}{1 - \gamma}\Big] .

The discount makes every return finite and every Bellman operator a contraction; 1/(1 - \gamma) acts as an effective horizon.

Definition 1.2 — Policies A policy chooses the action from the past. It is history-dependent in general, a_t \sim \pi_t(\cdot \mid s_0, a_0, \dots, s_t).

It is Markov stationary if a_t \sim \pi(\cdot \mid s_t) with the same \pi at every step, and deterministic if moreover \pi(\cdot \mid s) is a point mass, written \pi(s).

A stationary policy \pi induces a Markov chain with matrix P^\pi and a reward vector r^\pi: P^\pi(s, s') = \sum_a \pi(a \mid s)\, P(s' \mid s, a), \qquad r^\pi(s) = \sum_a \pi(a \mid s)\, r(s, a) .

Definition 1.3 — Value functions The value of a policy \pi in state s and its action value are V^\pi(s) = \mathbb{E}^\pi\Big[\sum_{t \ge 0} \gamma^t r_t \,\Big|\, s_0 = s\Big], \qquad Q^\pi(s, a) = \mathbb{E}^\pi\Big[\sum_{t \ge 0} \gamma^t r_t \,\Big|\, s_0 = s, a_0 = a\Big] .

The optimal value is V^\star(s) = \sup_\pi V^\pi(s), the supremum over all history-dependent policies, and Q^\star is defined in the same way. A policy is optimal if V^\pi = V^\star in every state.

Bellman equations and operators

Proposition 1.4 — Bellman evaluation equation For a stationary policy \pi, the value V^\pi is the unique solution of V = r^\pi + \gamma P^\pi V:

V^\pi = (I - \gamma P^\pi)^{-1} r^\pi = \sum_{t \ge 0} \gamma^t (P^\pi)^t r^\pi .

Moreover the action values and the values are linked by Q^\pi(s, a) = r(s, a) + \gamma \sum_{s'} P(s' \mid s, a) V^\pi(s'), \qquad V^\pi(s) = \sum_a \pi(a \mid s) Q^\pi(s, a) .

Proof. By the Markov property, the law of s_t given s_0 = s is the row s of (P^\pi)^t, so \mathbb{E}[r_t \mid s_0 = s] = ((P^\pi)^t r^\pi)(s). Summing with weights \gamma^t gives the series.

The matrix \gamma P^\pi has sup-norm operator norm \gamma < 1, because P^\pi is stochastic. Hence the Neumann series converges to (I - \gamma P^\pi)^{-1}, and I - \gamma P^\pi is invertible. Conditioning on the first action and the first transition gives the two identities for Q^\pi. ∎

Definition 1.5 — Bellman operators For V \in \mathbb{R}^{\mathcal{S}}, write (PV)(s, a) = \sum_{s'} P(s' \mid s, a) V(s'). The evaluation operator of a stationary policy and the optimality operator are T^\pi V = r^\pi + \gamma P^\pi V, \qquad (T^\star V)(s) = \max_{a \in \mathcal{A}} \big[ r(s, a) + \gamma (PV)(s, a) \big] .

A deterministic policy \pi is greedy with respect to V if \pi(s) attains the maximum in (T^\star V)(s) for every s, that is T^\pi V = T^\star V.

Proposition 1.6 — Monotonicity and contraction The operators T^\pi and T^\star are monotone (V \le W entrywise implies TV \le TW), satisfy T(V + c\mathbf{1}) = TV + \gamma c \mathbf{1}, and are \gamma-contractions in the sup norm.

Proof. Monotonicity and the shift identity follow from the non-negativity of P and from P\mathbf{1} = \mathbf{1}.

For the contraction, use |\max_a f(a) - \max_a g(a)| \le \max_a |f(a) - g(a)|. For every s, |(T^\star V)(s) - (T^\star W)(s)| \le \gamma \max_a \big|\big(P(V - W)\big)(s, a)\big| \le \gamma \|V - W\|_\infty . The same argument without the maximum treats T^\pi. ∎

By Theorem 0.4, T^\star has a unique fixed point. The central result of the theory is that this fixed point is the optimal value, and that acting greedily with respect to it is optimal.

Key result — the Bellman optimality equation V^\star(s) = \max_{a \in \mathcal{A}} \Big[ r(s, a) + \gamma \sum_{s'} P(s' \mid s, a)\, V^\star(s') \Big]

Theorem 1.7 — Bellman optimality Let V^\dagger be the fixed point of T^\star. Then V^\dagger = V^\star, every greedy policy with respect to V^\star is optimal, and an optimal policy can therefore be chosen deterministic and stationary. In the same way, Q^\star is the unique fixed point of (T^\star Q)(s, a) = r(s, a) + \gamma \sum_{s'} P(s' \mid s, a) \max_{a'} Q(s', a') .

Proof. Step 1: V^\dagger is attained. Let \pi be greedy with respect to V^\dagger. Then T^\pi V^\dagger = T^\star V^\dagger = V^\dagger.

So V^\dagger is the fixed point of T^\pi, which is V^\pi by Proposition 1.4. Hence V^\dagger = V^\pi \le V^\star.

Step 2: no policy does better. Fix a history-dependent policy and a horizon n. For a function V, consider the n-step problem with terminal reward \gamma^n V(s_n). Backward induction over the last step shows that its optimal value over all history-dependent policies is (T^\star)^n V, because at the last step the best conditional choice depends only on s_{n-1}.

Take V = 0. The expected return of the policy is at most (T^\star)^n 0 + \gamma^n/(1 - \gamma), the second term bounding the rewards after time n. Letting n \to \infty gives a value at most V^\dagger, by Theorem 0.4.

Step 3: Q^\star. The same two steps apply to the operator on \mathbb{R}^{\mathcal{S} \times \mathcal{A}}, a \gamma-contraction for the same reason. ∎

The theorem reduces a search over all history-dependent policies to a fixed-point problem in dimension S. It also says that Q^\star is enough to act: \pi^\star(s) \in \arg\max_a Q^\star(s, a) needs no model.

Value iteration

Proposition 1.8 — Value iteration and greedy policies (Singh and Yee, 1994) The iterates V_{k+1} = T^\star V_k converge to V^\star, with \|V_k - V^\star\|_\infty \le \gamma^k \|V_0 - V^\star\|_\infty . Moreover, if \pi is greedy with respect to any V, \|V^\star - V^\pi\|_\infty \le \frac{2\gamma}{1 - \gamma}\, \|V - V^\star\|_\infty .

Proof. The first claim is Theorem 0.4. For the second, write \varepsilon = \|V - V^\star\|_\infty and use T^\pi V = T^\star V: V^\star - V^\pi = (T^\star V^\star - T^\star V) + (T^\pi V - T^\pi V^\pi) \le \gamma \varepsilon \mathbf{1} + \gamma P^\pi (V - V^\pi) .

Then V - V^\pi \le \varepsilon \mathbf{1} + (V^\star - V^\pi), so that V^\star - V^\pi \le 2\gamma\varepsilon\mathbf{1} + \gamma P^\pi (V^\star - V^\pi) .

Since V^\star - V^\pi \ge 0, taking the sup norm gives the bound \|V^\star - V^\pi\|_\infty \le 2\gamma\varepsilon + \gamma \|V^\star - V^\pi\|_\infty . ∎

With rewards in [0, 1] and V_0 = 0, an accuracy \varepsilon is reached after a number of sweeps k \ge \frac{\log\big(1/(\varepsilon(1 - \gamma))\big)}{1 - \gamma} , each costing O(S^2 A) operations. The factor 1/(1 - \gamma) is the price of a long effective horizon.

Policy iteration

Algorithm 1.9 — Policy iteration Start from a deterministic policy \pi_0 and repeat:

  1. evaluation: solve the linear system V^{\pi_k} = r^{\pi_k} + \gamma P^{\pi_k} V^{\pi_k};
  2. improvement: let \pi_{k+1} be greedy with respect to V^{\pi_k}, keeping \pi_k(s) when it is among the maximisers;
  3. stop when \pi_{k+1} = \pi_k.

Example 1.10 — A two-state MDP State 1 has a “safe” action (reward 1, stay in 1) and a “risky” one (reward 0, move to 2). In state 2, “safe” gives reward 2 and stays with probability 0.8, returning to state 1 otherwise; “risky” gives 0 and returns to 1. Take \gamma = 0.9.

  • Value iteration from V_0 = 0: V_1 = (1, 2), then V_2 = (1.9, 3.62), with “safe” greedy in both states.
  • At the third sweep, risky wins in state 1, since 0.9 \times 3.62 = 3.258 > 1 + 0.9 \times 1.9 = 2.71. So V_3 = (3.258, 4.948).
  • Policy iteration from (safe, safe): V = (10, 13.571). In state 1, risky is worth 0.9 \times 13.571 = 12.214 > 10; in state 2, safe keeps 13.571 > 9.
  • The new policy (risky, safe) has value V(2) = 2/0.118 and V(1) = 0.9\, V(2), and it is greedy with respect to its own value. Policy iteration stops after two improvements with

V^\star = (15.254,\ 16.949) .

Theorem 1.11 — Policy improvement and termination The values produced by policy iteration are non-decreasing, V^{\pi_{k+1}} \ge V^{\pi_k}, with a strict inequality in some state unless \pi_k is optimal. Policy iteration therefore stops after at most A^S iterations, and returns an optimal policy.

Proof. Greediness gives T^{\pi_{k+1}} V^{\pi_k} = T^\star V^{\pi_k} \ge T^{\pi_k} V^{\pi_k} = V^{\pi_k} . Applying the monotone operator T^{\pi_{k+1}} repeatedly, V^{\pi_k} \le T^{\pi_{k+1}} V^{\pi_k} \le (T^{\pi_{k+1}})^2 V^{\pi_k} \le \dots \to V^{\pi_{k+1}} .

If V^{\pi_{k+1}} = V^{\pi_k}, all these inequalities are equalities, so T^\star V^{\pi_k} = V^{\pi_k} and \pi_k is optimal by Theorem 1.7. Otherwise the value strictly increases, so no policy is visited twice; there are A^S deterministic policies. ∎

The bound A^S is very pessimistic. Ye (2011) proved that policy iteration needs a number of iterations polynomial in S and A for a fixed discount.

import numpy as np

def bellman_q(P, r, gamma, V):
    """Q(s,a) = r(s,a) + gamma * sum_s' P(s'|s,a) V(s'); P has shape (S, A, S)."""
    return r + gamma * P @ V

def value_iteration(P, r, gamma, tol=1e-8):
    V, k = np.zeros(P.shape[0]), 0
    while True:
        V_new = bellman_q(P, r, gamma, V).max(axis=1)
        k += 1
        if np.max(np.abs(V_new - V)) < tol:
            return V_new, k
        V = V_new

def policy_evaluation(P, r, gamma, pi):
    S = P.shape[0]
    P_pi, r_pi = P[np.arange(S), pi], r[np.arange(S), pi]
    return np.linalg.solve(np.eye(S) - gamma * P_pi, r_pi)

def policy_iteration(P, r, gamma):
    pi, k = np.zeros(P.shape[0], dtype=int), 0
    while True:
        V = policy_evaluation(P, r, gamma, pi)
        pi_new = bellman_q(P, r, gamma, V).argmax(axis=1)
        k += 1
        if np.array_equal(pi_new, pi):
            return V, pi, k
        pi = pi_new

# Example 1.10: two states, actions 0 = "safe", 1 = "risky"
P = np.zeros((2, 2, 2))
P[0, 0, 0] = 1.0                       # state 1, safe: stay
P[0, 1, 1] = 1.0                       # state 1, risky: go to state 2
P[1, 0] = [0.2, 0.8]                   # state 2, safe: back w.p. 0.2
P[1, 1, 0] = 1.0                       # state 2, risky: back to state 1
r = np.array([[1.0, 0.0], [2.0, 0.0]])
V, k = value_iteration(P, r, 0.9)
_, pi, k_pi = policy_iteration(P, r, 0.9)
print("two-state MDP: V* =", V.round(3), "after", k, "VI sweeps;",
      "PI policy", pi, "after", k_pi, "iterations")

# a random MDP: VI needs many sweeps, PI a handful of iterations
rng = np.random.default_rng(1)
S, A = 50, 4
P = rng.dirichlet(np.ones(S), size=(S, A))
r = rng.uniform(size=(S, A))
for gamma in (0.9, 0.99):
    V_vi, k_vi = value_iteration(P, r, gamma)
    V_pi, _, k_pi = policy_iteration(P, r, gamma)
    print(f"gamma={gamma}: VI sweeps={k_vi}, PI iterations={k_pi}, "
          f"max |V_VI - V_PI| = {np.max(np.abs(V_vi - V_pi)):.1e}")

The code counts the final check as an iteration: policy iteration evaluates two policies and confirms the second. On a random MDP with 50 states and 4 actions, value iteration needs 174 sweeps for \gamma = 0.9 and 1812 for \gamma = 0.99, while policy iteration stops after 3 iterations in both cases.

Linear programming and the finite horizon

Proposition 1.12 — Linear programming formulation Let \mu be a probability vector with \mu(s) > 0 for all s. Then V^\star is the unique solution of the linear program \min_{V \in \mathbb{R}^{\mathcal{S}}} \sum_s \mu(s) V(s) \quad \text{subject to} \quad V(s) \ge r(s, a) + \gamma (PV)(s, a) \ \text{ for all } (s, a) .

Proof. The constraints say V \ge T^\star V. By monotonicity, V \ge T^\star V \ge (T^\star)^2 V \ge \dots \to V^\star, so every feasible V dominates V^\star entrywise. Since V^\star is feasible and \mu > 0, it is the unique minimiser. ∎

In a problem with horizon H and no discount, the value depends on the remaining time. Backward induction computes V_H = 0 and V_h = T^\star V_{h+1} for h = H - 1, \dots, 0, the greedy action at step h being taken with respect to V_{h+1}.

The optimal policy is then Markov but non-stationary. The proof is Step 2 of Theorem 1.7, and the episodic algorithms of ch. 6 use this recursion.

Key takeaways — chapter 1

  • A stationary policy turns the MDP into a Markov chain; its value solves the linear system V = r^\pi + \gamma P^\pi V.
  • T^\star is a monotone \gamma-contraction; its fixed point is V^\star, and greedy policies with respect to V^\star are optimal.
  • Value iteration converges geometrically; a greedy policy loses at most 2\gamma/(1 - \gamma) times the value error.
  • Policy iteration improves monotonically and terminates; V^\star is also the solution of a linear program.

2. The first algorithms of reinforcement learning

In reinforcement learning the transition kernel and the rewards are unknown: the agent only sees transitions (s_t, a_t, r_t, s_{t+1}). This chapter shows how to estimate values from such samples, and how to learn Q^\star directly, without ever estimating the model.

Monte Carlo and temporal-difference evaluation

Definition 2.1 — Monte Carlo evaluation In an episodic task, or with returns truncated at a horizon where \gamma^t is negligible, the Monte Carlo estimate of V^\pi(s) averages the returns observed after the visits to s under \pi. With first visits only, each return is an unbiased sample of V^\pi(s), and the estimate converges by the law of large numbers.

Monte Carlo waits until the end of an episode and its variance grows with the horizon. Temporal differences instead use the Bellman equation itself as a target, replacing the unknown future by the current estimate. This is called bootstrapping.

Definition 2.2 — TD(0) After each transition under \pi, the temporal-difference error and the TD(0) update are \delta_t = r_t + \gamma V(s_{t+1}) - V(s_t), \qquad V(s_t) \leftarrow V(s_t) + \alpha_t\, \delta_t . Given the past and s_t = s, the target r_t + \gamma V(s_{t+1}) has mean (T^\pi V)(s): TD(0) is a noisy, asynchronous fixed-point iteration of T^\pi.

The convergence of TD(0), and of Q-learning below, follows from a single stochastic approximation theorem for contractions.

Theorem 2.3 — Asynchronous stochastic approximation (Jaakkola, Jordan and Singh, 1994; Tsitsiklis, 1994) Let H be a \gamma-contraction of \mathbb{R}^n in the sup norm, with fixed point x^\star. Consider, for each coordinate i, x_{t+1}(i) = \big(1 - \alpha_t(i)\big)\, x_t(i) + \alpha_t(i) \big[ (H x_t)(i) + w_t(i) \big] , where \alpha_t(i) \in [0, 1], \alpha_t(i) = 0 for the coordinates not updated at time t, and the steps are adapted to the past \mathcal{F}_t.

Assume that the noise is centred with a variance of at most quadratic growth, \mathbb{E}[w_t(i) \mid \mathcal{F}_t] = 0, \qquad \mathbb{E}[w_t(i)^2 \mid \mathcal{F}_t] \le C (1 + \|x_t\|_\infty^2) , and that almost surely, for every i, \sum_t \alpha_t(i) = \infty and \sum_t \alpha_t(i)^2 < \infty. Then, almost surely, x_t \to x^\star . The proof is in ch. 9.

Corollary 2.4 — Convergence of tabular TD(0) If every state is visited infinitely often and the step at the n-th visit of s is n^{-\beta} with 1/2 < \beta \le 1, then TD(0) converges to V^\pi almost surely.

Proof: apply Theorem 2.3 with H = T^\pi and w_t = r_t + \gamma V_t(s_{t+1}) - (T^\pi V_t)(s_t). Rewards are bounded, so the conditional variance of w_t is at most C(1 + \|V_t\|_\infty^2). ∎

Definition 2.5 — n-step returns and TD(\lambda) The n-step return bootstraps after n rewards, and the \lambda-return averages them geometrically, for \lambda \in [0, 1]: G_t^{(n)} = \sum_{k=0}^{n-1} \gamma^k r_{t+k} + \gamma^n V(s_{t+n}), \qquad G_t^\lambda = (1 - \lambda) \sum_{n \ge 1} \lambda^{n-1} G_t^{(n)} .

TD(\lambda) implements it online with an eligibility trace e_t = \gamma\lambda\, e_{t-1} + \mathbf{1}_{s_t} and the update V \leftarrow V + \alpha_t \delta_t e_t. The value \lambda = 0 gives TD(0), and \lambda = 1 gives Monte Carlo for offline updates.

The parameter \lambda trades bias for variance: small \lambda trusts the current estimate, large \lambda trusts the observed rewards.

Q-learning and SARSA

To act well, the agent needs Q^\star, the fixed point of the operator of Theorem 1.7 on action values. Watkins (1989) proposed to iterate it from samples.

Key result — the Q-learning update Q(s_t, a_t) \leftarrow Q(s_t, a_t) + \alpha_t \Big( r_t + \gamma \max_{a'} Q(s_{t+1}, a') - Q(s_t, a_t) \Big)

Theorem 2.6 — Q-learning (Watkins and Dayan, 1992) After each transition, Q-learning applies the update of the key result above. If every pair (s, a) is visited infinitely often and the steps of each pair satisfy the Robbins–Monro conditions, then Q_t \to Q^\star almost surely, whatever the behaviour policy.

Proof. Let H = T^\star act on \mathbb{R}^{\mathcal{S} \times \mathcal{A}}, a \gamma-contraction in the sup norm (Theorem 1.7). The update is the iteration of Theorem 2.3 with the noise w_t = r_t + \gamma \max_{a'} Q_t(s_{t+1}, a') - (T^\star Q_t)(s_t, a_t) .

Given the past and (s_t, a_t), the next state has law P(\cdot \mid s_t, a_t) and the reward has mean r(s_t, a_t), so w_t has mean zero. Its conditional variance is at most C(1 + \|Q_t\|_\infty^2), since rewards are bounded. Theorem 2.3 concludes. ∎

Q-learning is off-policy: the behaviour policy only has to visit every pair, while the target always uses the greedy action. SARSA is its on-policy counterpart.

Definition 2.7 — SARSA and GLIE exploration SARSA uses the next action actually played, a_{t+1}, in its target: Q(s_t, a_t) \leftarrow Q(s_t, a_t) + \alpha_t \big( r_t + \gamma Q(s_{t+1}, a_{t+1}) - Q(s_t, a_t) \big) .

An exploration scheme is GLIE (greedy in the limit with infinite exploration) if every pair is visited infinitely often and the policy becomes greedy with respect to Q_t as t \to \infty. SARSA with GLIE exploration converges to Q^\star (Singh, Jaakkola, Littman and Szepesvári, 2000).

Two exploration rules are standard. The \varepsilon-greedy rule plays the greedy action with probability 1 - \varepsilon and a uniform action otherwise; the choice \varepsilon = c/n_t(s) with 0 < c < 1, where n_t(s) counts the visits of s, gives a GLIE scheme.

The Boltzmann rule plays a with probability proportional to \exp(Q(s, a)/\tau). Neither rule is driven by uncertainty, which is why both fail on the river of the introduction (ch. 6).

Example 2.8 — One TD update in Example 1.10 Take V = (10, 13.571), the value of (safe, safe), \gamma = 0.9 and \alpha = 0.5. Evaluating the policy (risky, safe), the agent plays risky in state 1 and observes r = 0 and s' = 2.

  • The TD error is \delta = 0 + 0.9 \times 13.571 - 10 = 2.214.
  • The update moves V(1) halfway to the target: V(1) = 10 + 0.5 \times 2.214 = 11.107.
  • The true value of state 1 under (risky, safe) is 15.254; repeated updates propagate the larger value of state 2 backwards.
import numpy as np

# the two-state MDP of Example 1.10 (actions 0 = safe, 1 = risky)
P = np.zeros((2, 2, 2))
P[0, 0, 0], P[0, 1, 1], P[1, 1, 0] = 1.0, 1.0, 1.0
P[1, 0] = [0.2, 0.8]
r = np.array([[1.0, 0.0], [2.0, 0.0]])
gamma = 0.9

Q_star = np.zeros((2, 2))
for _ in range(2000):                       # value iteration on Q
    Q_star = r + gamma * P @ Q_star.max(axis=1)

def q_learning(exponent, n_steps=200_000, seed=0):
    """Off-policy Q-learning, uniform behaviour policy, step 1/N(s,a)^exponent."""
    rng = np.random.default_rng(seed)
    Q, N, s = np.zeros((2, 2)), np.zeros((2, 2)), 0
    errors = {}
    for t in range(1, n_steps + 1):
        a = rng.integers(2)
        s_next = rng.choice(2, p=P[s, a])
        N[s, a] += 1
        alpha = 1.0 / N[s, a] ** exponent
        target = r[s, a] + gamma * Q[s_next].max()
        Q[s, a] += alpha * (target - Q[s, a])
        s = s_next
        if t in (1_000, 10_000, 100_000, n_steps):
            errors[t] = round(float(np.max(np.abs(Q - Q_star))), 3)
    return Q, errors

print("Q* =", Q_star.round(2).tolist())
for exponent in (1.0, 0.7):
    Q, errors = q_learning(exponent)
    print(f"alpha = 1/N^{exponent}: errors {errors}, greedy policy {Q.argmax(axis=1)}")

Both runs find the greedy policy (risky, safe), but the errors differ. With \alpha = 1/N the sup-norm error is still 4.78 after 200 000 steps; with \alpha = N^{-0.7} it is 0.021 (ch. 9 explains why).

Model-based learning and the maximisation bias The alternative to Q-learning is certainty equivalence: estimate \hat P and \hat r by empirical frequencies and solve the estimated MDP. With a simulator that returns a sample of P(\cdot \mid s, a) for any pair, about SA/((1 - \gamma)^3 \varepsilon^2) samples, up to logarithmic factors, give an \varepsilon-accurate Q^\star; this is minimax optimal (Azar, Munos and Kappen, 2013).

The maximum in the Q-learning target is a biased estimate of the maximum of the means: \mathbb{E}\max \ge \max \mathbb{E}. Double Q-learning (van Hasselt, 2010) removes this bias with two estimators (ch. 5).

Key takeaways — chapter 2

  • Monte Carlo is unbiased with a high variance; TD bootstraps on the Bellman equation, with lower variance and a bias.
  • TD(0) and Q-learning are noisy fixed-point iterations of contractions; Theorem 2.3 gives their almost sure convergence.
  • Q-learning is off-policy and learns Q^\star from any exploratory behaviour; SARSA is on-policy and needs GLIE exploration.
  • Step sizes matter: 1/N is too slow, N^{-\beta} with 1/2 < \beta < 1 is a safer default.

3. The actors: policy iteration and policy gradient

Value-based methods derive a policy from a value function. Actor methods improve the policy itself, either by exact or approximate policy iteration steps or by gradient ascent on its value. This chapter gives the identity behind both, the policy gradient theorem, and what is known about global convergence.

Performance difference and approximate policy iteration

For a start distribution \mu, write V^\pi(\mu) = \sum_s \mu(s) V^\pi(s), define the advantage A^\pi(s, a) = Q^\pi(s, a) - V^\pi(s), and the discounted occupancy d^\pi_\mu(s) = (1 - \gamma) \sum_{t \ge 0} \gamma^t\, \mathbb{P}^\pi(s_t = s \mid s_0 \sim \mu) .

Lemma 3.1 — Performance difference (Kakade and Langford, 2002) For any two stationary policies \pi and \pi', V^{\pi'}(\mu) - V^\pi(\mu) = \frac{1}{1 - \gamma}\, \mathbb{E}_{s \sim d^{\pi'}_\mu,\ a \sim \pi'(\cdot \mid s)} \big[ A^\pi(s, a) \big] .

Proof. Run \pi' from s_0 \sim \mu and add a telescoping sum, using \gamma^t V^\pi(s_t) \to 0: V^{\pi'}(\mu) - V^\pi(\mu) = \mathbb{E}^{\pi'}\Big[ \sum_{t \ge 0} \gamma^t \big( r_t + \gamma V^\pi(s_{t+1}) - V^\pi(s_t) \big) \Big] .

Given (s_t, a_t), the bracket has mean Q^\pi(s_t, a_t) - V^\pi(s_t) = A^\pi(s_t, a_t). The definition of d^{\pi'}_\mu turns the discounted sum of expectations into the stated expectation. ∎

The lemma explains policy iteration in one line: a greedy policy \pi' has \mathbb{E}_{a \sim \pi'} A^\pi(s, a) \ge 0 in every state, so it cannot be worse. It also shows the difficulty of approximate improvement: the advantage is averaged under the occupancy of the new policy, which is unknown before it is played.

Proposition 3.2 — Approximate policy iteration (Bertsekas and Tsitsiklis, 1996) If each evaluation satisfies \|V_k - V^{\pi_k}\|_\infty \le \varepsilon and \pi_{k+1} is greedy with respect to V_k, then \limsup_{k \to \infty} \|V^\star - V^{\pi_k}\|_\infty \le \frac{2\gamma\, \varepsilon}{(1 - \gamma)^2} . The proof is in ch. 9.

The policy gradient theorem

Definition 3.3 — Parametric policies A parametric policy \pi_\theta is differentiable in \theta \in \mathbb{R}^d, with objective J(\theta) = V^{\pi_\theta}(\mu). Two families are standard:

  • the tabular softmax, \pi_\theta(a \mid s) \propto \exp(\theta_{s, a}), or its linear and neural versions \exp(f_\theta(s, a));
  • the Gaussian policy for continuous actions, with law \mathcal{N}(m_\theta(s), \sigma^2 I) in state s.

The score is \nabla_\theta \log \pi_\theta(a \mid s).

Key result — the policy gradient \nabla J(\theta) = \frac{1}{1 - \gamma}\, \mathbb{E}_{s \sim d^{\pi_\theta}_\mu,\ a \sim \pi_\theta(\cdot \mid s)} \big[ Q^{\pi_\theta}(s, a)\, \nabla_\theta \log \pi_\theta(a \mid s) \big]

Theorem 3.4 — Policy gradient theorem (Sutton, McAllester, Singh and Mansour, 2000) For a differentiable policy in a finite MDP, the gradient of J is the expectation of the key result above. The occupancy d^{\pi_\theta}_\mu is not differentiated.

Proof. Write \pi = \pi_\theta. Differentiate V^\pi(s) = \sum_a \pi(a \mid s) Q^\pi(s, a) and Q^\pi = r + \gamma P V^\pi: \nabla V^\pi(s) = \sum_a \nabla\pi(a \mid s)\, Q^\pi(s, a) + \gamma \sum_{s'} P^\pi(s, s')\, \nabla V^\pi(s') .

This is a Bellman equation for the vector \nabla V^\pi, with “reward” g(s) = \sum_a \nabla\pi(a \mid s) Q^\pi(s, a). By Proposition 1.4, \nabla V^\pi = \sum_t \gamma^t (P^\pi)^t g.

Averaging over s_0 \sim \mu gives \nabla J = (1 - \gamma)^{-1} \sum_s d^\pi_\mu(s)\, g(s). Finally \nabla\pi = \pi\, \nabla\log\pi turns the sum over actions into an expectation. ∎

For the tabular softmax, the score is \frac{\partial \log \pi(a \mid s)}{\partial\theta_{s, b}} = \mathbf{1}_{a = b} - \pi(b \mid s) , and the theorem becomes \frac{\partial J}{\partial \theta_{s, a}} = \frac{1}{1 - \gamma}\, d^{\pi_\theta}_\mu(s)\, \pi_\theta(a \mid s)\, A^{\pi_\theta}(s, a) .

Example 3.5 — The gradient in Example 1.10 Take the uniform policy, \theta = 0, and \mu = (1/2, 1/2). Then J = 7.294, and the gradient in state 1 is (0.795, -0.795): it favours “safe”, although “risky” is optimal.

  • Under the uniform policy, state 2 is often left by the risky action, so it is worth little, and moving to it does not pay.
  • The gradient in state 2, (2.672, -2.672), is larger: it first makes state 2 safe, and then the gradient in state 1 changes sign.
  • Gradient ascent with step 1 reaches J = 16.002 after 10 steps and 16.101 after 2000 steps, for an optimum of 16.102.

Algorithm 3.6 — REINFORCE with a baseline (Williams, 1992) Sample an episode (s_0, a_0, r_0, \dots) with \pi_\theta, compute the returns G_t = \sum_{k \ge t} \gamma^{k - t} r_k, and update \theta \leftarrow \theta + \alpha \sum_t \gamma^t \big( G_t - b(s_t) \big) \nabla_\theta \log \pi_\theta(a_t \mid s_t) .

For any baseline b(s), the extra term has mean zero: \mathbb{E}_{a \sim \pi(\cdot \mid s)}\big[ b(s) \nabla\log\pi(a \mid s) \big] = b(s)\, \nabla \sum_a \pi(a \mid s) = 0 . The baseline does not bias the estimate, and b = V^{\pi_\theta} replaces Q by the advantage, often reducing the variance by orders of magnitude.

import numpy as np

# two-state MDP of Example 1.10, softmax policy pi(a|s) ∝ exp(theta[s, a])
P = np.zeros((2, 2, 2))
P[0, 0, 0], P[0, 1, 1], P[1, 1, 0] = 1.0, 1.0, 1.0
P[1, 0] = [0.2, 0.8]
r = np.array([[1.0, 0.0], [2.0, 0.0]])
gamma, mu = 0.9, np.array([0.5, 0.5])

def softmax(theta):
    z = np.exp(theta - theta.max(axis=1, keepdims=True))
    return z / z.sum(axis=1, keepdims=True)

def J_and_grad(theta):
    pi = softmax(theta)
    P_pi = np.einsum("sa,sat->st", pi, P)
    r_pi = (pi * r).sum(axis=1)
    V = np.linalg.solve(np.eye(2) - gamma * P_pi, r_pi)
    Q = r + gamma * P @ V
    d = (1 - gamma) * np.linalg.solve(np.eye(2) - gamma * P_pi.T, mu)  # d_mu^pi
    grad = d[:, None] * pi * (Q - V[:, None]) / (1 - gamma)           # Theorem 3.4
    return mu @ V, grad

theta = np.zeros((2, 2))
J, g = J_and_grad(theta)
eps, fd = 1e-6, np.zeros((2, 2))
for i in range(2):
    for j in range(2):
        e = np.zeros((2, 2)); e[i, j] = eps
        fd[i, j] = (J_and_grad(theta + e)[0] - J_and_grad(theta - e)[0]) / (2 * eps)
print("J(uniform policy) =", round(J, 3))
print("policy-gradient theorem:", g.round(4).tolist())
print("finite differences:     ", fd.round(4).tolist())

for step in range(1, 2001):                  # exact gradient ascent, step 1
    J, g = J_and_grad(theta)
    theta += 1.0 * g
    if step in (10, 100, 2000):
        print(f"step {step:4d}: J = {J:.3f}, pi(risky|1) = {softmax(theta)[0, 1]:.3f}")

# REINFORCE on a 3-armed bandit: variance with and without a baseline
rng = np.random.default_rng(0)
means, offset = np.array([1.0, 1.5, 2.0]), 10.0
pi = np.ones(3) / 3
a = rng.choice(3, p=pi, size=100_000)
R = offset + means[a] + rng.normal(size=a.size)
score = np.eye(3)[a] - pi                       # grad of log softmax at theta = 0
for b, name in [(0.0, "no baseline"), (offset + means.mean(), "baseline = V")]:
    G = (R - b)[:, None] * score
    print(f"{name:13s}: mean grad {G.mean(0).round(3)}, total variance {G.var(0).sum():.2f}")

The finite differences confirm Theorem 3.4 to four digits. On the bandit, whose rewards are shifted by 10, both estimators have the same mean, close to the exact gradient (-1/6, 0, 1/6). The total variance per sample falls from 88.94 without a baseline to

0.73 \text{ with the baseline } b = V .

When does policy gradient find the optimum?

J is not concave in \theta, even for the tabular softmax. Still, a gradient-domination inequality shows that it has no bad stationary points when \mu covers the state space.

Proposition 3.7 — Gradient domination (Agarwal, Kakade, Lee and Mahajan, 2021) Use the direct parametrisation, where \pi(a \mid s) itself is the parameter, in a product of simplices. For any start distributions \rho and \mu, V^\star(\rho) - V^\pi(\rho) \le \frac{1}{1 - \gamma} \Big\| \frac{d^{\pi^\star}_\rho}{\mu} \Big\|_\infty \max_{\bar\pi} \big(\bar\pi - \pi\big)^\top \nabla_\pi V^\pi(\mu) .

Proof. By Lemma 3.1 with \pi' = \pi^\star, then bounding the average of A^\pi(s, \cdot) by its maximum, which is non-negative: V^\star(\rho) - V^\pi(\rho) \le \frac{1}{1 - \gamma} \sum_s d^{\pi^\star}_\rho(s) \max_a A^\pi(s, a) \le \frac{1}{1 - \gamma} \Big\| \frac{d^{\pi^\star}_\rho}{d^\pi_\mu} \Big\|_\infty \sum_s d^\pi_\mu(s) \max_a A^\pi(s, a) .

By Theorem 3.4, the gradient has the entries \frac{\partial V^\pi(\mu)}{\partial\pi(a \mid s)} = \frac{d^\pi_\mu(s)\, Q^\pi(s, a)}{1 - \gamma} . Since \sum_a \pi(a \mid s) Q^\pi(s, a) = V^\pi(s), the maximum over \bar\pi equals the last sum divided by 1 - \gamma.

Finally d^\pi_\mu \ge (1 - \gamma)\mu entrywise, by the term t = 0 of the occupancy. ∎

If \mu > 0 everywhere, every stationary point over the simplices is therefore globally optimal, and projected gradient ascent converges to an optimal policy. For the softmax, Agarwal and coauthors prove asymptotic convergence, and Mei, Xiao, Szepesvári and Schuurmans (2020) a rate O(1/t).

Definition 3.8 — Natural policy gradient (Kakade, 2001) The natural gradient preconditions by the Fisher information of the policy: \theta \leftarrow \theta + \eta\, F(\theta)^{\dagger} \nabla J(\theta), \qquad F(\theta) = \mathbb{E}_{s \sim d^{\pi_\theta}_\mu,\ a \sim \pi_\theta} \big[ \nabla\log\pi_\theta(a \mid s)\, \nabla\log\pi_\theta(a \mid s)^\top \big] .

For the tabular softmax, the update is a multiplicative-weights step (derivation in ch. 9): \pi_{k+1}(a \mid s) \propto \pi_k(a \mid s) \exp\big(\eta A^{\pi_k}(s, a)/(1 - \gamma)\big) . Started from the uniform policy, its error satisfies, for every \rho (Agarwal et al., 2021), V^\star(\rho) - V^{\pi_k}(\rho) \le \frac{\log A}{\eta k} + \frac{1}{(1 - \gamma)^2 k} .

The bound has no distribution-mismatch coefficient, and as \eta \to \infty the update becomes policy iteration: the natural gradient bridges the two views of the actor.

Definition 3.9 — Trust regions: TRPO and PPO Lemma 3.1 with d^{\pi'}_\mu replaced by the known d^{\pi_k}_\mu gives a surrogate objective, accurate when \pi' stays close to \pi_k: L_k(\theta) = \mathbb{E}_{s \sim d^{\pi_k}_\mu,\ a \sim \pi_k} \Big[ \rho_\theta(s, a)\, A^{\pi_k}(s, a) \Big], \qquad \rho_\theta(s, a) = \frac{\pi_\theta(a \mid s)}{\pi_k(a \mid s)} .

TRPO (Schulman, Levine, Abbeel, Jordan and Moritz, 2015) maximises L_k under a bound on the average KL divergence between \pi_k and \pi_\theta. PPO (Schulman, Wolski, Dhariwal, Radford and Klimov, 2017) maximises the clipped objective \mathbb{E}\Big[ \min\big( \rho_\theta A^{\pi_k},\ \mathrm{clip}(\rho_\theta, 1 - \epsilon, 1 + \epsilon)\, A^{\pi_k} \big) \Big] .

Key takeaways — chapter 3

  • The performance difference lemma writes any policy improvement as an average advantage under the new occupancy.
  • Approximate policy iteration loses a factor 2\gamma/(1 - \gamma)^2 on the evaluation error.
  • Policy gradient: \nabla J is (1 - \gamma)^{-1}\, \mathbb{E}[Q \nabla\log\pi]; a state baseline keeps it unbiased and cuts the variance.
  • With a covering start distribution, stationary points are global optima, but plain gradients can be slow; natural gradients and trust regions fix much of this.

4. The critics: reinforcement learning with function approximation

Tables of values do not scale: a state may be an image or a robot configuration. This chapter replaces V and Q by parametric “critics”, studies what temporal differences converge to, and shows when approximation errors stay controlled and when they explode.

Linear value approximation and the projected Bellman equation

Definition 4.1 — Linear architecture, weighted projection A linear architecture approximates V by V_w = \Phi w, where the rows of \Phi \in \mathbb{R}^{S \times k} are feature vectors \varphi(s)^\top and \Phi has full column rank.

For a distribution d > 0, let D = \mathrm{diag}(d) and \|v\|_d^2 = \sum_s d(s) v(s)^2. The orthogonal projection onto the span of \Phi for this norm is \Pi = \Phi (\Phi^\top D \Phi)^{-1} \Phi^\top D .

TD with approximation cannot reach V^\pi itself when it is outside the span. It solves the projected Bellman equation, which is well posed for the right norm.

Key result — the projected Bellman equation \Phi w_{\mathrm{TD}} = \Pi\, T^\pi (\Phi w_{\mathrm{TD}})

Proposition 4.2 — The projected Bellman operator is a contraction Let d be the stationary distribution of an irreducible P^\pi. Then \|P^\pi v\|_d \le \|v\|_d for every v.

Hence \Pi T^\pi is a \gamma-contraction for the norm \|\cdot\|_d.

Its fixed point \Phi w_{\mathrm{TD}} is characterised by A\, w_{\mathrm{TD}} = b, \qquad A = \Phi^\top D (I - \gamma P^\pi) \Phi, \qquad b = \Phi^\top D\, r^\pi .

Proof. By Jensen’s inequality and then stationarity of d, \|P^\pi v\|_d^2 = \sum_s d(s) \Big( \sum_{s'} P^\pi(s, s') v(s') \Big)^2 \le \sum_s d(s) \sum_{s'} P^\pi(s, s') v(s')^2 = \|v\|_d^2 .

An orthogonal projection is non-expansive, so \|\Pi T^\pi u - \Pi T^\pi v\|_d \le \gamma \|P^\pi(u - v)\|_d \le \gamma \|u - v\|_d .

The fixed-point equation says that the residual T^\pi \Phi w - \Phi w is D-orthogonal to the columns of \Phi, which is \Phi^\top D (r^\pi + \gamma P^\pi \Phi w - \Phi w) = 0. ∎

Theorem 4.3 — Convergence of linear TD(0) (Tsitsiklis and Van Roy, 1997) Along one trajectory of \pi, whose chain is irreducible and aperiodic, linear TD(0) updates w_{t+1} = w_t + \alpha_t\, \delta_t\, \varphi(s_t), \qquad \delta_t = r_t + \gamma \varphi(s_{t+1})^\top w_t - \varphi(s_t)^\top w_t . With Robbins–Monro steps, w_t \to w_{\mathrm{TD}} almost surely.

Key step: under the stationary law, the mean update is b - A w, and A is positive definite (not symmetric): w^\top A w = \|\Phi w\|_d^2 - \gamma \langle \Phi w, P^\pi \Phi w \rangle_d \ge (1 - \gamma)\, \|\Phi w\|_d^2 . The inequality is Cauchy–Schwarz with Proposition 4.2. The mean dynamics \dot w = b - A w is then globally stable, and a stochastic approximation argument with Markov noise concludes.

Theorem 4.4 — Quality of the TD fixed point Under the assumptions of Proposition 4.2, \|V^\pi - \Phi w_{\mathrm{TD}}\|_d \le \frac{1}{\sqrt{1 - \gamma^2}}\, \|V^\pi - \Pi V^\pi\|_d .

Proof. The error V^\pi - \Pi V^\pi is D-orthogonal to the span, which contains \Pi V^\pi - \Phi w_{\mathrm{TD}}. Pythagoras gives \|V^\pi - \Phi w_{\mathrm{TD}}\|_d^2 = \|V^\pi - \Pi V^\pi\|_d^2 + \|\Pi V^\pi - \Phi w_{\mathrm{TD}}\|_d^2 .

Since V^\pi = T^\pi V^\pi and \Phi w_{\mathrm{TD}} = \Pi T^\pi \Phi w_{\mathrm{TD}}, the second term is at most \gamma^2 \|V^\pi - \Phi w_{\mathrm{TD}}\|_d^2 by Proposition 4.2. Rearranging gives the claim. ∎

The TD solution is not the best approximation \Pi V^\pi, but it is within a factor 1/\sqrt{1 - \gamma^2} of it. The factor grows with the horizon: at \gamma = 0.95 it is 3.2.

Sample-based critics

Definition 4.5 — LSTD and fitted Q-iteration LSTD (Bradtke and Barto, 1996) replaces A and b by their empirical versions along a trajectory, and solves the linear system: \hat A_n = \sum_{t < n} \varphi(s_t) \big( \varphi(s_t) - \gamma \varphi(s_{t+1}) \big)^\top, \qquad \hat b_n = \sum_{t < n} r_t\, \varphi(s_t), \qquad \hat w_n = \hat A_n^{-1} \hat b_n .

Fitted Q-iteration (Ernst, Geurts and Wehenkel, 2005) works on a fixed data set of transitions (s_i, a_i, r_i, s'_i). It repeats one regression per iteration, over a class \mathcal{F} (trees, linear models, networks): Q_{k+1} \in \arg\min_{f \in \mathcal{F}} \sum_i \Big( f(s_i, a_i) - r_i - \gamma \max_{a'} Q_k(s'_i, a') \Big)^2 .

By the ergodic theorem (Theorem 0.2), \hat A_n/n \to A and \hat b_n/n \to b, so LSTD converges to w_{\mathrm{TD}} with no step size. Each step costs O(k^2) operations. LSPI (Lagoudakis and Parr, 2003) uses its action-value version as the evaluation step of approximate policy iteration.

Proposition 4.6 — Error propagation in approximate value iteration Let \pi_k be greedy with respect to Q_k, and assume that every regression step satisfies \|Q_{k+1} - T^\star Q_k\|_\infty \le \varepsilon. Then \limsup_{k \to \infty} \|V^\star - V^{\pi_k}\|_\infty \le \frac{2\varepsilon}{(1 - \gamma)^2} .

Proof. By the contraction, \|Q_{k+1} - Q^\star\|_\infty \le \varepsilon + \gamma \|Q_k - Q^\star\|_\infty , so the limit superior of \|Q_k - Q^\star\|_\infty is at most \varepsilon/(1 - \gamma).

For \pi greedy with respect to Q and \eta = \|Q - Q^\star\|_\infty, write Q^\star(s, \pi^\star(s)) - Q^\pi(s, \pi(s)) as the sum of four terms:

  • Q^\star(s, \pi^\star(s)) - Q(s, \pi^\star(s)) \le \eta;
  • Q(s, \pi^\star(s)) - Q(s, \pi(s)) \le 0, by greediness;
  • Q(s, \pi(s)) - Q^\star(s, \pi(s)) \le \eta;
  • Q^\star(s, \pi(s)) - Q^\pi(s, \pi(s)), which equals \gamma P(V^\star - V^\pi)(s, \pi(s)), so is at most \gamma \|V^\star - V^\pi\|_\infty.

Hence \|V^\star - V^\pi\|_\infty \le 2\eta/(1 - \gamma), and the claim follows. ∎

The sup norm is unrealistic for a regression. Munos (2007) and Munos and Szepesvári (2008) prove L_p versions, in which concentrability coefficients measure how far the occupancy of future policies is from the data distribution. These coefficients are the central difficulty of offline RL (ch. 10).

The deadly triad

Example 4.7 — Off-policy divergence (Tsitsiklis and Van Roy, 1997) Two states have the features 1 and 2, so that V_w = (w, 2w). Updates are made only on the transition from state 1 to state 2, with reward 0, as an off-policy data distribution could do. Each TD update multiplies w by the same factor: w \leftarrow w + \alpha (\gamma \cdot 2w - w) = \big(1 + \alpha(2\gamma - 1)\big)\, w .

  • For \gamma > 1/2 the factor exceeds 1 and w diverges, although w = 0 represents the true value exactly.
  • With \alpha = 0.1: after 100 updates w = 0.13 for \gamma = 0.4, and w = 2.2 \times 10^3 for \gamma = 0.9.

Sutton and Barto (2018, sec. 11.3) call the combination of function approximation, bootstrapping and off-policy data the deadly triad: any two are safe, all three can diverge. Baird (1995) built a seven-state example where even expected updates diverge.

Remedies replace the semi-gradient by a true gradient of the projected Bellman error \|\Pi T^\pi V_w - V_w\|_d^2, as in gradient-TD methods (Sutton et al., 2009), or slow the bootstrap target down, as the target networks of ch. 5 do.

import numpy as np

rng = np.random.default_rng(0)
S, gamma = 50, 0.95
# Markov chain of a fixed policy on a ring: right w.p. 0.6, left w.p. 0.4
P = np.zeros((S, S))
for s in range(S):
    P[s, (s + 1) % S], P[s, (s - 1) % S] = 0.6, 0.4
r = (np.arange(S) < 10).astype(float)          # reward 1 on states 0..9
V = np.linalg.solve(np.eye(S) - gamma * P, r)   # true value function
d = np.ones(S) / S                              # stationary distribution (uniform)
D = np.diag(d)
centres = np.linspace(0, S, 5, endpoint=False)
dist = np.abs(np.arange(S)[:, None] - centres)
dist = np.minimum(dist, S - dist)
Phi = np.exp(-(dist / 6.0) ** 2)                # 5 Gaussian bumps on the ring

def d_norm(v):
    return np.sqrt(v @ D @ v)

w_proj = np.linalg.solve(Phi.T @ D @ Phi, Phi.T @ D @ V)                # Pi V
A = Phi.T @ D @ (Phi - gamma * P @ Phi)
w_td = np.linalg.solve(A, Phi.T @ D @ r)                                # TD fixed point
print(f"||V - Pi V||_d     = {d_norm(V - Phi @ w_proj):.3f}")
print(f"||V - Phi w_TD||_d = {d_norm(V - Phi @ w_td):.3f}"
      f"  (bound {d_norm(V - Phi @ w_proj) / np.sqrt(1 - gamma**2):.3f})")

# sample-based LSTD and TD(0) along one trajectory of length n
n, s = 100_000, 0
A_hat, b_hat, w = np.zeros((5, 5)), np.zeros(5), np.zeros(5)
for t in range(1, n + 1):
    s_next = (s + 1) % S if rng.random() < 0.6 else (s - 1) % S
    phi, phi_next = Phi[s], Phi[s_next]
    A_hat += np.outer(phi, phi - gamma * phi_next)
    b_hat += r[s] * phi
    w += (2.0 / t ** 0.6) * (r[s] + gamma * phi_next @ w - phi @ w) * phi   # TD(0)
    s = s_next
w_lstd = np.linalg.solve(A_hat, b_hat)
print(f"LSTD  from samples: ||w - w_TD|| = {np.linalg.norm(w_lstd - w_td):.3f}")
print(f"TD(0) from samples: ||w - w_TD|| = {np.linalg.norm(w - w_td):.3f}")

# Example 4.7: off-policy updates on the transition 1 -> 2 only (features 1 and 2)
for g in (0.4, 0.9):
    w = 1.0
    for _ in range(100):
        w += 0.1 * (0.0 + g * 2 * w - w) * 1.0
    print(f"gamma = {g}: w after 100 off-policy TD updates = {w:.3g}")

On the ring, the best approximation has error 1.692 in the d-norm. The TD fixed point has error 1.889, well inside the bound 5.419 of Theorem 4.4. After 10^5 transitions, LSTD is at distance 0.149 from w_{\mathrm{TD}} and TD(0) at 0.195.

Actor–critic methods

An actor–critic algorithm runs a critic, learnt by TD, and an actor that follows the policy gradient with the critic in place of Q^\pi. Konda and Tsitsiklis (2000) proved its convergence with two time scales, the critic moving faster. The critic may bias the gradient, unless its features are chosen to match the actor.

Proposition 4.8 — Compatible function approximation (Sutton et al., 2000) Let f_w(s, a) = w^\top \nabla_\theta\log\pi_\theta(a \mid s), and let w^\star minimise the squared error \mathbb{E}_{s \sim d^{\pi_\theta}_\mu,\ a \sim \pi_\theta} \big[ (Q^{\pi_\theta}(s, a) - f_w(s, a))^2 \big] . Then the critic gives the exact gradient: \nabla J(\theta) = \frac{1}{1 - \gamma}\, \mathbb{E}_{s \sim d^{\pi_\theta}_\mu,\ a \sim \pi_\theta} \big[ f_{w^\star}(s, a)\, \nabla_\theta\log\pi_\theta(a \mid s) \big] .

Proof. The first-order condition of the least-squares problem reads \mathbb{E}\big[ (Q^{\pi_\theta} - f_{w^\star})\, \nabla_\theta\log\pi_\theta \big] = 0 . Substitute in Theorem 3.4. ∎

The same condition reads F(\theta)\, w^\star = (1 - \gamma) \nabla J(\theta): the compatible critic’s weights are, up to the factor 1 - \gamma, the natural gradient of Definition 3.8 (Kakade, 2001).

Key takeaways — chapter 4

  • With linear features and on-policy data, TD solves the projected Bellman equation, a contraction in the stationary norm.
  • The TD fixed point is within 1/\sqrt{1 - \gamma^2} of the best approximation; LSTD computes it without step sizes.
  • Approximate value iteration loses 2\varepsilon/(1 - \gamma)^2; concentrability coefficients govern the L_p versions.
  • Function approximation, bootstrapping and off-policy data together can diverge; compatible critics give unbiased actor–critic gradients.

5. Scaling up: towards deep RL and continuous MDPs

Deep networks can represent value functions and policies on images or high-dimensional states, but they make the bootstrapped regressions of ch. 4 unstable. Continuous actions make the maximum over actions an optimisation problem of its own. This chapter shows how deep Q-networks and deep actor–critic methods handle both, and solves the classical continuous MDP with a closed form, the linear-quadratic regulator.

Deep Q-networks

Algorithm 5.1 — Deep Q-network (Mnih et al., 2015) A network Q_\theta is trained from an \varepsilon-greedy behaviour with two devices:

  • a replay buffer of past transitions, from which minibatches are drawn uniformly;
  • a target network Q_{\theta^-}, a copy of Q_\theta refreshed every C steps.

Each step takes a gradient step on the loss L(\theta) = \mathbb{E}_{(s, a, r, s') \sim \text{buffer}} \Big[ \big( r + \gamma \max_{a'} Q_{\theta^-}(s', a') - Q_\theta(s, a) \big)^2 \Big] .

Between two refreshes the target is fixed, so the inner loop is a regression: DQN is a stochastic version of fitted Q-iteration (Definition 4.5), one iteration every C steps. The replay buffer reuses data and breaks the correlation of consecutive samples.

Proposition 5.2 — Overestimation and the double estimator Let \hat q(a) be unbiased estimates of values q(a), a = 1, \dots, K. Then \mathbb{E}\big[ \max_a \hat q(a) \big] \ge \max_a q(a) .

If \hat q' is an independent second set of unbiased estimates and \hat a = \arg\max_a \hat q(a), then \mathbb{E}[\hat q'(\hat a)] \le \max_a q(a).

Proof. The maximum is convex, so Jensen’s inequality gives the first claim. For the second, condition on \hat q: the conditional mean of \hat q'(\hat a) is q(\hat a) \le \max_a q(a). ∎

With K actions of equal value and independent standard Gaussian errors, the bias of the maximum is about 0.56 for K = 2 and 1.54 for K = 10. Bootstrapping propagates this bias through the states.

Double DQN (van Hasselt, Guez and Silver, 2016) chooses the action with the online network and evaluates it with the target network: y = r + \gamma\, Q_{\theta^-}\big(s', \arg\max_{a'} Q_\theta(s', a')\big) .

import numpy as np
import torch
from torch import nn

torch.set_num_threads(1)
torch.manual_seed(0)
rng = np.random.default_rng(0)

# chain MDP: 8 states, action 0 = left, 1 = right (succeeds w.p. 0.9)
S, A, gamma = 8, 2, 0.9
P = np.zeros((S, A, S)); R = np.zeros((S, A))
for s in range(S):
    P[s, 0, max(s - 1, 0)] = 1.0
    P[s, 1, min(s + 1, S - 1)] += 0.9
    P[s, 1, s] += 0.1
R[0, 0], R[S - 1, 1] = 0.2, 1.0
Q_star = np.zeros((S, A))
for _ in range(1000):
    Q_star = R + gamma * P @ Q_star.max(axis=1)

net = nn.Sequential(nn.Linear(S, 64), nn.ReLU(), nn.Linear(64, A))
target = nn.Sequential(nn.Linear(S, 64), nn.ReLU(), nn.Linear(64, A))
target.load_state_dict(net.state_dict())
opt = torch.optim.Adam(net.parameters(), lr=1e-3)
eye = torch.eye(S)
buffer, s = [], 0
for step in range(1, 8001):
    a = int(rng.integers(A))                       # uniform behaviour policy
    s_next = int(rng.choice(S, p=P[s, a]))
    buffer.append((s, a, R[s, a], s_next)); s = s_next
    if len(buffer) < 256:
        continue
    idx = rng.integers(len(buffer), size=64)       # experience replay
    bs, ba, br, bn = map(np.array, zip(*[buffer[i] for i in idx]))
    with torch.no_grad():                          # frozen target network
        y = torch.tensor(br, dtype=torch.float32) + gamma * target(eye[bn]).max(1).values
    q = net(eye[bs]).gather(1, torch.tensor(ba)[:, None]).squeeze(1)
    loss = ((q - y) ** 2).mean()
    opt.zero_grad(); loss.backward(); opt.step()
    if step % 200 == 0:                            # refresh the target
        target.load_state_dict(net.state_dict())
Q_dqn = net(eye).detach().numpy()
print("max |Q_DQN - Q*| =", round(float(np.abs(Q_dqn - Q_star).max()), 3))
print("greedy DQN policy:", Q_dqn.argmax(1), " optimal:", Q_star.argmax(1))

# discounted scalar LQR: x' = a x + b u + noise, cost q x^2 + rho u^2
a, b, q, rho, g = 1.2, 1.0, 1.0, 1.0, 0.95
p = q
for _ in range(500):                               # Riccati fixed-point iteration
    p = q + g * a**2 * p - (g * a * b * p) ** 2 / (rho + g * b**2 * p)
K = g * a * b * p / (rho + g * b**2 * p)
print(f"Riccati: p = {p:.4f}, gain K = {K:.4f}, closed loop a - bK = {a - b * K:.4f}")

On the chain, Q^\star ranges up to 10, and the network learnt from 8000 uniformly random transitions is within 0.29 of it in every pair, with the optimal greedy policy.

Continuous MDPs and the linear-quadratic regulator

Definition 5.3 — Continuous MDP A continuous MDP has states in \mathcal{S} \subseteq \mathbb{R}^n, actions in \mathcal{A} \subseteq \mathbb{R}^m, a transition kernel P(ds' \mid s, a) and a measurable reward. With bounded rewards, compact action sets and continuity of r and P in the action, the results of ch. 1 hold on bounded measurable functions. Then T^\star is a contraction and optimal policies can be chosen deterministic, stationary and measurable (Bertsekas and Shreve, 1978; Hernández-Lerma and Lasserre, 1996).

Quadratic costs are unbounded, so the linear-quadratic regulator falls outside this setting, but it has an explicit solution.

Theorem 5.4 — Discounted linear-quadratic regulator Let x_{t+1} = A x_t + B u_t + \xi_t, with i.i.d. noise of mean 0 and covariance W, and the reward -(x^\top Q x + u^\top R u), where Q \succeq 0 and R \succ 0. Let P \succeq 0 solve the discounted Riccati equation P = Q + \gamma A^\top P A - \gamma^2 A^\top P B\, (R + \gamma B^\top P B)^{-1} B^\top P A .

Then the quadratic function V(x) = -x^\top P x - \gamma\, \mathrm{tr}(PW)/(1 - \gamma) satisfies the Bellman optimality equation, with the linear greedy policy u = -K x, \qquad K = \gamma\, (R + \gamma B^\top P B)^{-1} B^\top P A .

Proof. Try V(x) = -x^\top P x - c. With u fixed, the expected next value is -(Ax + Bu)^\top P (Ax + Bu) - \mathrm{tr}(PW) - c, since the noise is centred.

The right-hand side of the Bellman equation is therefore the maximum over u of a concave quadratic. Its gradient vanishes at (R + \gamma B^\top P B) u = -\gamma B^\top P A x, which is u = -Kx.

Substituting back, the quadratic part in x matches -x^\top P x exactly when P solves the Riccati equation. The constants match when c = \gamma\, \mathrm{tr}(PW) + \gamma c. That this solution is the optimal value, among all policies of finite cost, requires a stabilisability condition and a growth argument; see Bertsekas (2017), vol. I, on linear systems with quadratic cost. ∎

Two features of this solution matter for learning. The optimal gain does not depend on the noise, which is certainty equivalence for control. And the Riccati iteration, P_0 = 0 then the right-hand side, is exactly value iteration on quadratic functions.

In the scalar example of the code, a = 1.2, b = q = \rho = 1 and \gamma = 0.95. The fixed point is p = 1.9322, the gain K = 0.7768, and the closed loop is stable although a > 1:

a - bK = 0.4232 .

Policy gradients for continuous actions

Theorem 5.5 — Deterministic policy gradient (Silver et al., 2014) Let \pi_\theta : \mathcal{S} \to \mathcal{A} be a deterministic policy, and assume that Q^{\pi_\theta}(s, a) is differentiable in a, with regularity conditions given in the paper. Then \nabla J(\theta) = \frac{1}{1 - \gamma}\, \mathbb{E}_{s \sim d^{\pi_\theta}_\mu} \Big[ \nabla_\theta \pi_\theta(s)^\top\, \nabla_a Q^{\pi_\theta}(s, a) \big|_{a = \pi_\theta(s)} \Big] .

Sketch: differentiate V^{\pi_\theta}(s) = Q^{\pi_\theta}(s, \pi_\theta(s)). The chain rule gives the term above, plus \gamma times the expected gradient of V^{\pi_\theta} at the next state. Unrolling as in Theorem 3.4 gives the occupancy.

DDPG (Lillicrap et al., 2016) combines this gradient with a deep critic, a replay buffer and slowly moving target networks. TD3 (Fujimoto, van Hoof and Meger, 2018) adds the minimum of two critics in the target, a deterministic counterpart of the double estimator of Proposition 5.2.

Proposition 5.6 — Entropy regularisation and the soft Bellman equation Add \tau\, \mathcal{H}(\pi(\cdot \mid s_t)) to each reward, where \mathcal{H} is the entropy and \tau > 0 a temperature. The soft Bellman operator is a \gamma-contraction: (T_\tau Q)(s, a) = r(s, a) + \gamma \sum_{s'} P(s' \mid s, a)\, \tau \log \sum_{a'} \exp\big( Q(s', a')/\tau \big) .

Its fixed point Q^\star_\tau gives the optimal regularised policy, the Boltzmann policy \pi^\star_\tau(a \mid s) \propto \exp\big(Q^\star_\tau(s, a)/\tau\big) .

Proof. For a vector q and a distribution p on actions, with Z = \sum_a e^{q(a)/\tau} and \sigma = e^{q/\tau}/Z, \sum_a p(a) q(a) + \tau\, \mathcal{H}(p) = \tau \log Z - \tau\, \mathrm{KL}(p \,\|\, \sigma) .

So the regularised greedy step is maximised by p = \sigma, with value \tau\log Z. The function q \mapsto \tau\log\sum_a e^{q(a)/\tau} is monotone and commutes with constant shifts, hence 1-Lipschitz in the sup norm, and T_\tau is a \gamma-contraction. The proof of Theorem 1.7 then applies. ∎

Since 0 \le \mathcal{H} \le \log A, the regularised and unregularised optimal values differ by at most \tau\log A/(1 - \gamma). Soft actor–critic (Haarnoja, Zhou, Abbeel and Levine, 2018) applies this principle to continuous actions, with a Gaussian actor trained to minimise, in each state, \mathrm{KL}\big(\pi(\cdot \mid s) \,\big\|\, \exp(Q(s, \cdot)/\tau)/Z(s)\big) .

Definition 5.7 — Generalised advantage estimation (Schulman, Moritz, Levine, Jordan and Abbeel, 2016) With TD errors \delta_t = r_t + \gamma V(s_{t+1}) - V(s_t) of a learnt critic, the GAE estimate of the advantage is \hat A_t = \sum_{l \ge 0} (\gamma\lambda)^l\, \delta_{t+l} , the advantage version of the \lambda-return of Definition 2.5.

PPO in practice combines parallel rollouts, GAE advantages, and several epochs of minibatch steps on the clipped objective of Definition 3.9.

The programming assignment announced on master-mva.com comes after this session; its content is not displayed. The solo projects of Projects and assessment are sized like such an assignment.

Key takeaways — chapter 5

  • DQN is fitted Q-iteration with a replay buffer and a target network; the maximum overestimates, and the double estimator removes the bias.
  • The linear-quadratic regulator has a quadratic value and a linear optimal policy given by the Riccati equation, which is value iteration on quadratics.
  • Deterministic policy gradients follow \nabla_\theta\pi\, \nabla_a Q; DDPG and TD3 build on them.
  • Entropy regularisation gives a soft Bellman contraction with a Boltzmann optimal policy (SAC); GAE and PPO are the standard on-policy recipe.

6. Exploration and exploitation

A learning agent must try actions whose value it does not know, at a cost, and exploit those it knows to be good. This chapter measures the cost by the regret, solves the trade-off for bandits, and extends the principle of optimism to MDPs, where it explains the river of the introduction.

Multi-armed bandits

Definition 6.1 — Stochastic bandit and regret A K-armed bandit is a set of reward laws \nu_1, \dots, \nu_K with means \mu_a, best mean \mu^\star = \max_a \mu_a and gaps \Delta_a = \mu^\star - \mu_a.

At each round the learner picks an arm A_t from the past and observes X_t \sim \nu_{A_t}. After T rounds, its regret is R_T = T \mu^\star - \mathbb{E}\Big[ \sum_{t=1}^T X_t \Big] . A bandit is an MDP with a single state.

Proposition 6.2 — Regret decomposition With N_a(T) the number of pulls of arm a up to time T, R_T = \sum_a \Delta_a\, \mathbb{E}[N_a(T)] . Proof: \mathbb{E}[X_t \mid A_t] = \mu_{A_t}, so the expected total reward is \sum_a \mu_a\, \mathbb{E}[N_a(T)], and \sum_a N_a(T) = T. ∎

A constant exploration rate \varepsilon pulls each arm about \varepsilon T/K times, a regret linear in T. The principle of optimism in the face of uncertainty instead plays the arm whose plausible value is highest.

Algorithm 6.3 — UCB1 (Auer, Cesa-Bianchi and Fischer, 2002) For rewards in [0, 1], pull each arm once, then pull the arm with the largest upper confidence bound, where \hat\mu_a is the empirical mean of arm a: A_t \in \arg\max_a \Big( \hat\mu_a(t-1) + \sqrt{\frac{2 \log t}{N_a(t-1)}} \Big) .

Theorem 6.4 — Regret of UCB1 For every bandit with rewards in [0, 1] and every T, R_T \le \sum_{a : \Delta_a > 0} \Big( \frac{8 \log T}{\Delta_a} + \Big(1 + \frac{\pi^2}{3}\Big) \Delta_a \Big) .

Key step: once N_a \ge 8\log T/\Delta_a^2, the bonus of arm a is at most \Delta_a/2.

Arm a can then be pulled only if the optimal arm’s index underestimates \mu^\star, or if \hat\mu_a overestimates \mu_a by more than its bonus. By Hoeffding’s inequality each event has probability at most t^{-4}; the full proof is in ch. 9.

Lai and Robbins showed that this order is necessary, with an instance-dependent constant that is the model of the results of ch. 7 and ch. 8.

Definition 6.5 — Consistent algorithm An algorithm is consistent on a class of bandits if, for every bandit of the class and every \alpha > 0, its regret satisfies R_T = o(T^\alpha).

Theorem 6.6 — Lai and Robbins (1985) Consider Bernoulli bandits, and write the Bernoulli KL divergence \mathrm{kl}(p, q) = p\log\frac{p}{q} + (1 - p)\log\frac{1 - p}{1 - q} . For every consistent algorithm and every suboptimal arm a, \liminf_{T \to \infty} \frac{\mathbb{E}[N_a(T)]}{\log T} \ge \frac{1}{\mathrm{kl}(\mu_a, \mu^\star)} .

The same holds for any one-parameter exponential family, with its KL divergence. The proof, a change of measure, is in ch. 9.

With Proposition 6.2, the theorem bounds the regret of every consistent algorithm from below.

Key result — the Lai–Robbins regret constant \liminf_{T \to \infty} \frac{R_T}{\log T} \ge \sum_{a : \Delta_a > 0} \frac{\Delta_a}{\mathrm{kl}(\mu_a, \mu^\star)}

Pinsker’s inequality, \mathrm{kl}(\mu_a, \mu^\star) \ge 2\Delta_a^2, bounds the constant by \sum_a 1/(2\Delta_a). Conversely, the KL divergence is at most the \chi^2 divergence, \Delta_a^2/(\mu^\star(1 - \mu^\star)), so UCB1 is optimal up to a constant factor when the means stay away from 0 and 1.

KL-UCB (ch. 7) and Thompson sampling reach the constant itself. Thompson sampling (Thompson, 1933) samples a mean for each arm from its posterior and plays the best sample. For Bernoulli arms with uniform priors it is asymptotically optimal (Kaufmann, Korda and Munos, 2012; Agrawal and Goyal, 2013).

Optimism in episodic MDPs

Definition 6.7 — Episodic MDP and regret An episodic MDP has horizon H, a fixed initial state s_1, rewards in [0, 1] and unknown P and r.

In episode k = 1, \dots, K the learner plays a non-stationary policy \pi_k for H steps. With T = KH steps in total, its regret is \mathrm{Regret}(K) = \sum_{k=1}^K \big( V^\star_1(s_1) - V^{\pi_k}_1(s_1) \big) .

Algorithm 6.8 — UCB-VI (Azar, Osband and Munos, 2017) At the start of episode k, form the empirical model (\hat P_k, \hat r_k) from the counts N_k(s, a). With L a logarithmic factor and c a constant, set the bonus b_k(s, a) = c H \sqrt{L/\max(1, N_k(s, a))}.

Compute optimistic values by backward induction, from \bar V_{H+1} = 0: \bar Q_h(s, a) = \min\Big( H,\ \hat r_k(s, a) + b_k(s, a) + \sum_{s'} \hat P_k(s' \mid s, a)\, \bar V_{h+1}(s') \Big), \qquad \bar V_h(s) = \max_a \bar Q_h(s, a) . Play the greedy policy with respect to \bar Q_h at step h.

Proposition 6.9 — Optimism For a suitable L = O(\log(SAT/\delta)), with probability at least 1 - \delta, the optimistic values dominate the optimal ones for all k, h, s, a: \bar Q_{k,h}(s, a) \ge Q^\star_h(s, a) .

Proof. By backward induction on h; the case h = H + 1 is trivial. If \bar V_{h+1} \ge V^\star_{h+1}, then, since \hat P_k \ge 0, \bar Q_h - Q^\star_h \ge (\hat r_k - r) + (\hat P_k - P) V^\star_{h+1} + b_k before clipping. Clipping at H is harmless, because Q^\star_h \le H.

Since V^\star_{h+1} is a fixed vector with values in [0, H], Hoeffding’s inequality applies to the average of r_i + V^\star_{h+1}(s'_i) over the N_k(s, a) samples of the pair. A union bound over pairs, steps and counts makes |(\hat r_k - r) + (\hat P_k - P)V^\star_{h+1}| \le b_k everywhere with probability 1 - \delta. ∎

Theorem 6.10 — Regret of UCB-VI (Azar, Osband and Munos, 2017) With Hoeffding bonuses, with probability at least 1 - \delta, \mathrm{Regret}(K) = \tilde O\big( H \sqrt{SAT} + H^2 S^2 A \big) , where \tilde O hides logarithmic factors. With Bernstein bonuses, which use the empirical variance of V, the leading term becomes \sqrt{HSAT} for T large enough.

Key step: by optimism, the regret of episode k is at most \bar V_{k,1}(s_1) - V^{\pi_k}_1(s_1). Along the trajectory, this gap is a sum of bonuses, a martingale, and a model-error term. By Cauchy–Schwarz, the bonuses sum to at most cH\sqrt{L} \sum_{s,a} 2\sqrt{N_K(s, a)} \le 2cH\sqrt{L\, SAT} . Details in ch. 9.

A lower bound of order \sqrt{HSAT} holds for every algorithm (Domingues, Ménard, Kaufmann and Valko, 2021), so the Bernstein version is minimax optimal up to logarithmic factors.

The Bayesian alternative is posterior sampling (PSRL; Osband, Russo and Van Roy, 2013). At each episode, sample an MDP from the posterior, for example Dirichlet laws on the transitions, and play its optimal policy. Its Bayesian regret is \tilde O(HS\sqrt{AT}), and it is often better than optimism in practice.

import numpy as np

# RiverSwim-type chain (Strehl and Littman, 2008): 6 states, 0 = left, 1 = right
S, A, H, K = 6, 2, 20, 2000
P = np.zeros((S, A, S)); R = np.zeros((S, A))
for s in range(S):
    P[s, 0, max(s - 1, 0)] = 1.0                       # swimming with the current
    if s == 0:
        P[s, 1, [0, 1]] = [0.6, 0.4]
    elif s == S - 1:
        P[s, 1, [s - 1, s]] = [0.4, 0.6]
    else:
        P[s, 1, [s - 1, s, s + 1]] = [0.05, 0.6, 0.35]
R[0, 0], R[S - 1, 1] = 0.005, 1.0

def backward_induction(P, R, bonus=0.0):
    """Optimal H-step policy of the model (P, R + bonus); values clipped at H - h."""
    V, pi = np.zeros((H + 1, S)), np.zeros((H, S), dtype=int)
    for h in range(H - 1, -1, -1):
        Q = np.minimum(R + bonus + P @ V[h + 1], H - h)
        pi[h], V[h] = Q.argmax(1), Q.max(1)
    return pi, V

def policy_value(pi):
    V = np.zeros(S)
    for h in range(H - 1, -1, -1):
        V = R[np.arange(S), pi[h]] + P[np.arange(S), pi[h]] @ V
    return V[0]

V_star = backward_induction(P, R)[1][0, 0]

def run(agent, c=0.5, seed=0):
    rng = np.random.default_rng(seed)
    N, Nsas, Rsum = np.zeros((S, A)), np.zeros((S, A, S)), np.zeros((S, A))
    Q, regret = np.zeros((H, S, A)), 0.0
    for k in range(K):
        if agent == "ucbvi":                           # optimism in the face of uncertainty
            n = np.maximum(N, 1)
            P_hat = np.where(N[..., None] > 0, Nsas / n[..., None], 1.0 / S)
            bonus = c * np.sqrt(np.log(S * A * H * K) / n)
            pi = backward_induction(P_hat, Rsum / n, bonus)[0]
        else:                                          # epsilon-greedy Q-learning
            pi = Q.argmax(2)
        regret += V_star - policy_value(pi)
        s = 0
        for h in range(H):
            a = pi[h, s]
            if agent == "qlearning" and rng.random() < 0.1:
                a = rng.integers(A)
            s2 = rng.choice(S, p=P[s, a])
            N[s, a] += 1; Nsas[s, a, s2] += 1; Rsum[s, a] += R[s, a]
            if agent == "qlearning":
                alpha = (H + 1) / (H + N[s, a])
                target = R[s, a] + (Q[h + 1, s2].max() if h + 1 < H else 0.0)
                Q[h, s, a] += alpha * (target - Q[h, s, a])
            s = s2
    return regret, pi

print(f"V*(start) = {V_star:.3f}")
for agent, c in [("qlearning", None), ("ucbvi", 0.5), ("ucbvi", 20.0)]:
    regret, pi = run(agent, c)
    print(f"{agent:10s} c={c}: regret after {K} episodes = {regret:7.1f}, "
          f"policy at step 1 = {pi[0]}")

Swimming right is optimal in every state, with V^\star_1(s_1) = 3.064. Q-learning with \varepsilon = 0.1 starts from pessimistic values, finds the small reward at the left bank first and never revisits that belief: its regret, 5929, grows linearly. UCB-VI with c = 0.5 has regret 73.3 and plays the optimal policy at the end.

With the worst-case scale c = H = 20 the bonuses dominate for the whole run, and the regret after 2000 episodes is 6088. The theory gives the rate, not the constants: practical implementations shrink the bonus or use posterior sampling.

Key takeaways — chapter 6

  • Regret is the sum, over suboptimal arms or pairs, of gaps times numbers of plays; constant \varepsilon-greedy exploration has linear regret.
  • UCB1 has regret O(\sum_a \log T/\Delta_a); Lai and Robbins show that \log T/\mathrm{kl}(\mu_a, \mu^\star) pulls are necessary.
  • In MDPs, optimistic backward induction with Hoeffding bonuses dominates Q^\star and has regret \tilde O(H\sqrt{SAT}); Bernstein bonuses reach the minimax rate \sqrt{HSAT}.
  • Posterior sampling is a strong Bayesian alternative; constants of worst-case bonuses are far too conservative in practice.

7. Average-reward RL and instance-optimal algorithms

A robot or a recommender that runs indefinitely has no natural discount. This chapter defines the long-run average reward, its optimality equation, and regret in this setting, then asks what the best possible regret is on a given MDP, not in the worst case.

Gain, bias and the optimality equation

Definition 7.1 — Gain, communicating MDPs, diameter The gain of a policy is its long-run average reward, g^\pi(s) = \lim_{T \to \infty} \frac{1}{T}\, \mathbb{E}^\pi\Big[ \sum_{t=0}^{T-1} r_t \,\Big|\, s_0 = s \Big] . If P^\pi has a single recurrent class with stationary law d^\pi, the gain is the constant \sum_s d^\pi(s) r^\pi(s), by Theorem 0.2.

An MDP is communicating if every state can be reached from every other one under some policy. Its diameter D is the largest, over pairs s \ne s', of the smallest expected time to go from s to s'.

Definition 7.2 — Bias and Poisson equation For such a policy, the bias h^\pi solves the Poisson equation, unique up to an additive constant: g^\pi \mathbf{1} + h^\pi = r^\pi + P^\pi h^\pi .

It measures the transient advantage of starting in s. With the normalisation d^\pi h^\pi = 0, the discounted value has the expansion, as \gamma \to 1 (Puterman, 1994, ch. 8), V^\pi_\gamma = \frac{g^\pi}{1 - \gamma}\, \mathbf{1} + h^\pi + o(1) .

Key result — the average-reward optimality equation g^\star + h^\star(s) = \max_a \Big[ r(s, a) + \sum_{s'} P(s' \mid s, a)\, h^\star(s') \Big]

Theorem 7.3 — Average-reward optimality equation In a communicating finite MDP there exist a constant g^\star and a vector h^\star that solve the key equation above in every state s. Then g^\star is the optimal gain from every state, and a policy that attains the maximum in every state is gain-optimal.

Proof. Optimality. For any policy, possibly history-dependent, the equation gives r(s_t, a_t) \le g^\star + h^\star(s_t) - (P h^\star)(s_t, a_t) . Take expectations and sum over t < T; the terms in h^\star telescope in expectation: \mathbb{E}\Big[ \sum_{t < T} r_t \Big] \le T g^\star + h^\star(s_0) - \mathbb{E}\, h^\star(s_T) \le T g^\star + \mathrm{sp}(h^\star) , where \mathrm{sp}(h) = \max h - \min h. Dividing by T shows that no policy beats g^\star; a maximising policy turns the inequalities into equalities.

Existence follows from the vanishing-discount limit (1 - \gamma) V^\star_\gamma \to g^\star, with h^\star a limit point of V^\star_\gamma - V^\star_\gamma(s_0)\mathbf{1}; see ch. 9. ∎

Algorithm 7.4 — Relative value iteration With (Th)(s) = \max_a [r(s, a) + (Ph)(s, a)] and a reference state s_0, iterate h_{k+1} = T h_k - (T h_k)(s_0)\, \mathbf{1} . For unichain aperiodic MDPs, h_k \to h^\star and (T h_k)(s_0) - h_k(s_0) \to g^\star (Puterman, 1994, sec. 8.5). The operator T is non-expansive for the span seminorm.

Proposition 7.5 — Span and diameter (Bartlett and Tewari, 2009) In a communicating MDP with rewards in [0, 1], \mathrm{sp}(h^\star) \le D .

Proof. Since r \ge 0, the optimality equation gives h^\star(x) \ge -g^\star + (Ph^\star)(x, a) for every action.

Fix s, s', and follow from s' the policy that reaches s at a time \tau with \mathbb{E}\tau \le D.

By optional stopping, and since g^\star \le 1, h^\star(s') \ge h^\star(s) - g^\star\, \mathbb{E}\tau \ge h^\star(s) - D . ∎

The diameter, or the span of the bias, replaces the horizon 1/(1 - \gamma) of the discounted setting: it is the scale of the values, and the regret bounds below depend on it.

import numpy as np

# the river chain of ch. 6, now as a continuing (average-reward) MDP
S, A = 6, 2
P = np.zeros((S, A, S)); R = np.zeros((S, A))
for s in range(S):
    P[s, 0, max(s - 1, 0)] = 1.0
    if s == 0:
        P[s, 1, [0, 1]] = [0.6, 0.4]
    elif s == S - 1:
        P[s, 1, [s - 1, s]] = [0.4, 0.6]
    else:
        P[s, 1, [s - 1, s, s + 1]] = [0.05, 0.6, 0.35]
R[0, 0], R[S - 1, 1] = 0.005, 1.0

h = np.zeros(S)                                  # relative value iteration
for it in range(5000):
    Th = (R + P @ h).max(axis=1)
    g, h_new = Th[0] - h[0], Th - Th[0]
    if np.max(np.abs(h_new - h)) < 1e-12:
        break
    h = h_new
gaps = g + h[:, None] - (R + P @ h)              # Delta(s,a) >= 0, zero for optimal a
print(f"gain g* = {g:.4f} after {it} sweeps; bias h* = {h.round(3)}")
print("gaps Delta(s, left) =", gaps[:, 0].round(3))

D = 0.0                                          # diameter: worst fastest hitting time
for target in range(S):
    T = np.zeros(S)
    for _ in range(10_000):
        T_new = 1 + (P @ T).min(axis=1)
        T_new[target] = 0.0
        if np.max(np.abs(T_new - T)) < 1e-10:
            break
        T = T_new
    D = max(D, T.max())
print(f"span of h* = {h.max() - h.min():.3f} <= diameter D = {D:.2f}")

for gamma in (0.9, 0.99, 0.999):                 # vanishing discount: (1-gamma) V* -> g*
    V = np.zeros(S)
    for _ in range(200_000):
        V_new = (R + gamma * P @ V).max(axis=1)
        if np.max(np.abs(V_new - V)) < 1e-10:
            break
        V = V_new
    print(f"gamma = {gamma}: (1 - gamma) V*(0) = {(1 - gamma) * V[0]:.4f}")

def kl_bern(p, q):
    p, q = np.clip(p, 1e-12, 1 - 1e-12), np.clip(q, 1e-12, 1 - 1e-12)
    return p * np.log(p / q) + (1 - p) * np.log((1 - p) / (1 - q))

def kl_ucb(mean, n, t):
    lo, hi = mean, 1.0                           # bisection: largest q with n kl <= log t
    for _ in range(60):
        mid = (lo + hi) / 2
        lo, hi = (mid, hi) if n * kl_bern(mean, mid) <= np.log(t) else (lo, mid)
    return lo

for mean in (0.3, 0.95):
    print(f"mean {mean}, n = 20, t = 1000: KL-UCB index {kl_ucb(mean, 20, 1000):.4f}, "
          f"UCB1 index {mean + np.sqrt(2 * np.log(1000) / 20):.4f}")

On the river chain, relative value iteration converges in 140 sweeps to g^\star = 0.4286. The bias rises from 0 at the left bank to 6.727 at the right bank, below the diameter 15.69. The values (1 - \gamma)V^\star_\gamma(s_0) approach g^\star slowly: 0.120, 0.375 and 0.423 for \gamma = 0.9, 0.99 and 0.999.

Regret, optimism and instance optimality

Definition 7.6 — Regret in average reward In a communicating MDP, the regret of a learning algorithm after T steps is R_T = T g^\star - \sum_{t=0}^{T-1} r_t .

Theorem 7.7 — UCRL2 (Jaksch, Ortner and Auer, 2010) UCRL2 keeps a confidence set of MDPs, with L_1 balls around the empirical transition laws and intervals around the empirical rewards. In each episode it plays the optimal policy of the most optimistic MDP of the set, computed by extended value iteration, until the count of some pair doubles.

With probability at least 1 - \delta, its regret satisfies R_T = \tilde O\big( D S \sqrt{AT} \big) . Conversely, every algorithm has regret \Omega(\sqrt{DSAT}) on some MDP with these parameters.

These are worst-case statements. On a fixed MDP, the regret can be logarithmic, and the right constant comes from the gaps of the optimality equation, exactly as for bandits.

Proposition 7.8 — Regret decomposition by gaps Define the gaps of the optimality equation, \Delta(s, a) = g^\star + h^\star(s) - r(s, a) - (Ph^\star)(s, a) \ge 0 , and let N_T(s, a) be the number of plays of (s, a) before T. Then \Big| \mathbb{E}[R_T] - \sum_{s, a} \Delta(s, a)\, \mathbb{E}[N_T(s, a)] \Big| \le \mathrm{sp}(h^\star) .

Proof. By definition of the gaps, r_t has the conditional mean g^\star + h^\star(s_t) - \Delta(s_t, a_t) - (Ph^\star)(s_t, a_t) . Summing over t < T, the terms h^\star(s_t) - (Ph^\star)(s_t, a_t) add up to h^\star(s_0) - h^\star(s_T) plus a martingale of mean zero. ∎

For a bandit, \Delta(s, a) is the gap \Delta_a and the proposition is Proposition 6.2. On the river chain, the gaps of the action “left” are 0.424 at the left bank and between 1.5 and 1.86 elsewhere.

Theorem 7.9 — Instance-dependent lower bound (Burnetas and Katehakis, 1997) Consider ergodic MDPs, where every stationary policy induces an irreducible chain, with unknown transition laws. For every consistent algorithm, \liminf_{T \to \infty} \frac{\mathbb{E}[R_T]}{\log T} \ge C(M) = \sum_{(s, a) \text{ critical}} \frac{\Delta(s, a)}{K_{s,a}(M)} .

Here K_{s,a}(M) is the smallest KL divergence from P(\cdot \mid s, a) to a law q that would make a strictly better than the optimal action in s, that is r(s, a) + q^\top h^\star > g^\star + h^\star(s).

A pair is critical when such a q exists. Burnetas and Katehakis also give an index policy that attains C(M).

The bound is the MDP version of Theorem 6.6. Algorithms that match such constants are called instance optimal; they replace Hoeffding bonuses by KL divergences.

Definition 7.10 — KL-UCB and IMED indices For Bernoulli arms, KL-UCB (Garivier and Cappé, 2011) plays the arm with the largest index U_a(t) = \max\Big\{ q \in [\hat\mu_a, 1] : N_a\, \mathrm{kl}(\hat\mu_a, q) \le \log t + c\log\log t \Big\} .

IMED (Honda and Takemura, 2015) plays the arm minimising N_a\, \mathrm{kl}(\hat\mu_a, \hat\mu^\star) + \log N_a, with no optimisation. Both attain the Lai–Robbins constant.

The KL index adapts to the variance of the arm. With n = 20 pulls at t = 1000 (and c = 0), an empirical mean 0.3 gets the KL-UCB index 0.703 and the UCB1 index 1.131. For a mean of 0.95 the KL-UCB index is just below 1, while the UCB1 index is 1.781, larger than any possible mean.

The same ideas extend to MDPs. KL-UCRL (Filippi, Cappé and Garivier, 2010) uses KL confidence sets in UCRL2. IMED-RL (Pesquerel and Maillard, 2022) extends IMED to ergodic MDPs and attains the Burnetas–Katehakis constant.

Key takeaways — chapter 7

  • The gain and the bias solve g^\star + h^\star = \max_a [r + Ph^\star]; any maximiser is gain-optimal, and the span of h^\star is at most the diameter.
  • Relative value iteration computes (g^\star, h^\star); the discounted value behaves like g^\star/(1 - \gamma) + h^\star.
  • UCRL2 has regret \tilde O(DS\sqrt{AT}), against a lower bound \Omega(\sqrt{DSAT}).
  • On a fixed MDP, regret is a sum of gaps times plays; the Burnetas–Katehakis constant is attained by KL-based indices.

8. Bandit methods for pure exploration and planning

Sometimes rewards collected during learning do not count: only the final decision does. This chapter studies how few samples suffice to identify the best arm with a prescribed confidence, and uses the same ideas to plan in an MDP with a simulator.

Best-arm identification with fixed confidence

Definition 8.1 — \delta-correct identification A strategy for best-arm identification has a sampling rule, a stopping time \tau_\delta and a recommendation \hat a. It is \delta-correct if, for every bandit of the class with a unique best arm a^\star, \mathbb{P}\big( \tau_\delta < \infty,\ \hat a \ne a^\star \big) \le \delta . The goal is to minimise the expected number of samples, \mathbb{E}[\tau_\delta].

Algorithm 8.2 — Successive elimination (Even-Dar, Mannor and Mansour, 2006) In round n, sample every active arm once. With rewards in [0, 1], eliminate every arm a such that \max_b \hat\mu_b - \hat\mu_a \ge 2 r_n, \qquad r_n = \sqrt{\frac{\log(4Kn^2/\delta)}{2n}} . Stop when one arm is left, and recommend it.

Theorem 8.3 — Sample complexity of successive elimination Successive elimination is \delta-correct. With probability at least 1 - \delta, its number of samples is at most of order \sum_a \frac{1}{\Delta_a^2} \log \frac{K}{\delta\, \Delta_a} , where \Delta_{a^\star} is the smallest positive gap.

Proof sketch: by Hoeffding and a union bound, \sum_n \sum_a \delta/(2Kn^2) \le \delta, so all confidence intervals hold with probability 1 - \delta. Then the best arm is never eliminated, and arm a is eliminated as soon as 4 r_n \le \Delta_a.

Theorem 8.4 — Lower bound and characteristic time (Garivier and Kaufmann, 2016) Let d be the KL divergence of the family (Gaussian, Bernoulli), and \mathrm{Alt}(\mu) the set of bandits whose best arm differs from that of \mu. Every \delta-correct strategy satisfies \mathbb{E}_\mu[\tau_\delta] \ge T^\star(\mu)\, \mathrm{kl}(\delta, 1 - \delta), \qquad T^\star(\mu)^{-1} = \sup_{w \in \Sigma_K} \inf_{\lambda \in \mathrm{Alt}(\mu)} \sum_a w_a\, d(\mu_a, \lambda_a) . Here \Sigma_K is the simplex of weights on the K arms. Since \mathrm{kl}(\delta, 1 - \delta) \sim \log(1/\delta), the ratio \mathbb{E}[\tau_\delta]/\log(1/\delta) is asymptotically at least T^\star(\mu).

Proof. Key step, the transportation lemma (Kaufmann, Cappé and Garivier, 2016): for \lambda \in \mathrm{Alt}(\mu), \sum_a \mathbb{E}_\mu[N_a(\tau_\delta)]\, d(\mu_a, \lambda_a) \ge \mathrm{kl}(\delta, 1 - \delta) . The left side is the KL divergence between the laws of the observations under \mu and \lambda.

The event \{\hat a = a^\star(\mu)\} has probability at least 1 - \delta under \mu and at most \delta under \lambda.

The data-processing inequality concludes.

Write \mathbb{E}_\mu[N_a] as w_a\, \mathbb{E}_\mu[\tau_\delta], take the infimum over \lambda, then bound by the supremum over w. ∎

Key result — the sample complexity of best-arm identification \mathbb{E}_\mu[\tau_\delta] \ge T^\star(\mu)\, \mathrm{kl}(\delta, 1 - \delta) \approx T^\star(\mu) \log(1/\delta)

The maximising weights w^\star(\mu) are the proportions in which an optimal strategy samples the arms. For two Gaussian arms of variance \sigma^2 and gap \Delta, w^\star = (1/2, 1/2) and T^\star = 8\sigma^2/\Delta^2.

Definition 8.5 — GLR stopping and Track-and-Stop For an empirical leader a and another arm b, with \hat\mu_{ab} their weighted mean, the generalised likelihood ratio statistic is Z_{a,b}(t) = N_a\, d(\hat\mu_a, \hat\mu_{ab}) + N_b\, d(\hat\mu_b, \hat\mu_{ab}) . The Chernoff stopping rule stops when \min_{b} Z_{a,b}(t) exceeds a threshold of order \log((1 + \log t)/\delta).

Track-and-Stop samples so that the proportions N_a(t)/t track the optimal weights w^\star(\hat\mu(t)) of the current estimate, with a forced exploration of order \sqrt{t}. It is \delta-correct and asymptotically optimal (Garivier and Kaufmann, 2016): \frac{\mathbb{E}[\tau_\delta]}{\log(1/\delta)} \xrightarrow[\delta \to 0]{} T^\star(\mu) .

import numpy as np
from scipy.optimize import minimize

mu, delta = np.array([0.5, 0.45, 0.4, 0.3]), 0.05     # Bernoulli arms, arm 0 is best
K = mu.size

def successive_elimination(rng):
    active, sums, n, pulls = list(range(K)), np.zeros(K), 0, 0
    while len(active) > 1:
        n += 1                                         # one more pull of each active arm
        sums[active] += rng.random(len(active)) < mu[active]
        pulls += len(active)
        means = sums / n
        radius = np.sqrt(np.log(4 * K * n**2 / delta) / (2 * n))
        best = max(active, key=lambda a: means[a])
        active = [a for a in active if means[best] - means[a] < 2 * radius]
    return active[0], pulls                            # recommendation, total samples

rng = np.random.default_rng(0)
runs = [successive_elimination(rng) for _ in range(50)]
print(f"successive elimination: {sum(rec != 0 for rec, _ in runs)} errors in 50 runs, "
      f"{np.mean([p for _, p in runs]):.0f} samples on average")

def kl(p, q):
    return p * np.log(p / q) + (1 - p) * np.log((1 - p) / (1 - q))

def inner(w):                                          # inf over the alternative set
    vals = []
    for a in range(1, K):
        m = (w[0] * mu[0] + w[a] * mu[a]) / (w[0] + w[a])
        vals.append(w[0] * kl(mu[0], m) + w[a] * kl(mu[a], m))
    return min(vals)

res = minimize(lambda z: -inner(np.exp(z) / np.exp(z).sum()), np.zeros(K),
               method="Nelder-Mead", options={"xatol": 1e-8, "fatol": 1e-12, "maxiter": 5000})
w_opt = np.exp(res.x) / np.exp(res.x).sum()
T_star = 1 / inner(w_opt)
kl_delta = (1 - 2 * delta) * np.log((1 - delta) / delta)   # kl(delta, 1 - delta)
print(f"optimal proportions w* = {w_opt.round(3)}, T*(mu) = {T_star:.0f}")
print(f"lower bound T*(mu) kl(delta, 1 - delta) = {T_star * kl_delta:.0f} samples")

On four Bernoulli arms with means (0.5, 0.45, 0.4, 0.3), the optimal weights put 92 % of the samples on the two best arms, and T^\star(\mu) = 867. At \delta = 0.05 the lower bound is 2297 samples, while successive elimination uses 47 188 on average, with no error in 50 runs.

Most of the factor 20 comes from the threshold: \log(4Kn^2/\delta) \approx 26 at the end of a run, against \mathrm{kl}(\delta, 1 - \delta) = 2.65, and from the factor 2 in the elimination rule. GLR stopping removes both.

Planning with a simulator

Definition 8.6 — Generative model and simple regret Planning in a large MDP is also a pure exploration problem. A generative model returns a sample s' \sim P(\cdot \mid s, a) and a reward for any pair queried. A planner recommends an action \hat a at the current state s_0 after n calls, and is judged by its simple regret V^\star(s_0) - Q^\star(s_0, \hat a) .

Theorem 8.7 — Sparse sampling (Kearns, Mansour and Ng, 2002) Build a tree of depth H from s_0, drawing C next states per action at every node, and estimate Q by averaging and maximising backwards.

For every \varepsilon > 0, there are choices of H and C for which the recommended action is \varepsilon-optimal.

These choices depend on \varepsilon, \gamma, A and the reward bound, but not on the number of states. The number of calls is (AC)^H .

The cost does not depend on the number of states, but it is exponential in the horizon; adaptive methods spend the budget only where it matters.

Algorithm 8.8 — UCT (Kocsis and Szepesvári, 2006) Monte Carlo tree search with a bandit at every node. Each simulation:

  1. selects actions from the root by the UCB1 rule of Algorithm 6.3 among the children of each node;
  2. expands one new node, and evaluates it by a random rollout or a learnt value;
  3. backs up the return to every node on the path, updating counts and means.

UCT recommends the optimal action with probability tending to 1, but its worst case is bad. Coquelin and Munos (2007) built trees on which it needs a hyper-exponential number of simulations in the depth, because UCB bonuses at inner nodes treat non-stationary returns as i.i.d.

The pure-exploration view leads to planners with guarantees. MDP-GapE (Jonsson, Kaufmann, Ménard, Darwiche Domingues, Leurent and Valko, 2020) stops as soon as an \varepsilon-optimal first action is identified with confidence 1 - \delta. Its sample complexity depends on the gaps of the tree, as Theorem 8.4 suggests.

Key takeaways — chapter 8

  • Best-arm identification minimises the number of samples needed to be right with probability 1 - \delta; elimination with Hoeffding intervals is correct but wasteful.
  • The characteristic time T^\star(\mu) and the optimal weights w^\star(\mu) come from the transportation lemma; Track-and-Stop with GLR stopping attains T^\star(\mu)\log(1/\delta).
  • Planning with a simulator is pure exploration over a tree: sparse sampling is independent of the number of states but exponential in the horizon.
  • UCT is a tree of bandits, consistent but with a poor worst case; gap-based planners stop with guarantees.

9. Complements for self-study

This chapter completes the proofs that the sessions only sketch, and adds a few complements: step sizes, conservative policy iteration, the dual linear program. It can be read after session 7; each section names the result it concerns.

Asynchronous stochastic approximation (Theorem 2.3)

The proof follows Tsitsiklis (1994) and Bertsekas and Tsitsiklis (1996, sec. 4.3). Shift coordinates so that x^\star = 0; then \|H x\|_\infty \le \gamma \|x\|_\infty.

Proof. Step 1: boundedness. The iterates are almost surely bounded. This step uses the growth condition on the noise and a rescaling argument; see Tsitsiklis (1994, sec. 6). Fix a sample path and a bound B on \|x_t\|_\infty.

Step 2: noise. Define W_{t+1}(i) = (1 - \alpha_t(i)) W_t(i) + \alpha_t(i) w_t(i) from W_0 = 0. It is a stochastic approximation of the root 0 with martingale noise of bounded variance (by Step 1). The Robbins–Monro conditions give W_t \to 0 almost surely.

Step 3: a shrinking envelope. Choose \varepsilon > 0 with \beta = \gamma + \varepsilon < 1, and set D_0 = B, D_{k+1} = \beta D_k.

Suppose that \|x_t\|_\infty \le D_k for all t beyond some t_k.

Then |(H x_t)(i)| \le \gamma D_k, and the sequence U_t = x_t - W_t satisfies, coordinate by coordinate, |U_{t+1}(i)| \le (1 - \alpha_t(i))\, |U_t(i)| + \alpha_t(i)\, \gamma D_k .

Since \sum_t \alpha_t(i) = \infty, the limit superior of |U_t(i)| is at most \gamma D_k. With Step 2, \|x_t\|_\infty \le \gamma D_k + \varepsilon D_k = D_{k+1} for all t beyond some t_{k+1}.

Conclusion. By induction, the limit superior of \|x_t\|_\infty is at most \beta^k B for every k, hence x_t \to 0. ∎

Step sizes of Q-learning (ch. 2)

The code of ch. 2 shows the step 1/N to be much slower than N^{-0.7}. Even-Dar and Mansour (2003) explain this: with the step 1/N, the convergence time of Q-learning can be exponential in 1/(1 - \gamma), while polynomial steps N^{-\beta} with 1/2 < \beta < 1 give polynomial bounds.

Approximate policy iteration (Proposition 3.2)

Proof. Write V_k for the evaluation of \pi_k, with \|V_k - V^{\pi_k}\|_\infty \le \varepsilon, and \pi_{k+1} greedy with respect to V_k.

Step 1: almost an improvement. Greediness and the contraction give T^{\pi_{k+1}} V^{\pi_k} \ge T^{\pi_{k+1}} V_k - \gamma\varepsilon \ge T^{\pi_k} V_k - \gamma\varepsilon \ge V^{\pi_k} - 2\gamma\varepsilon .

Hence, by the evaluation equation of \pi_{k+1}, (I - \gamma P^{\pi_{k+1}})(V^{\pi_{k+1}} - V^{\pi_k}) \ge -2\gamma\varepsilon\mathbf{1} . The matrix (I - \gamma P^{\pi_{k+1}})^{-1} is non-negative and maps \mathbf{1} to \mathbf{1}/(1 - \gamma), so V^{\pi_{k+1}} \ge V^{\pi_k} - \frac{2\gamma\varepsilon}{1 - \gamma}\, \mathbf{1} .

Step 2: progress towards the optimum. Split V^\star - V^{\pi_{k+1}} into three terms: \underbrace{T^{\pi^\star} V^\star - T^{\pi^\star} V^{\pi_k}}_{(\mathrm{i})} + \underbrace{T^{\pi^\star} V^{\pi_k} - T^{\pi_{k+1}} V^{\pi_k}}_{(\mathrm{ii})} + \underbrace{T^{\pi_{k+1}} V^{\pi_k} - T^{\pi_{k+1}} V^{\pi_{k+1}}}_{(\mathrm{iii})} .

  • Term (i) equals \gamma P^{\pi^\star}(V^\star - V^{\pi_k}).
  • Term (ii) is at most 2\gamma\varepsilon, because T^{\pi_{k+1}} V_k \ge T^{\pi^\star} V_k.
  • Term (iii) equals \gamma P^{\pi_{k+1}}(V^{\pi_k} - V^{\pi_{k+1}}), at most 2\gamma^2\varepsilon/(1 - \gamma) by Step 1.

Taking sup norms, with e_k = \|V^\star - V^{\pi_k}\|_\infty, we get e_{k+1} \le \gamma e_k + 2\gamma\varepsilon/(1 - \gamma), and the limit superior of e_k is at most 2\gamma\varepsilon/(1 - \gamma)^2. ∎

The policies of approximate policy iteration may oscillate. Conservative policy iteration (Kakade and Langford, 2002) moves only a fraction \alpha towards the greedy policy, \pi_{k+1} = (1 - \alpha)\pi_k + \alpha\pi'. The occupancy then changes by O(\alpha), so Lemma 3.1 guarantees an improvement when \alpha is small compared with the estimated advantage.

Softmax policy gradient and the natural gradient (Definition 3.8)

For the tabular softmax, with e_{s,a} the canonical basis vectors, the score and the compatible critic are \nabla\log\pi(a \mid s) = e_{s,a} - \sum_b \pi(b \mid s)\, e_{s,b}, \qquad f_w(s, a) = w_{s,a} - \sum_b \pi(b \mid s)\, w_{s,b} . The critic is a function with mean zero under \pi(\cdot \mid s).

The projection of Q^\pi on such functions is the advantage, and w = A^\pi attains it exactly. By the remark after Proposition 4.8, the natural gradient direction is A^\pi/(1 - \gamma), up to constants per state that do not change the policy.

A step \eta in that direction multiplies \pi(a \mid s) by \exp(\eta A^\pi(s, a)/(1 - \gamma)), which is the update of Definition 3.8. It is mirror ascent with the KL divergence in each state, and its analysis is the multiplicative-weights argument of online learning (Agarwal et al., 2021).

The plain softmax gradient behaves very differently. The constants of its convergence can be very poor: Li, Wei, Chi, Gu and Chen (2021) exhibit MDPs where softmax policy gradient needs a time exponential in the number of states.

Example 3.5 shows two mild versions of this. The first step goes the wrong way in state 1: it lowers \pi(\text{risky} \mid 1) from 0.5 to 0.17, before the improvement of state 2 reverses the sign of the gradient.

Near the optimum, the gradient vanishes as the policy becomes deterministic. The value is 16.092 after 100 steps, but it reaches 16.101 only after 2000 steps.

The dual linear program (Proposition 1.12)

The dual program has one variable \lambda(s, a) \ge 0 per pair. Its constraints say that \lambda is (1-\gamma)^{-1} times a discounted state–action occupancy measure: optimal policies are read off its support. This dual view returns in the constrained and offline problems of ch. 10.

Explicitly, the dual is \max_{\lambda \ge 0} \sum_{s,a} \lambda(s, a)\, r(s, a) \quad \text{subject to} \quad \sum_a \lambda(s', a) - \gamma \sum_{s,a} P(s' \mid s, a)\, \lambda(s, a) = \mu(s') \ \text{ for all } s' .

Regret of UCB1 (Theorem 6.4)

Proof. Fix a suboptimal arm a and write c_{t,n} = \sqrt{2\log t/n}. Let \ell = \lceil 8\log T/\Delta_a^2 \rceil.

Let \hat\mu^\star_n and \hat\mu_{a,n} be the means of the first n rewards of an optimal arm and of arm a.

If arm a is pulled at time t while N_a(t-1) \ge \ell, then for some n < t and some n_a \in [\ell, t), \hat\mu^\star_n + c_{t,n} \le \hat\mu_{a,n_a} + c_{t,n_a} .

This inequality implies one of three events:

  • \hat\mu^\star_n \le \mu^\star - c_{t,n};
  • \hat\mu_{a,n_a} \ge \mu_a + c_{t,n_a};
  • \mu^\star < \mu_a + 2 c_{t,n_a}.

The third is impossible, because n_a \ge \ell gives 2c_{t,n_a} \le \Delta_a. By Hoeffding’s inequality, each of the first two has probability at most e^{-4\log t} = t^{-4}.

Summing over n, n_a and t gives \mathbb{E}[N_a(T)] \le \ell + \sum_t 2t^{-2} \le \frac{8\log T}{\Delta_a^2} + 1 + \frac{\pi^2}{3} . Proposition 6.2 concludes. ∎

The Lai–Robbins lower bound (Theorem 6.6)

The modern proof uses one information inequality (Garivier, Ménard and Stoltz, 2019). For two bandits \mu and \lambda and any random variable Z \in [0, 1] measurable with respect to the observations up to T, \sum_b \mathbb{E}_\mu[N_b(T)]\, \mathrm{kl}(\mu_b, \lambda_b) \ge \mathrm{kl}\big( \mathbb{E}_\mu[Z],\ \mathbb{E}_\lambda[Z] \big) .

The left side is the KL divergence between the laws of the observations (chain rule), and the right side follows from the data-processing inequality.

Proof. Let a be suboptimal, and let \lambda equal \mu except \lambda_a = \mu' > \mu^\star, so that a is the only optimal arm of \lambda.

Take Z = N_a(T)/T. Only arm a differs, so the left side is \mathbb{E}_\mu[N_a(T)]\, \mathrm{kl}(\mu_a, \mu').

By consistency, \mathbb{E}_\mu[Z] \to 0, and 1 - \mathbb{E}_\lambda[Z] = o(T^{\alpha - 1}) for every \alpha > 0. The elementary bound \mathrm{kl}(p, q) \ge (1 - p)\log\frac{1}{1 - q} - \log 2 then gives \mathbb{E}_\mu[N_a(T)]\, \mathrm{kl}(\mu_a, \mu') \ge (1 - o(1))\, (1 - \alpha) \log T - \log 2 .

Divide by \log T, let T \to \infty, then \alpha \to 0 and \mu' \downarrow \mu^\star, using the continuity of \mathrm{kl}. ∎

The same inequality, applied at the stopping time with Z = \mathbf{1}\{\hat a = a^\star(\mu)\}, is the transportation lemma of Theorem 8.4.

Regret of UCB-VI (Theorem 6.10)

Proof. Sketch. Work on the event of Proposition 6.9, and let \delta_{k,h} = \bar V_{k,h}(s_{k,h}) - V^{\pi_k}_h(s_{k,h}) . By optimism, the regret is at most \sum_k \delta_{k,1}. With (s, a) = (s_{k,h}, a_{k,h}) and the empirical model of episode k: \delta_{k,h} \le 2 b_k(s, a) + (\hat P_k - P)(\bar V_{k,h+1} - V^\star_{h+1})(s, a) + P(\bar V_{k,h+1} - V^{\pi_k}_{h+1})(s, a) .

  • The last term is \delta_{k,h+1} plus a martingale difference bounded by H.
  • The middle term is the delicate one, because \bar V_{k,h+1} depends on the data. A Bernstein bound for each next state shows that it is at most 1/H times P(\bar V_{k,h+1} - V^\star_{h+1})(s, a), plus O(H^2 S L/N_k(s, a)).
  • Unrolling over h multiplies the terms by at most (1 + 1/H)^H \le e.

Summing over episodes, the bonuses give, by Cauchy–Schwarz, \sum_{s,a} \sum_{n \le N_K(s,a)} c H\sqrt{L/n} \le 2cH\sqrt{L\, SAT} . The second-order terms give O(H^2 S^2 A L \log T), and the martingale O(H\sqrt{TL}) by Azuma’s inequality. ∎

Existence for the average-reward equation (Theorem 7.3)

Proof. Span bound. Let V_\gamma = V^\star_\gamma. From s', follow a policy that reaches s at a time \tau with \mathbb{E}\tau \le D. Rewards are non-negative, so by Jensen’s inequality V_\gamma(s') \ge \mathbb{E}[\gamma^\tau]\, V_\gamma(s) \ge \gamma^D V_\gamma(s) . Hence V_\gamma(s) - V_\gamma(s') \le (1 - \gamma^D)\, \frac{1}{1 - \gamma} \le D .

Limit. Set h_\gamma = V_\gamma - V_\gamma(s_0)\mathbf{1} and g_\gamma = (1 - \gamma)V_\gamma(s_0) \in [0, 1]. Subtracting V_\gamma(s_0) from the Bellman equation gives g_\gamma + h_\gamma(s) = \max_a \big[ r(s, a) + \gamma (P h_\gamma)(s, a) \big] . Both g_\gamma and h_\gamma are bounded, so a sequence \gamma_n \to 1 has (g_{\gamma_n}, h_{\gamma_n}) \to (g^\star, h^\star), and the limit solves the optimality equation. ∎

Key takeaways — chapter 9

  • Stochastic approximation for contractions: noise averages out, and a shrinking envelope drives the iterates to the fixed point.
  • Approximate policy iteration: an almost-improvement step plus a contraction towards the optimum give the (1 - \gamma)^{-2} factor.
  • Natural gradient for the softmax is a multiplicative-weights update on the advantage.
  • Lower bounds in bandits come from one change-of-measure inequality; upper bounds from Hoeffding plus counting.
  • The average-reward equation is the vanishing-discount limit of the discounted one, with values of span at most D.

10. Research directions and open problems

This self-study chapter surveys active questions that extend the course, with entry points into the literature. It is a map for choosing a project or an internship topic, not a complete review.

Reading a reinforcement learning theory paper

Before the result, locate the setting. Four questions place most papers on the map of this course:

Offline reinforcement learning

In offline RL, the agent learns from a fixed data set collected by other policies, with no further interaction; Levine, Kumar, Tucker and Fu (2020) survey the field. The difficulty is the distribution shift measured by the concentrability coefficients of ch. 4: the data say little about the actions a new policy would take.

The dominant principle is pessimism, the mirror image of the optimism of ch. 6. Conservative Q-learning (Kumar, Zhou, Tucker and Levine, 2020) penalises values outside the data. Jin, Yang and Wang (2021) and Rashidinejad, Zhu, Ma, Jiao and Russell (2021) show that pessimistic value iteration needs coverage of the optimal policy only, not of all policies.

Reinforcement learning from human preferences

When rewards are hard to write down, they can be learnt from comparisons. Christiano, Leike, Brown, Martic, Legg and Amodei (2017) fitted a reward model to human preferences between trajectory segments and optimised it with RL. Ouyang and coauthors (2022) applied the same pipeline, with PPO, to fine-tune language models.

The KL-regularised problem has a closed-form optimal policy: a Boltzmann policy, as in Proposition 5.6 with a reference policy in place of the uniform law. Rafailov and coauthors (2023) inverted this relation to write the reward through the policy, which gives direct preference optimisation, a supervised loss with no RL loop. Which of these methods is preferable, and why, is an open empirical and theoretical question.

Function approximation with guarantees

The tabular rates of ch. 6 depend on S, useless for images. In linear MDPs, P and r are linear in known features of dimension d.

Optimistic algorithms then have regret polynomial in d and H times \sqrt{T} (Jin, Yang, Wang and Jordan, 2020). Structural conditions such as low Bellman rank (Jiang, Krishnamurthy, Agarwal, Langford and Schapire, 2017) extend this to richer classes.

Negative results show the limits. If only Q^\star is linear in the features, efficient planning can be impossible: Weisz, Amortila and Szepesvári (2021) prove a lower bound exponential in the dimension or the horizon. Du, Kakade, Wang and Yang (2020) give related lower bounds for approximately good representations.

Pure exploration in MDPs and reward-free exploration

Best-policy identification extends ch. 8 to MDPs. Al Marjani, Garivier and Proutière (2021) derive instance-dependent lower bounds for identifying the best policy in a discounted MDP, and algorithms close to them. Simchowitz and Jamieson (2019) give gap-dependent regret bounds for optimistic algorithms in tabular MDPs.

In reward-free exploration, the agent explores without rewards, then must output a near-optimal policy for any reward function given afterwards. Jin, Krishnamurthy, Simchowitz and Yu (2020) introduced the problem; Kaufmann and coauthors (2021) and Ménard and coauthors (2021) give adaptive algorithms with sharper sample complexity.

Distributional and model-based deep RL

Distributional RL learns the law of the return, not only its mean, with a distributional Bellman operator that is a contraction in a Wasserstein metric (Bellemare, Dabney and Munos, 2017). Model-based deep RL learns a model for planning: MuZero (Schrittwieser and coauthors, 2020) learns a latent model and plans in it with Monte Carlo tree search.

Variants of the tree search of ch. 8, with learnt priors and values, drive AlphaGo and AlphaZero (Silver et al., 2016, 2018). For deterministic systems, optimistic planning (Hren and Munos, 2008) has a complexity governed by the branching factor of the near-optimal paths.

Open problems

Key takeaways — chapter 10

  • Locate a paper by its criterion, its access to the environment, its objective and the type of its guarantee.
  • Offline RL replaces optimism by pessimism; preference-based RL learns the reward itself.
  • Linear and low-rank structures give guarantees with function approximation; realisability of Q^\star alone is not enough.
  • Pure exploration, reward-free exploration and model-based planning extend ch. 8 to MDPs.

Exercises

Levels: ★ apply the course, ★★ combine results or prove a short statement, ★★★ open-ended or research-flavoured. Exercises 6, 14 and 17 are computational; they reuse the code of the chapters.

  1. ★ Evaluating and improving a policy. In the MDP of Example 1.10, with \gamma = 0.9, compute the value of the policy (safe, safe) by solving the Bellman evaluation equation. Then perform one improvement step of policy iteration.

    Solution: in state 1, V(1) = 1 + 0.9\, V(1), so V(1) = 10. In state 2, V(2) = 2 + 0.9\,(0.2 \times 10 + 0.8\, V(2)), so 0.28\, V(2) = 3.8 and V(2) = 13.571.

    Improvement: in state 1, risky is worth 0.9 \times 13.571 = 12.214 > 10; in state 2, safe keeps 13.571 against 0.9 \times 10 = 9. The new policy is (risky, safe), which is optimal (Example 1.10).

  2. ★ How many sweeps? Rewards are in [0, 1] and value iteration starts from V_0 = 0. How many sweeps guarantee \|V_k - V^\star\|_\infty \le 0.01 for \gamma = 0.9 and for \gamma = 0.99?

    Solution: \|V_0 - V^\star\|_\infty \le 1/(1 - \gamma), so it suffices that \gamma^k/(1 - \gamma) \le 0.01 (Proposition 1.8), that is k \ge \frac{\log\big(100/(1 - \gamma)\big)}{\log(1/\gamma)} . This gives k = 66 for \gamma = 0.9 and k = 917 for \gamma = 0.99: the cost grows like 1/(1 - \gamma), up to a logarithm.

  3. ★ Q-learning against SARSA. The current estimates are Q(1, \text{risky}) = 2 and Q(2, \cdot) = (4, 1) for (safe, risky). The agent plays risky in state 1, receives r = 0 and lands in state 2, where its \varepsilon-greedy rule draws the exploratory action risky.

    With \alpha = 0.5 and \gamma = 0.9, give the Q-learning and the SARSA updates of Q(1, \text{risky}).

    Solution: the Q-learning target uses the maximum, 0 + 0.9 \times 4 = 3.6, so Q \leftarrow 2 + 0.5 \times 1.6 = 2.8.

    The SARSA target uses the action actually drawn, 0 + 0.9 \times 1 = 0.9, so Q \leftarrow 2 + 0.5 \times (-1.1) = 1.45. SARSA evaluates the exploring policy, Q-learning the greedy one.

  4. ★ Step sizes. Which of the following step sequences satisfy the Robbins–Monro conditions of Theorem 0.6: 1/t, 1/\sqrt{t}, 1/t^2, 1/(t\log t) for t \ge 2, the constant 0.1, and t^{-0.7}?

    Solution: 1/t, 1/(t\log t) and t^{-0.7} do. The sum of 1/(t\log t) diverges like \log\log t, while its squares are summable.

    The steps 1/\sqrt{t} and 0.1 fail the second condition, since their squares are not summable: the iterates keep fluctuating. The steps 1/t^2 fail the first, so the iterates may stop before reaching the root.

  5. ★ UCB indices by hand. After t = 100 rounds of a three-armed bandit, the arms have been pulled (60, 30, 10) times with empirical means (0.55, 0.50, 0.35). Which arm does UCB1 pull next?

    Solution: 2\log 100 = 9.21. The indices are 0.55 + \sqrt{9.21/60} = 0.942, 0.50 + \sqrt{9.21/30} = 1.054 and 0.35 + \sqrt{9.21/10} = 1.310.

    UCB1 pulls arm 3, the worst empirical arm, because it is the most uncertain.

  6. ★ SARSA in code. Adapt the Q-learning code of ch. 2 to SARSA with \varepsilon-greedy exploration, \varepsilon = 0.1 fixed and steps N^{-0.7}, for 300 000 steps. Compare the result with Q^\star and explain the difference.

    Hints and expected result: replace the target by r + \gamma Q(s', a'), with a' drawn from the \varepsilon-greedy rule and then played. SARSA gives about [[13.57, 13.99], [15.71, 12.57]], close to the action values of the \varepsilon-greedy policy that is greedy with respect to them, [[13.61, 14.03], [15.74, 12.61]].

    These values lie about 1.1 below Q^\star = [[14.73, 15.25], [16.95, 13.73]]: with \varepsilon fixed, SARSA learns the value of exploring forever. The greedy policy is still (risky, safe).

  7. ★★ Overestimation of the maximum. Let X_1, X_2 be independent \mathcal{N}(0, \sigma^2) estimates of two actions of true value 0. Compute \mathbb{E}[\max(X_1, X_2)]. With an independent second pair (Y_1, Y_2), compute the mean of the double estimator Y_{\hat a}, where \hat a = \arg\max_a X_a.

    Solution: \max(X_1, X_2) = (X_1 + X_2)/2 + |X_1 - X_2|/2. Since X_1 - X_2 \sim \mathcal{N}(0, 2\sigma^2) has mean absolute value 2\sigma/\sqrt{\pi}, the expectation is \mathbb{E}[\max(X_1, X_2)] = \frac{\sigma}{\sqrt{\pi}} \approx 0.564\, \sigma .

    The double estimator is unbiased here: given X, Y_{\hat a} has mean 0 (Proposition 5.2). When the true values differ, it can underestimate.

  8. ★★ The TD fixed point with one feature. A chain moves uniformly at random between two states (P has all entries 1/2), with rewards r = (1, 0) and \gamma = 0.9. The single feature is \varphi = (1, 2). Compute V^\pi, the best approximation \Pi V^\pi, the TD fixed point, and check Theorem 4.4.

    Solution: the mean value m solves m = 0.5 + 0.9\, m, so m = 5 and V^\pi = (5.5, 4.5). The stationary law is (1/2, 1/2).

    The projection is w = (5.5 + 2 \times 4.5)/(1 + 4) = 2.9, with error \|V - \Pi V\|_d = 2.056.

    For TD, (I - \gamma P)\varphi = (-0.35, 0.65), so A = 0.475 and b = 0.5, and w_{\mathrm{TD}} = 1.053. Its error is \|V - \Phi w_{\mathrm{TD}}\|_d = 3.572 \le 2.056/\sqrt{1 - 0.81} = 4.716 .

  9. ★★ Policy improvement from the performance difference. Use Lemma 3.1 to prove that if \pi' is greedy with respect to Q^\pi, then V^{\pi'} \ge V^\pi in every state, with equality everywhere only if \pi is optimal.

    Solution: apply Lemma 3.1 with \mu = \delta_s. The advantage A^\pi(x, \pi'(x)) = \max_a Q^\pi(x, a) - V^\pi(x) is non-negative in every state, so V^{\pi'}(s) \ge V^\pi(s).

    If equality holds at every s, the expectation vanishes. Since d^{\pi'}_{\delta_s}(s) \ge 1 - \gamma > 0, this forces \max_a Q^\pi(s, a) = V^\pi(s) for every s. Then T^\star V^\pi = V^\pi, and \pi is optimal by Theorem 1.7.

  10. ★★ The best constant baseline. For the estimator g = (R - b)\, \nabla\log\pi(a) of a one-step problem, find the constant b that minimises \mathbb{E}\|g\|^2. Apply it to the bandit of the code of ch. 3.

    Solution: the mean of g does not depend on b, and its second moment is a quadratic in b: \mathbb{E}\|g\|^2 = \mathbb{E}\big[R^2 \|\nabla\log\pi\|^2\big] - 2b\, \mathbb{E}\big[R\, \|\nabla\log\pi\|^2\big] + b^2\, \mathbb{E}\|\nabla\log\pi\|^2 . The minimiser is b^\star = \frac{\mathbb{E}\big[ R\, \|\nabla\log\pi\|^2 \big]}{\mathbb{E}\, \|\nabla\log\pi\|^2} .

    For the uniform softmax on three arms, \|e_a - \pi\|^2 = 2/3 for every arm. So b^\star = \mathbb{E}[R] = 11.5, the value baseline used in the code.

  11. ★★ The regulator and the golden ratio. Solve the scalar Riccati equation of Theorem 5.4 for a = b = q = \rho = 1 and \gamma = 1. Give the gain and the closed loop.

    Solution: the equation p = 1 + p - p^2/(1 + p) reduces to p^2 = p + 1, so p = (1 + \sqrt 5)/2 = 1.618.

    The gain is K = p/(1 + p) = 1/p = 0.618, and the closed loop is 1 - K = 1/p^2 = 0.382. The open-loop system, a = 1, is only marginally stable; feedback makes it contract by 0.382 per step.

  12. ★★ Gain and bias of a two-state chain. A chain has P = \begin{pmatrix} 0.9 & 0.1 \\ 0.5 & 0.5 \end{pmatrix} and rewards r = (0, 1). Compute its gain, its bias with h(1) = 0, and compare with (1 - \gamma)V_\gamma for \gamma close to 1.

    Solution: the stationary law solves 0.1\, d(1) = 0.5\, d(2), so d = (5/6, 1/6) and g = 1/6. The Poisson equation in state 1 gives g = 0.1\, h(2), so h = (0, 5/3). State 2 checks: 1/6 + 5/3 = 1 + 0.5 \times 5/3.

    For \gamma = 0.99, (1 - \gamma)V_\gamma = (0.164, 0.180) and V_\gamma(2) - V_\gamma(1) = 1.656.

    For \gamma = 0.999 they are (0.1664, 0.1681) and 1.666, approaching g and h (Definition 7.2).

  13. ★★ Characteristic time with unequal variances. Two Gaussian arms have variances \sigma_1^2 and \sigma_2^2 and gap \Delta. Show that the optimal weights are proportional to \sigma_1 and \sigma_2, and that T^\star = 2(\sigma_1 + \sigma_2)^2/\Delta^2.

    Evaluate the lower bound of Theorem 8.4 for \sigma_1 = 1, \sigma_2 = 2, \Delta = 0.5 and \delta = 0.01.

    Solution: the closest alternative moves both means to a common value m. Minimising over m gives \min_m \Big[ \frac{w_1(\mu_1 - m)^2}{2\sigma_1^2} + \frac{w_2(\mu_2 - m)^2}{2\sigma_2^2} \Big] = \frac{\Delta^2}{2(\sigma_1^2/w_1 + \sigma_2^2/w_2)} .

    Minimising \sigma_1^2/w_1 + \sigma_2^2/w_2 under w_1 + w_2 = 1 gives w_i \propto \sigma_i, with minimum (\sigma_1 + \sigma_2)^2.

    Numerically, T^\star = 2 \times 9/0.25 = 72, the weights are (1/3, 2/3), and \mathrm{kl}(0.01, 0.99) = 0.98 \log 99 = 4.503. The bound is \mathbb{E}[\tau_\delta] \ge 72 \times 4.503 \approx 324 .

  14. ★★ UCB against \varepsilon-greedy. Simulate UCB1 and \varepsilon-greedy (\varepsilon = 0.1, greedy on empirical means) on Bernoulli arms with means (0.5, 0.4, 0.3), over 10 runs, for T = 10^4 and T = 10^5. Explain the results with Proposition 6.2.

    Hints and expected result: with seeds 0 to 9, the mean regrets are about 114 for \varepsilon-greedy against 154 for UCB1 at T = 10^4, but 1012 against 280 at T = 10^5.

    The exploration of \varepsilon-greedy pulls each suboptimal arm about \varepsilon T/3 times, a regret near 0.1 \times T \times (0.1 + 0.2)/3 = 10^{-2}\, T. UCB1 grows like \log T: it loses at small T, then wins by a growing margin.

  15. ★★ The simulation lemma. Let P and \hat P be two transition kernels with the same rewards. For a stationary policy \pi, prove the identity below.

    Deduce a bound on \|V^\pi_P - V^\pi_{\hat P}\|_\infty in terms of the largest L_1 distance \varepsilon between the laws P(\cdot \mid s, a) and \hat P(\cdot \mid s, a). V^\pi_P - V^\pi_{\hat P} = \gamma\, (I - \gamma \hat P^\pi)^{-1} (P^\pi - \hat P^\pi)\, V^\pi_P

    Solution: subtract the two Bellman equations, then invert I - \gamma\hat P^\pi: V_P - V_{\hat P} = \gamma(P^\pi - \hat P^\pi) V_P + \gamma \hat P^\pi (V_P - V_{\hat P}) .

    Each entry of (P^\pi - \hat P^\pi)V_P is at most \varepsilon \|V_P\|_\infty \le \varepsilon/(1 - \gamma), and the inverse has norm 1/(1 - \gamma). Hence the bound \gamma\varepsilon/(1 - \gamma)^2.

    Plugging in an L_1 concentration bound of order \sqrt{S/N} costs a factor S and (1 - \gamma)^{-1} compared with the minimax analysis of Azar, Munos and Kappen (2013).

  16. ★★★ Which arms are hardest? Show that for Gaussian arms of variance \sigma^2 the Lai–Robbins constant of arm a is 2\sigma^2/\Delta_a^2, and compare with the 8/\Delta_a^2 of UCB1 for rewards in [0, 1].

    Then, for laws \nu, \nu' on [0, 1], prove the inequality below. What does it say about Bernoulli arms? \mathrm{KL}(\nu, \nu') \ge \mathrm{kl}(\mathbb{E}\nu, \mathbb{E}\nu')

    Hints and expected result: the Gaussian KL is \Delta^2/(2\sigma^2). For Bernoulli arms, Pinsker’s inequality \mathrm{kl} \ge 2\Delta^2 shows that at most 1/(2\Delta_a^2) pulls per unit of \log T are required: the constant of UCB1 is at least 16 times too large.

    For the inequality, map X \in [0, 1] to a Bernoulli(X) variable; the image of a law is the Bernoulli law with the same mean, and KL decreases under a channel (data processing). Hence the Lai–Robbins constant over all laws on [0, 1] is at most the Bernoulli one: Bernoulli arms are the hardest of their means, and KL-UCB with the Bernoulli \mathrm{kl} is safe for all bounded rewards.

  17. ★★★ UCT on a deceptive tree. Build a binary tree of depth 6 in which the left action at the root leads to a subtree of rewards 0.5, except one leaf at depth 6 with reward 1, and the right action leads to leaves of reward 0.6. Implement UCT (Algorithm 8.8) and uniform Monte Carlo sampling, and plot the simple regret against the number of simulations. How does the exploration constant change the picture?

    Hints and expected result: with random rollouts, the left subtree looks worse on average, so UCT first concentrates on the right branch. It finds the deep optimal leaf only after a number of simulations that grows quickly with the depth; this is the phenomenon of Coquelin and Munos (2007). A larger exploration constant helps on this tree and hurts on others; there is no free lunch for tree search.

  18. ★★★ Instance-dependent regret in episodic MDPs. Read Simchowitz and Jamieson (2019). Express their gap-dependent bound with the gaps Q^\star_h(s, \pi^\star(s)) - Q^\star_h(s, a), and compare it with Proposition 7.8. Which part of the Burnetas–Katehakis constant of Theorem 7.9 has no counterpart, and why is an exact episodic constant still open?

    Hints and expected result: the episodic analogue of Proposition 7.8 writes the regret as an expected sum of gaps along the visited pairs. Gap-dependent bounds then scale like a sum over pairs of \log T divided by the gap, times a power of H.

    The Burnetas–Katehakis constant uses KL projections of the transition laws at each pair. In episodic MDPs, states that the optimal policy rarely visits complicate the change of measure, which is part of why matching upper and lower bounds remain open (ch. 10).

Projects and assessment

The official assessment, per master-mva.com, is one written exam after class 8 and one programming assignment after class 5; no weights are displayed. The Université Paris-Saclay course detail classifies the assessment as “Evaluation Continue non Intégrale”. The content of the programming assignment is not published.

The solo subjects below are sized like such an assignment and use ch. 1–5, except one paper study on ch. 8. The group subjects are longer paper studies in the MVA tradition. The written exam is a proposal for self-testing; none of these proposals is official material.

Solo projects

  1. [Solo · ≈ 20 h] Deep Q-learning on a self-written cart-pole. Implement the cart-pole dynamics of Barto, Sutton and Anderson (1983) in NumPy, then DQN (Algorithm 5.1) and Double DQN (van Hasselt, Guez and Silver, 2016) in PyTorch, on a CPU.
    • Question: how large is the overestimation of DQN, and does the double estimator remove it?
    • Success criterion: an average return of at least 195 over 100 consecutive episodes capped at 200 steps, and a plot of the predicted value at the start state against the Monte Carlo return, for both methods and 5 seeds.
    • Deliverables: code, a 4–6 page report, a 10-minute talk. Chapters 2, 4, 5.
  2. [Solo · ≈ 20 h] Off-policy divergence and gradient-TD: a paper study. Study Sutton, Maei, Precup, Bhatnagar, Silver, Szepesvári and Wiewiora (2009), and Baird (1995).
    • Implement: linear TD(0), GTD2 and TDC with linear features, on Baird’s seven-state star and on Example 4.7.
    • Success criterion: a figure of the projected Bellman error \|\Pi T^\pi V_w - V_w\|_d against the number of updates, with TD diverging and TDC converging, and a short proof that Example 4.7 diverges exactly when \gamma > 1/2.
    • Deliverables: code, report, talk. Chapters 2, 4.
  3. [Solo · ≈ 15 h] Track-and-Stop: a paper study. Study Garivier and Kaufmann (2016) and implement Track-and-Stop with the GLR stopping rule (Definition 8.5) for Bernoulli arms.
    • Experiments: the four arms of ch. 8 and one instance of the paper, for \delta \in \{0.1, 0.01, 0.001\}, 500 runs each, against successive elimination (Algorithm 8.2).
    • Success criterion: the empirical error rate stays below \delta, and \mathbb{E}[\tau_\delta]/\log(1/\delta) approaches T^\star(\mu) as \delta decreases.
    • Deliverables: code, report, talk. Chapter 8.

Group projects

  1. [Group of 2–3 · ≈ 30 h each] Minimax regret in tabular RL: optimism against posterior sampling. Study Azar, Osband and Munos (2017) and Osband, Russo and Van Roy (2013).
    • Work split: one member implements UCB-VI with Hoeffding and Bernstein bonuses (Algorithm 6.8); one implements PSRL with Dirichlet posteriors; one builds the environments (the river chain of ch. 6 with 6 to 20 states, random MDPs) and the evaluation, with seeds and confidence bands.
    • Success criterion: log–log plots of regret against the number of episodes, with slope close to 1/2 once the regime is reached, and a measured dependence on S compared with Theorem 6.10.
    • Deliverables: code, a 6-page report, a 15-minute talk. Chapters 1, 6, 9.
  2. [Group of 2–3 · ≈ 30 h each] Average-reward learning: UCRL2, KL-UCRL and instance optimality. Study Jaksch, Ortner and Auer (2010), Filippi, Cappé and Garivier (2010) and Burnetas and Katehakis (1997).
    • Work split: one member implements extended value iteration and UCRL2; one replaces the L_1 balls by KL balls; one computes the constant C(M) of Theorem 7.9 for small ergodic MDPs.
    • Success criterion: regret curves up to T = 10^6 on an ergodic variant of the river chain, showing the logarithmic regime, compared with C(M)\log T; an honest discussion of the gap.
    • Deliverables: code, report, talk. Chapters 6, 7, 9.
  3. [Group of 2–3 · ≈ 30 h each] Planning with a simulator. Study Kearns, Mansour and Ng (2002), Kocsis and Szepesvári (2006) and Jonsson, Kaufmann, Ménard, Darwiche Domingues, Leurent and Valko (2020).
    • Work split: one member implements sparse sampling and uniform Monte Carlo; one implements UCT and studies its exploration constant on the deceptive trees of Exercise 17; one implements MDP-GapE.
    • Success criterion: simple regret against the number of simulator calls on random MDPs with 2 to 4 actions and \gamma = 0.9, with confidence bands, and the empirical correctness rate of MDP-GapE at \delta = 0.1.
    • Deliverables: code, report, talk. Chapters 1, 6, 8.

Written exam (proposal)

Format: 2 h 30, one handwritten A4 sheet allowed, no electronic device; four independent exercises.

  1. Course question (5 points). Define the Bellman optimality operator T^\star and prove that it is a \gamma-contraction in the sup norm. Prove that a greedy policy with respect to its fixed point is optimal among stationary policies. State the loss of a greedy policy with respect to an approximation V of V^\star.

    Expected: Definition 1.5; Proposition 1.6 with |\max f - \max g| \le \max|f - g|; Step 1 of Theorem 1.7; Proposition 1.8, with the bound 2\gamma\|V - V^\star\|_\infty/(1 - \gamma).

  2. Computation (5 points). In state 1, action a gives reward 0 and leads to state 2, and action b gives reward 0.5 and stays. State 2 has a single action, with reward 1, staying with probability 0.5 and returning to state 1 otherwise. Take \gamma = 0.8.

    (a) Evaluate the two deterministic policies. (b) Give two sweeps of value iteration from V_0 = 0 and the greedy actions. (c) With Q(1, a) = 1, \max_{a'} Q(2, a') = 2 and \alpha = 0.5, give the Q-learning update after the transition (1, a, 0, 2).

    Expected: (a) with a: V(2) = 1/0.28 = 3.571 and V(1) = 2.857; with b: V(1) = 2.5 and V(2) = 3.333.

    So a is optimal, and it is greedy with respect to its own value (2.857 > 0.5 + 0.8 \times 2.857 = 2.786).

    (b) V_1 = (0.5, 1), then V_2 = (0.9, 1.6), with b still greedy in state 1 after two sweeps. (c) The target is 0.8 \times 2 = 1.6, so Q(1, a) = 1.3.

  3. Short proof (5 points). Prove the performance difference lemma. Deduce the policy gradient theorem for the tabular softmax: \frac{\partial J}{\partial\theta_{s,a}} = \frac{1}{1 - \gamma}\, d^{\pi_\theta}_\mu(s)\, \pi_\theta(a \mid s)\, A^{\pi_\theta}(s, a) .

    Expected: the telescoping sum of Lemma 3.1. Then either the unrolled Bellman equation of Theorem 3.4, or the first-order expansion of Lemma 3.1 with \pi' = \pi_{\theta + h}, followed by the softmax score \mathbf{1}_{a=b} - \pi(b \mid s).

  4. Problem (5 points). Bernoulli bandit with means (0.9, 0.8).

    (a) Prove the regret decomposition. (b) State the Lai–Robbins bound and compute its constant. (c) Compare with the bound of Theorem 6.4 at T = 10^4. (d) Explain in two sentences why identifying the best arm calls for a different sampling rule than minimising regret.

    Expected: (a) Proposition 6.2. (b) \mathrm{kl}(0.8, 0.9) = 0.0444, so the regret is at least (0.1/0.0444)\log T = 2.25\log T, about 20.7 at T = 10^4.

    (c) Theorem 6.4 gives about 80 \log T + 0.43 \approx 737, a factor 35 above. (d) Regret penalises every pull of the worse arm, so it pulls it only O(\log T) times. Identification needs both means precisely: for these two arms the optimal weights of Theorem 8.4 are about (0.52, 0.48), so it samples them almost equally.

Grading rubric (proposal)

Criterion Weight What earns the marks
Correctness of the implementation 30 % Algorithms implemented as specified, tested on cases with a known answer (the two-state MDP, Q^\star by value iteration, the exact gradient)
Experimental evidence 25 % Several seeds, confidence bands, the success criterion of the subject met or its failure explained
Understanding of the theory 25 % The guarantee of the paper or chapter stated precisely, with its assumptions, and checked against the experiments
Report and talk 20 % A clear question, readable figures, honest limits, and a talk that fits its time

References

Official references

The course page on master-mva.com lists no references for this course. The lists below give standard textbooks and the works cited on this page.

Textbooks

Dynamic programming and the first algorithms (ch. 0–2)

Actors and critics (ch. 3–4)

Deep RL and continuous control (ch. 5)

Exploration, regret and average reward (ch. 6–7)

Pure exploration and planning (ch. 8)

Research directions (ch. 10)