AI Safety & Governance Series Appendix — Technical Foundations
Appendix · Section A13

Reinforcement
Learning

A condensed, symbol‑dense reference covering the mathematical foundations of reinforcement learning — from the critique of supervised learning through the core formalism of states, actions, rewards, policies, and value functions. Designed as a rapid technical primer for the agentic AI systems discussed in the main chapters.

StatusOpen Draft
Sections13 Sub‑sections
Parent ChapterAppendix — AI Fundamentals
DomainML · RL · Mathematics
AuthorMukul Namagiri
Light
Appendix A13 Reinforcement Learning — Symbol‑Dense Reference
Note on scope. Reinforcement learning is a vast topic and would require an entire book of its own to proceed forward — which is not plausible here. We have therefore tried to condense as many concepts as possible in a very information‑dense way. What better way to condense than with a bunch of symbols.
A13.1

Critique of Supervised Learning

The supervised learning phenomenon purely interpolates or extrapolates from existing data sets. But learning can also happen without previous experience — through exploration. Hence reinforcement learning was necessary.

A13.2

Origin of Reinforcement

The word reinforcement comes from behaviour psychology and denotes reward or punishment. It depends on the agent's decisions and on external factors.

A13.3

Agent

The decision‑maker that selects actions.

No mathematical variables; “agent” is a conceptual label.
A13.4

Environment

The system outside the agent that produces the next state and reward.

No mathematical variables; “environment” is a conceptual label.
A13.5

State

St ∈ 𝒮, Pr{ St+1 ∣ St, At } = Pr{ St+1 ∣ S0, A0, …, St, At }
  • tdiscrete time step index (t = 0,1,2,…).
  • 𝒮the set (space) of all possible states.
  • Stthe state at time t; a particular element of 𝒮.
  • St+1the next state, after taking action At.
  • Atthe action chosen at time t (see A13.6).
  • Pr{·∣·}conditional probability.
  • S0,A0,…the entire history of states and actions up to time t.
A13.6

Action

At ∈ 𝒜
  • ttime step.
  • 𝒜the set (space) of all possible actions; sometimes written 𝒜(s) if state‑dependent.
  • Atthe action taken at time t.
A13.7

Reward

Rt ∈ ℝ, Rt = R( St−1, At−1, St )
  • ttime step when the reward is received.
  • the real numbers.
  • Rtscalar reward signal received at time t.
  • St−1the state immediately before the action.
  • At−1the action that led to the reward.
  • Stthe state entered after taking the action.
  • R(·)the reward function mapping (St−1, At−1, St) to a real number.
A13.8

Return

Gt ≐ Σk=0 γk Rt+k+1
  • ttime step from which we compute the return.
  • Gtthe (discounted) return starting from time t.
  • definitional equality.
  • ksummation index (steps into the future, k = 0,1,2,…).
  • γdiscount factor, 0 ≤ γ ≤ 1 (and γ < 1 if the sum is infinite).
  • Rt+k+1reward received k steps into the future (at time t+k+1).
  • Σsummation operator.
A13.9

Goal

maximise 𝔼[Gt] from every state s
  • 𝔼[·]expectation operator (average over all possible future trajectories).
  • Gtthe return (see A13.8).
  • tany time step; objective is stationary.
  • from every state sthe expectation is conditional on starting in state s, for all s ∈ 𝒮.
A13.10

Policy

π(a|s) = Pr{At=a ∣ St=s}, or π(s)=a (deterministic)
  • πthe policy, a rule specifying action probabilities.
  • sa state (element of 𝒮).
  • aan action (element of 𝒜).
  • π(a|s)probability of selecting action a in state s.
  • Pr{·∣·}conditional probability.
  • At, Staction and state random variables at time t.
  • π(s)for deterministic policies, the action prescribed in state s.
A13.11

State‑value function

Vπ(s) ≐ 𝔼π[ Gt ∣ St=s ]
  • Vπ(s)state‑value of s under policy π.
  • definitional equality.
  • 𝔼π[·]expectation over trajectories when following policy π.
  • Gtthe return.
  • Stthe state at time t (conditioned to be s).
  • sthe specific state for which we evaluate the value.
A13.12

Action‑value function

Qπ(s,a) ≐ 𝔼π[ Gt ∣ St=s, At=a ]
  • Qπ(s,a)action‑value of taking a in s under policy π.
  • definitional equality.
  • 𝔼π[·]expectation when following policy π.
  • Gtthe return.
  • St, Atstate and action conditioned to be s and a.
  • s, aspecific state and action values used as conditioning.
A13.13

Markov Decision Process (MDP)

ℳ ≐ (𝒮, 𝒜, p, r, γ)

p(s′, r ∣ s, a) ≐ Pr{St=s′, Rt=r ∣ St−1=s, At−1=a}

r(s, a) ≐ 𝔼[ Rt ∣ St−1=s, At−1=a ]
  • the MDP tuple.
  • 𝒮state space (set of all states).
  • 𝒜action space (set of all actions).
  • ptransition probability function (dynamics).
  • rexpected immediate reward function r(s,a).
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • s, a, s′, rstate, action, next state, reward value (context distinguishes the reward function r).
  • St−1, At−1, St, Rtrandom variables at appropriate time steps.
A13.14

Laplacian Determinism

Laplacian determinism is the view that the evolution of a system is fully determined by its initial conditions and governing differential equations. In optimal control theory this means that optimal actions a(s,t) are sought analytically, rather than through trial‑and‑error learning.

The essential point is the last one: the theory considers, for a given system of differential equations, ways of finding the optimal a(s,t) analytically. Drawing an analogy with the problem of maximizing, say, a differentiable function f(x) → maxx, optimal control theory looks for necessary conditions of the solution: for example, that at an extremum of a function we must have x f(x) = 0. No “learning by trial and error” is assumed here.
  • a(s,t)optimal action as a function of state and time, determined analytically.
  • f(x)an objective function to be maximised.
  • x f(x) = 0necessary first‑order condition for an extremum (gradient vanishes).
A13.15

Time‑homogeneous (Stationary) Markov Chain

∀t,   p(st+1 ∣ st) = p(s1 ∣ s0)

p(s′ ∣ s) ≐ Pr{St+1=s′ ∣ St=s}
  • ttime step; the condition states that the distribution is identical for all t.
  • p(st+1 ∣ st)time‑dependent transition probability (if any).
  • p(s1 ∣ s0)the transition probability from the initial step, used as the reference.
  • s, s′a current state s and next state s′ (the prime notation ′ indicates the next time step).
  • p(s′ ∣ s)the stationary transition kernel, a single conditional probability distribution Pr{St+1=s′ ∣ St=s} valid for every t.
A13.16

Stationary MDP

A stationary (time‑homogeneous) MDP is one where both the transition dynamics p and the reward function r are independent of time t.

A13.17

Environment (Controlled Markov Chain)

An environment (or controlled Markov chain) is a triple (S, A, P) that specifies the state space, action space, and stationary transition dynamics governing the system’s evolution.

Environment ≐ (S, A, P)

P = { p(s′ ∣ s, a) ∣ s, s′ ∈ S, a ∈ A }
p(s′ ∣ s, a) ≐ Pr{St+1=s′ ∣ St=s, At=a}
  • Sset of states (state space).
  • Aset of actions (action space).
  • Ptransition function (world dynamics) – a family of conditional distributions.
  • scurrent state, s ∈ S.
  • aaction chosen by the agent, a ∈ A.
  • s′next state, s′ ∈ S.
  • p(s′ ∣ s, a)probability of moving to state s′ given that the agent took action a in state s; implicitly stationary (time‑independent) and Markovian.
  • St, At, St+1random variables for state, action, and next state at step t.
A13.18

Fully Observable Environment

An environment is fully observable when at each time t the agent receives the complete state St as its observation, i.e. the observation equals the state; otherwise the problem is a partially observable Markov decision process (POMDP).

  • Stthe true state of the environment at time t.
  • Observationthe signal the agent receives; here it is exactly St (no additional symbol, because observation ≡ state).
  • Fully observableimplies that the agent’s decision rule can be a function of St alone without needing any memory of the past.
A13.19

Action Spaces

Two common types of action space are distinguished:

Finite (discrete)|A| < +∞, with the additional practical assumption that the number of actions |A| is reasonably small.
ContinuousA ⊆ [−1,1]m. The choice of the interval [−1,1] is a widespread convention that does not sacrifice generality. Problems with such an action space are also called continuous control problems.
A13.20

Trajectory

A sequence

T ≐ (s0, a0, s1, a1, s2, a2, s3, a3, …)

is called a trajectory.

A13.21

Trajectory Distribution & Expectation

For a given environment, policy π, and initial state s0 ∈ S, the distribution from which trajectories T are drawn is called the trajectory distribution:

p(T) = p(a0, s1, a1, …) = ∏t≥0 π(at ∣ st) p(st+1 ∣ st, at)

Expectations over trajectories are denoted by ET and understood as an infinite chain of nested expectations:

ET (⋅) := Eπ(a0∣s0) Ep(s1∣s0,a0) Eπ(a1∣s1) … (⋅)  (1.1)

A convenient shorthand unpacks this chain as

ET (⋅) = Ea0 Es1 Ea1 … (⋅)

In such notation one should remember that actions come from a fixed policy π. Where clarity is needed, the notation ET∼π is used.

A13.22

Policy

A policy specifies the agent’s behaviour as a mapping from states to a probability distribution over actions.

π(a ∣ s) ≐ Pr{At=a ∣ St=s}
  • πpolicy (decision rule).
  • π(a ∣ s)probability of selecting action a in state s.
  • stationary policya policy that depends only on the current state and is independent of time t (as implied by the definition above).

A deterministic policy maps each state to a single action; a stochastic policy gives a distribution over actions.

A13.23

Theorem — Equivalent MDP Formulations

Theorem. MDP may equivalently use: r(s), r(s,a), r(s,a,s′), p(r,s′|s,a), or s0~p(s0).

Proof. Push all randomness into p(s′|s,a) by augmenting the state with last (a,r); then reward becomes deterministic r(s). ∎

A13.24

Finite (Tabular) MDP

An MDP is called finite (or tabular) if and only if both the state space and action space are finite:

|S| < ∞,   |A| < ∞
A13.25

Episodicity

In many cases the agent–environment interaction may “end” under certain conditions, and the fact of termination is accessible to the agent.

Definition (Terminal State). A state s is called terminal in an MDP if for all actions a ∈ A:

P(s′ = s ∣ s, a) = 1,   r(s, a) = 0,

i.e., with probability 1 the agent cannot leave the state.

One cycle of the process from a starting state up to a terminal state is called an episode.

A13.26

Episodic Environment

An environment is called episodic if, for any strategy, the interaction process is guaranteed to terminate within at most some finite number of steps Tmax.

A13.27

Theorem — Tree Structure of Episodic Environments

Theorem. In an episodic environment, the probability of returning to a previously visited state within a single episode is zero. Consequently, the state‑action graph is a tree.

Proof. Suppose state s can be revisited with probability p > 0 after T steps. By the Markov property, repeating the same actions yields an episode of at least nT steps with probability pn > 0 for any n, violating the existence of a finite bound Tmax. ∎

A13.28

Discounting

The objective is to find a policy π that maximizes the expected total reward:

𝔼T∼πt≥0 rt → maxπ, (1.2)

where rt ≐ r(st, at) is the reward at step t. To exclude cases where this sum diverges, we first bound the per‑step reward:

∀s, a : |r(s, a)| ≤ rmax. (1.3)

Even with this bound, infinite horizons can still lead to unbounded sums. We therefore introduce discounting with factor γ, defining the discounted return:

G ≐ ∑t=0 γt rt.

For any γ ∈ [0, 1) and bounded rewards, this series converges absolutely. The new objective becomes

𝔼T∼π [G] → maxπ.
  • rtreward received at time step t.
  • rmaxuniform bound on the absolute reward, |r(s,a)| ≤ rmax.
  • γdiscount factor, 0 ≤ γ < 1, controlling the present value of future rewards.
  • Gdiscounted return (cumulative discounted reward).
A13.29

Score (Performance) of a Policy

The score (or performance) of a policy π in a given MDP is the expected discounted return over trajectories:

J(π) ≐ 𝔼T∼π [ G ] = 𝔼T∼π [ ∑t=0 γt rt ]. (1.5)

The reinforcement learning problem consists of maximising this objective:

J(π) → maxπ.
  • J(π)score (performance) of policy π.
  • πstationary policy, π(a|s).
  • Ttrajectory (state‑action sequence).
  • T ∼ πdistribution of trajectories under π.
  • Gdiscounted return, Σ γt rt.
  • γdiscount factor, 0 ≤ γ < 1.
  • rtimmediate reward at time t, bounded |r| ≤ rmax.
  • 𝔼T∼π[·]expectation over trajectories under π.
A13.30

Claim 1 — Score Is Bounded

Claim 1. Under the stated assumptions (bounded rewards and either discounting γ < 1 or finite episode length Tmax with γ = 1), the score J(π) is bounded.

Proof.

If γ < 1: |R(T)| = |∑t≥0 γt rt| ≤ ∑t≥0 γt rmax = 1/(1 − γ) rmax.
If γ = 1 (episodic with horizon Tmax): |R(T)| ≤ Tmax rmax.

In either case, the absolute return of any trajectory is bounded by a constant M (where M = rmax/(1−γ) or M = Tmax rmax). Consequently, its expectation J(π) = 𝔼[R(T)] also satisfies |J(π)| ≤ M. ∎

  • R(T)return (cumulative discounted reward) of trajectory T.
  • rtreward at step t, bounded: |r(s,a)| ≤ rmax.
  • rmaxuniform upper bound on |r(s,a)|.
  • γdiscount factor (γ < 1 in the discounted case, γ = 1 in episodic).
  • Tmaxmaximum episode length when γ = 1.
A13.31

Note

If rewards are unbounded, policies with infinite return become indistinguishable (e.g., +1 every step vs. +1 every second step). Bounding avoids this.

Without discounting or bounded returns, the infinite sum may oscillate (e.g., +1/−1 alternating) and fail to converge, making the objective ill‑defined.

All functions are assumed measurable to ensure that all expectations and integrals exist.

A13.32

Transition

The tuples

T ≐ (s, a, r, s′, done)

where r ≐ r(s, a), s′ ∼ p(s′ ∣ s, a), and done ≐ done(s′), are called transitions.

  • scurrent state.
  • aaction taken.
  • rimmediate reward, r(s, a).
  • s′next state, sampled from p(s′ ∣ s, a).
  • doneboolean flag indicating whether s′ is terminal.
  • p(s′ ∣ s, a)transition probability from s to s′ given action a.
  • done(s′)function returning 1 if s′ is terminal, else 0.
A13.33

Claim — Supervised Learning is a Special Case of RL

Claim. Supervised learning with loss ℓ(ŷ, y) is an episodic MDP with horizon 1, γ = 1, and reward r = −ℓ.

Proof. Let S = X × Y ∪ {s0}, A = Ŷ. From initial state s0, environment draws (x, y) ∼ D and transitions to state s = (x, y) (reward 0). From s, action ŷ leads to a terminal state with reward −ℓ(ŷ, y). The expected return is then

J(π) = 𝔼(x,y)∼D[−ℓ(π(x), y)] = −𝔼[ℓ(π(x), y)].

Maximising J(π) is equivalent to minimising the expected supervised loss. ∎

  • X, Yinput space and target space of the supervised problem.
  • Ddata distribution over X × Y.
  • ℓ(ŷ, y)supervised loss function.
  • Ŷspace of predictions (action space A).
  • s0initial dummy state.
  • sstate (x, y) containing the input–target pair.
  • π(x)deterministic policy (predictor) mapping input x to prediction ŷ.
  • J(π)expected return (negative expected loss).
  • γdiscount factor, γ = 1 (episodic with horizon 1).
  • r = −ℓreward = negative loss.
A13.34

Simulator (Access to Transition Function)

The agent has a simulator (or access to the transition function) if it knows the reward function r(s,a) and can, at any moment during learning, sample an arbitrary number of draws from the transition kernel p(s′ ∣ s, a) for any chosen state‑action pair (s, a).

  • simulatormodel providing on‑demand samples of s′ ∼ p(s′ ∣ s, a) and the known reward r(s,a).
  • p(s′ ∣ s, a)transition probability distribution.
  • r(s, a)reward function, assumed known.
A13.35

Model‑Free Algorithm

An RL algorithm is classified as model‑free if it does not use, and does not attempt to learn, a model of the environment dynamics

p(s′ ∣ s, a)
  • p(s′ ∣ s, a)transition probability; a model‑free algorithm explicitly avoids estimating this distribution.
A13.36

Off‑Policy & On‑Policy Algorithms

Off‑policy. An RL algorithm is called off‑policy if it can use the interaction experience of an arbitrary policy for training.

On‑policy. An RL algorithm is called on‑policy if, for the next iteration of the algorithm, it requires interaction experience from some specific policy that is provided by the algorithm itself.

A13.37

Metaheuristics

A metaheuristic is a high‑level, problem‑independent algorithmic framework that guides a subordinate heuristic to explore the search space of an optimization problem. Unlike RL, metaheuristics typically do not maintain a value function or a policy gradient; they rely on generic operators (e.g., mutation, crossover, annealing) and evaluate candidate solutions solely via a fitness (cost) function.

A13.38

Value‑based Algorithms

Value‑based RL algorithms learn the optimal action‑value (or value) function, from which the policy is derived implicitly, typically by acting greedily with respect to the estimated values.

Qπ(s, a) ≐ 𝔼π[ Gt ∣ St = s, At = a ]
  • Qπ(s, a)action‑value function under policy π.
  • Gtdiscounted return from time t, Σk=0 γk Rt+k+1.
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • 𝔼π[·]expectation over trajectories following policy π.

The policy is then defined by acting greedily: π(s) = arg maxa Q(s, a).

A13.39

Policy Gradient Algorithms

Policy gradient algorithms directly parameterize the policy πθ(a|s) and optimize the performance J(θ) via stochastic gradient ascent. The gradient is given by the policy gradient theorem:

θ J(θ) = 𝔼T∼πθ[ ∑t=0θ log πθ(At|St) Gt ]

These algorithms are typically on‑policy, requiring samples from the current parameterized policy to compute unbiased gradient estimates.

  • θparameters of the policy (e.g., neural network weights).
  • πθ(a|s)stochastic policy parameterized by θ.
  • J(θ)expected return, J(θ) = 𝔼πθ[G].
  • Gtdiscounted return from time t, Σk=0 γk Rt+k+1.
  • θ log πθ(a|s)score function (gradient of log‑probability).
  • 𝔼T∼πθ[·]expectation over trajectories generated by πθ.
A13.40

Monte‑Carlo Performance Estimate

The performance of a policy π can be estimated from N sampled trajectories (episodes) by the unbiased Monte‑Carlo estimator:

J(π) ≐ 𝔼T∼π[G]  ≈  Ĵ(π) = (1/N) ∑i=1N G(τi),

where each τi is a trajectory independently drawn under π and G(τ) is its return.

  • J(π)true expected return (score) of π.
  • Ĵ(π)Monte‑Carlo estimate of J(π).
  • Nnumber of sampled trajectories.
  • τithe i‑th trajectory, τ = (s0, a0, r1, s1, …).
  • G(τ)discounted return of trajectory τ, Σt≥0 γt rt.
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • T∼πtrajectory distribution induced by policy π.
A13.41

Wall‑Clock Time

Wall‑clock time is the real (elapsed) time required by an RL algorithm to achieve a given level of performance, measured in full analogy with classical optimization methods.

A13.42

Sample Efficiency

Sample efficiency is the number of samples (or steps) of interaction with the environment required by the algorithm to achieve a given level of performance. This factor is crucial when real‑world interaction is expensive (e.g., training a physical robot).

A13.43

Note

Sample efficiency increases with algorithmic complexity: metaheuristics ≪ policy gradient ≪ value‑based ≪ model‑based, while wall‑clock time per update follows the reverse order.

A13.44

Local Optima Problem

The policy may converge to a local maximum of the expected return, i.e. J(π) < J(π*) while J(π*) = maxπ′ J(π′). In non‑convex policy landscapes this prevents reaching the global optimum.

  • J(π)expected return of policy π.
  • π*globally optimal policy.
A13.45

Sample Inefficiency Problem

Many RL algorithms require millions of environment interactions to converge, making them impractical when data collection is expensive (e.g., real‑world robots). Sample efficiency is often measured as the number of transitions needed to reach a given performance level.

A13.46

Exploration–Exploitation Trade‑off

The agent must balance exploration (trying new actions to discover higher rewards) and exploitation (choosing actions known to yield high rewards). Suboptimal balancing leads to either premature convergence or excessive wandering.

A13.47

Credit Assignment Problem

Determining which past actions contributed to a delayed reward is challenging. The return Gt = Σk=0 γk rt+k+1 mixes the effects of many decisions, and temporal credit assignment methods (e.g., TD‑learning) are used to disentangle them.

  • Gtdiscounted return from time t.
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • rtreward at time t.
A13.48

Reward Hypothesis

Any intellectual task can be stated (defined) by means of a reward function.

A13.49

Reward Shaping

Reward shaping transforms the original reward r(s, a) into a shaped reward r̃(s, a, s′) using a potential function Φ(s) without changing the optimal policy.

r̃(s, a, s′) ≐ r(s, a) + γ Φ(s′) − Φ(s) (1.7)

Proof. The shaped return over a trajectory is

t≥0 γtt = ∑t≥0 γt rt + ∑t≥0t+1 Φ(st+1) − γt Φ(st)).

The second sum telescopes: all intermediate terms cancel, leaving only −Φ(s0) and the vanishing boundary term limt→∞ γt Φ(st) = 0 (or Φ(sT) = 0 for terminal states). The constant −Φ(s0) is independent of the policy and thus does not affect the optimisation. Hence, maximising the shaped return is equivalent to maximising the original return. ∎

  • r(s, a)original reward function.
  • r̃(s, a, s′)shaped reward function.
  • Φ(s)bounded potential function on states.
  • γdiscount factor, 0 ≤ γ < 1.
  • s0initial state (constant offset vanishes from optimisation).
A13.50

Individual (Particle) and Fitness

The point θ at which the optimization algorithm queries the oracle value is called an individual (or particle), and the value Ĵ(θ) itself for a given individual is its estimate or fitness.

  • θparameter vector (individual/particle).
  • Ĵ(θ)estimated performance (fitness) of individual θ.
A13.51

Search Strategy

A distribution q(θ) in the parameter space Θ is called a search strategy.

  • q(θ)probability distribution over parameter vectors θ ∈ Θ.
  • Θparameter space (set of all possible policy parameters).
A13.52

Random Search

Random search consists of sampling individuals θk ∼ q(θ), k ∈ {0,1,2,…}, from a search strategy q(θ), evaluating their fitness Ĵ(θk), and returning the individual with the best estimate as the result:

θ* = arg maxk Ĵ(θk).
  • θkthe k‑th sampled individual (policy parameter vector).
  • q(θ)search strategy (distribution from which individuals are drawn).
  • Ĵ(θ)estimated fitness of individual θ.
  • θ*best individual found (maximising estimated fitness).
A13.53

Population

A set of individuals

P ≐ ( θi ∣ i ∈ {1, 2, …, N} )

is called a population of size N.

  • Ppopulation (collection of individuals).
  • θithe i‑th individual in the population (parameter vector).
  • Nsize of the population (number of individuals).
A13.54

Evaluation of the Population

Querying the oracle for all individuals of the population is called evaluation of the population:

Ĵ(P) ≐ ( Ĵ(θi) ∣ i ∈ {1, 2, …, N} )
  • Ĵ(P)evaluation of the population; vector of fitness estimates.
  • Ĵ(θi)estimated fitness of the i‑th individual.
  • Ppopulation, P = (θ1, …, θN).
  • θithe i‑th individual (policy parameter vector).
  • Nsize of the population.
A13.55

Selection Procedure

A selection procedure is the choice (possibly random, possibly with repetitions) of M individuals from the population. Formally, it is a conditional distribution

select(P+ ∣ P, Ĵ(P))

such that, with probability 1, every individual in the new set P+ belongs to the original population P:

∀θ ∈ P+ : θ ∈ P   (w.p. 1).
  • Poriginal population (set of N individuals).
  • P+selected subset (or multiset) of size M.
  • Mnumber of individuals selected.
  • Ĵ(P)vector of fitness estimates for the population.
  • select(· ∣ ·)probability distribution over subsets P+ given the current population and its fitness values.
A13.56

Greedy Selection

Greedy selection (selecttop M) is the deterministic choice of the M individuals with the highest estimated fitness from the population:

P+ = { θ ∈ P : Ĵ(θ) is among the top M values in Ĵ(P) }.
  • Mnumber of individuals to select (e.g., top‑M).
  • Ĵ(θ)estimated fitness of individual θ.
  • Ĵ(P)vector of fitness estimates for population P.
  • P+selected set of top‑M individuals.
A13.57

Note

A selection procedure only allows one to “reduce” the diversity of the population.

A13.58

Mutation

A mutation is a stochastic operator that generates a new individual (the child) from an existing one (the parent). Formally, it is a conditional probability distribution

m(θ̂ ∣ θ),

where θ is the parent and θ̂ is the child. The distribution may be parameterised (e.g., by a step‑size or noise level) and is used to introduce variation into the population.

  • m(θ̂ ∣ θ)probability (or density) of obtaining child θ̂ given parent θ.
  • θparent individual (current parameter vector).
  • θ̂child individual (mutated parameter vector).
A13.59

Simulated Annealing

Simulated annealing is a stochastic optimization algorithm that introduces a temperature‑controlled acceptance probability for new individuals. At iteration k, a child θ̂k+1 ∼ m(θ̂ ∣ θk) is generated from the parent θk. The child is accepted as the next point with probability

Pr(θk+1 = θ̂k+1) := min( 1, exp( (Ĵ(θ̂k+1) − Ĵ(θk)) / τk ) ),

where τk > 0 is the temperature at step k. If the child is fitter, it is accepted with probability 1; if worse, it may still be accepted with a probability that decreases as the temperature decreases, encouraging exploration early and exploitation later.

The sequence θ0, θ1, … forms a Markov chain with a stationary distribution that, under suitable conditions on the cooling schedule τk, converges to a distribution concentrated around the global optimum of J.

  • θkcurrent individual (parent) at iteration k.
  • θ̂k+1proposed new individual (child) drawn from mutation distribution m(·|θk).
  • Ĵ(θ)estimated fitness (performance) of individual θ.
  • τktemperature parameter at iteration k; τk > 0 controls the probability of accepting worse solutions.
  • m(θ̂ ∣ θ)mutation distribution (proposal kernel).
  • stationary distributionthe limiting distribution of the Markov chain as k → ∞, independent of initial θ0.
A13.60

Metropolis–Hastings Algorithm

The Metropolis–Hastings algorithm is a Markov chain Monte Carlo method that generates samples from a target distribution p(θ) by proposing candidates from a conditional distribution q(θ̂ ∣ θ) and accepting them with probability

α(θ, θ̂) = min( 1, [p(θ̂) q(θ ∣ θ̂)] / [p(θ) q(θ̂ ∣ θ)] ).

If the candidate is rejected, the chain stays at θ. Under mild conditions the chain has stationary distribution p(θ).

  • p(θ)target distribution (may be unnormalised).
  • q(θ̂ ∣ θ)proposal distribution for candidate θ̂ given current state θ.
  • θcurrent state of the chain.
  • θ̂proposed next state.
  • α(θ, θ̂)acceptance probability; a uniform draw u ∼ U[0,1] decides acceptance.
  • stationary distributionthe limiting distribution of the chain, p(θ).
A13.61

Claim — Stationary Distribution of Simulated Annealing

Claim. Suppose the oracle is exact, i.e. Ĵ(θ) ≡ J(θ), and the mutation distribution m(θ̂ ∣ θ) is symmetric and strictly positive:

∀ θ, θ̂ :   m(θ̂ ∣ θ) = m(θ ∣ θ̂) > 0.

If the temperature τ is kept constant (independent of the iteration k), then for any initial point θ0 the sequence k) generated by simulated annealing forms a Markov chain with the stationary distribution

limk→∞ p(θk) ∝ exp( J(θk) / τ ).

In other words, the chain samples from a Boltzmann‑Gibbs distribution over the parameter space, where J plays the role of the negative energy and τ is the temperature.

  • J(θ)true performance (expected return) of policy πθ.
  • Ĵ(θ)estimated performance; here assumed exact (Ĵ ≡ J).
  • m(θ̂ ∣ θ)mutation kernel (proposal distribution); symmetric means m(θ̂|θ)=m(θ|θ̂).
  • τconstant temperature (>0) controlling the concentration of the stationary distribution.
  • θkindividual at iteration k of the simulated annealing chain.
  • exp(J/τ)unnormalised density of the limiting Boltzmann‑Gibbs distribution.
A13.62

Evolutionary Algorithm

An algorithm is called evolutionary if it constructs a sequence of populations P1, P2, …, where at the k-th step the next generation Pk is built on the basis of the previous one Pk−1.

  • Pkpopulation at generation k (a set of individuals).
  • Pk−1previous population.
A13.63

Evolution Strategy (ES)

An evolution strategy is a black‑box optimisation algorithm that maintains a population of search points and iteratively improves them through mutation and selection. The canonical form is the (μ/ρ +, λ)-ES, where μ parents produce λ offspring using ρ recombination parents per offspring.

Algorithm (simple (μ, λ)-ES):

  1. Initialisation: Sample μ parents P = {θ1, …, θμ} randomly.
  2. Repeat until a termination criterion is met:
    1. Mutation: For j = 1, …, λ, select a parent uniformly and generate offspring:   θ′j = θparent + εj,   εj ∼ 𝒩(0, σ2 I).
    2. Evaluation: Compute fitness Ĵ(θ′j) for all offspring.
    3. Selection: Form the new parent population P by taking the μ best offspring (comma selection).
    4. Adaptation (optional): Update step‑size σ (e.g., 1/5th success rule).
  3. Return the best individual found.
  • μnumber of parents (population size).
  • λnumber of offspring per generation (λ ≥ μ).
  • ρnumber of parents recombined per offspring (ρ = 1 means no recombination).
  • θindividual (parameter vector).
  • ε ~ 𝒩(0, σ2 I)mutation noise drawn from a multivariate Gaussian with zero mean and covariance σ2 I.
  • σmutation step‑size (global or per‑dimension).
  • Ĵ(θ)estimated fitness of individual θ.
  • comma (“,”) selectionnext parent population chosen only from offspring.
  • plus (“+”) selectionnext parent population chosen from union of parents and offspring.
A13.64

Genetic Algorithm (GA)

A genetic algorithm is an evolutionary optimisation method that evolves a population of individuals using selection, crossover (recombination), and mutation.

Algorithm 2: Genetic Search

  1. Initialisation: Generate an initial population P0 of N individuals (random parameter vectors).
  2. Repeat for each generation k = 0, 1, 2, … until termination:
    1. Evaluation: Compute fitness Ĵ(θ) for all individuals in Pk.
    2. Selection: Select parents from Pk based on fitness (e.g., roulette wheel, tournament selection).
    3. Crossover: With probability pc, pair parents and exchange genetic material to produce offspring.
    4. Mutation: With probability pm, randomly perturb offspring (e.g., Gaussian noise).
    5. Replacement: Form Pk+1 by replacing the old population with offspring (optionally keep the best individuals via elitism).
  3. Return the best individual found.
  • Npopulation size.
  • Pkpopulation at generation k.
  • Ĵ(θ)fitness (performance) of individual θ.
  • pccrossover probability.
  • pmmutation probability.
A13.65

Evolutionary Strategy (Distribution)

The distribution q(θ ∣ λk) from which the individuals of the k-th population are generated is called an evolutionary strategy (ES). The population is then

Pk ≐ { θi ∼ q(θ ∣ λk) ∣ i ∈ {1, 2, …, N} }.
  • q(θ ∣ λk)evolutionary strategy distribution (e.g., a Gaussian with mean and covariance parameters λk).
  • λkparameters of the search distribution at iteration k.
  • Pkpopulation of size N drawn i.i.d. from q(·|λk).
  • θithe i‑th individual in the population.
  • Npopulation size.
A13.66

Estimation of a Rare Probability Event

Rare event estimation is the problem of estimating a very small probability p = P(X ∈ A) where P(X ∈ A) ≪ 1. Standard Monte Carlo fails due to high variance; importance sampling (IS) is typically used, shifting the sampling distribution to q and reweighting:

p = 𝔼f[𝟙A(X)] = 𝔼q[ (f(X) / q(X)) 𝟙A(X) ].

The IS estimator from N samples Xi ∼ q is

IS = (1/N) ∑i=1N (f(Xi) / q(Xi)) 𝟙A(Xi).
  • ptarget rare probability, p ≪ 1.
  • Xrandom vector with original density f.
  • Arare event set.
  • 𝟙A(x)indicator function: 1 if x ∈ A, 0 otherwise.
  • qimportance sampling distribution, q(x) > 0 whenever f(x)𝟙A(x) > 0.
  • w(x) = f(x)/q(x)importance weight.
  • ISimportance sampling estimator of p.
  • Nnumber of samples drawn from q.
A13.67

Algorithm: Cross‑Entropy Method for Rare‑Event Probability

At the k-th step:

  1. Sample x1, …, xN ∼ q(x ∣ λk).
  2. Sort the values f(xi): f(1) ≤ f(2) ≤ ⋯ ≤ f(N).
  3. Set γk = min( γ, f(M) ), where M = ⌈ρN⌉ (elite sample count).
  4. Solve the weighted maximum likelihood problem:
    λk+1 = arg maxλ (1/N) ∑j=1N I[ f(xj) ≥ γk ] p(xj) q(xj∣λk) log q(xj ∣ λ). (2.4)
  5. Stopping criterion: γk = γ.

Obtaining the final estimate:

  1. Sample x1, …, xN ∼ q(x ∣ λk).
  2. Return
    ℓ ≈ (1/N) ∑j=1N I[ f(xj) ≥ γk ] p(xj) q(xj∣λk)
  • p(x)original density of the random vector.
  • q(x ∣ λ)parametric importance density with parameter λ.
  • λkparameter at iteration k.
  • f(x)scoring function; the rare event is {f(X) ≥ γ}.
  • γtarget level defining the rare event.
  • γkadaptive threshold at step k.
  • Mnumber of elite samples, M = ⌈ρN⌉.
  • ρfraction of elite samples (e.g., 0.1).
  • I[·]indicator function.
  • Nsample size per iteration.
  • final importance sampling estimate of the rare‑event probability.
A13.68

Cross‑Entropy Method for Stochastic Optimization

The Cross‑Entropy Method (CEM) for stochastic optimization finds a parameter θ that maximises an objective function J(θ). It maintains a parametric sampling distribution q(θ ∣ λ) and iteratively refines its parameter λ by sampling a population, selecting an elite subset of the best‑performing individuals, and updating λ to the maximum likelihood estimate on that elite set.

At iteration k:

  1. Draw N samples θ1, …, θN ∼ q(θ ∣ λk).
  2. Evaluate J(θi) for all i.
  3. Sort the values: J(1) ≤ J(2) ≤ … ≤ J(N).
  4. Define the elite set Ek = {θi : J(θi) ≥ γk}, where γk = J(⌈ρN⌉) is the (1−ρ)-quantile of the current sample scores.
  5. Update the distribution parameter by maximum likelihood:
    λk+1 = arg maxλθ ∈ Ek log q(θ ∣ λ).
  6. If a stopping criterion is met, return the best found solution; otherwise increment k.

The process shifts the sampling distribution toward regions of high objective value, typically collapsing to a point mass near a local (or global) optimum.

  • J(θ)objective function (reward, fitness) to be maximised.
  • q(θ ∣ λ)parametric probability density over the solution space Θ.
  • λparameter of the sampling distribution (e.g., mean μ and covariance Σ for a Gaussian).
  • λkdistribution parameter at iteration k.
  • Npopulation size (number of samples per iteration).
  • ρelite fraction, typically 0.05–0.2; determines the size of the elite set M = ⌈ρN⌉.
  • γkthreshold equal to the J-value of the M‑th best sample (adaptive level).
  • Ekelite set of individuals whose objective values lie at or above γk.
A13.69

Algorithm Cross‑Entropy Method for Optimization with a Zeroth‑Order Oracle

Algorithm applies the cross‑entropy method to maximize an objective J(θ) when only function evaluations (a zeroth‑order oracle) are available. A parametric distribution q(θ ∣ λ) is iteratively updated by selecting the best‑performing samples (elites) and moving the distribution toward them.

Input: oracle J(θ), initial parameter λ0, sample size N, elite fraction ρ, max iterations K.

For k = 0, 1, …, K−1 do

  1. Draw θ1, …, θN ∼ q(θ ∣ λk).
  2. Evaluate J(θi) for all i.
  3. Sort the values: J(1) ≤ J(2) ≤ … ≤ J(N).
  4. Determine the elite set Ek = {θi : J(θi) ≥ γk} where γk = J(⌈ρN⌉).
  5. Update the distribution parameter by maximizing the log‑likelihood on the elite set:
    λk+1 = arg maxλθ ∈ Ek log q(θ ∣ λ).

Output: the best individual found during the whole process, θ* = arg maxi,k J(θi).

  • J(θ)objective function (zeroth‑order oracle).
  • q(θ ∣ λ)parametric sampling density (e.g., Gaussian).
  • λkdistribution parameter at iteration k.
  • Nnumber of samples per iteration.
  • ρelite fraction, 0 < ρ ≤ 1, typical value 0.1.
  • γkadaptive elite threshold (quantile).
  • Ekelite set of the top‑ρN individuals.
  • Knumber of iterations.
A13.70

Cross‑Entropy Method for Reinforcement Learning

The Cross‑Entropy Method (CEM) for RL is a derivative‑free, population‑based policy search algorithm. It parameterises the policy πθ with parameters θ and maintains a Gaussian distribution q(θ ∣ λ) = N(θ ∣ μ, Σ) over θ. The goal is to maximise the expected return J(θ) = 𝔼πθ[G]. CEM iteratively refines μ, Σ by sampling a population of parameter vectors, evaluating their performance via Monte‑Carlo rollouts, selecting the top‑performing elite set, and updating μ, Σ to the maximum likelihood estimate on that elite set.

Algorithm. Given initial μ0, Σ0, population size N, elite fraction ρ, and K iterations:

  1. For k = 0, …, K−1:
    1. Sample θi ∼ N(μk, Σk), i = 1,…, N.
    2. For each θi, run policy πθi in the environment and estimate Ĵ(θi) (e.g., average return over one or more episodes).
    3. Sort Ĵ(θi) and select the M = ⌈ρN⌉ best‑performing samples as the elite set Ek.
    4. Update the Gaussian parameters by computing the empirical mean and covariance of the elites:
      μk+1 = mean(Ek),  Σk+1 = cov(Ek).
    5. Optionally, apply a regularisation (e.g., add small diagonal to Σk+1) to prevent premature collapse.
  2. Output: the policy πθ* with the highest estimated Ĵ observed during training, or the final μK.

CEM ignores the temporal structure of RL and treats J(θ) as a black‑box function; it is therefore a zeroth‑order method. It is often used in model‑free settings when gradient information is unavailable or unreliable.

  • θpolicy parameters.
  • πθstochastic or deterministic policy parameterised by θ.
  • J(θ)expected discounted return of πθ.
  • Ĵ(θ)Monte‑Carlo estimate of J(θ) from one or more episodes.
  • Npopulation size per iteration.
  • ρelite fraction (e.g., 0.1).
  • μk, Σkmean vector and covariance matrix of the Gaussian sampling distribution at iteration k.
  • Ekelite set containing the M best samples from iteration k.
  • M = ⌈ρN⌉number of elite samples.
A13.71

Natural Evolution Strategies

Natural Evolution Strategies (NES) is a family of black‑box optimisation algorithms that update a parametric search distribution q(θ ∣ λ) by following the natural gradient of the expected fitness J(λ) = 𝔼θ∼q(·|λ)[J(θ)]. The gradient with respect to λ is given by the “log‑likelihood trick”:

λ J(λ) = 𝔼θ∼q(·|λ)[ J(θ) ∇λ log q(θ ∣ λ) ].

The natural gradient is then obtained by premultiplying with the inverse Fisher information matrix F(λ) of q(·|λ):

λk+1 = λk + η F(λk)−1λ J(λk).

In practice, the gradient is estimated from a population of samples, and rank‑based fitness shaping is often used for invariance. NES includes algorithms like xNES (exponential NES) and separable NES (sNES).

  • q(θ ∣ λ)parametric search distribution (e.g., Gaussian with mean and covariance in λ).
  • λparameters of the search distribution.
  • J(λ)expected fitness under the search distribution.
  • J(θ)fitness (return) of an individual policy with parameters θ.
  • λ log q(θ∣λ)score function (gradient of log‑density).
  • F(λ)Fisher information matrix of q(·∣λ).
  • ηlearning rate (step size).
  • natural gradientF(λ)−1λ J(λ); follows the steepest ascent direction under the KL‑divergence metric.
A13.72

Theorem — Gradient of Expected Fitness

Theorem Let q(θ ∣ λ) be a probability density over parameters θ, differentiable w.r.t. λ, and let J(θ) be a function independent of λ. Define the expected fitness

g(λ) ≐ 𝔼θ ∼ q(·∣λ) [ J(θ) ] = ∫ J(θ) q(θ ∣ λ) dθ.

Then, under suitable regularity conditions, the gradient of g is

λ g(λ) = 𝔼θ ∼ q(·∣λ) [ J(θ) ∇λ log q(θ ∣ λ) ]. (2.6)

Proof.

λ g(λ) = ∇λ ∫ J(θ) q(θ ∣ λ) dθ
= ∫ J(θ) ∇λ q(θ ∣ λ) dθ  (dominated convergence, differentiation under the integral)
= ∫ J(θ) q(θ ∣ λ) ∇λ log q(θ ∣ λ) dθ  (since ∇λ q = q ∇λ log q)
= 𝔼θ ∼ q(·∣λ) [ J(θ) ∇λ log q(θ ∣ λ) ].

This identity, often called the score function estimator or REINFORCE gradient, allows estimating the gradient of an expectation by sampling from q and computing weighted log‑density gradients. It is a cornerstone of both evolutionary strategies and policy gradient methods.

  • g(λ)expected fitness under the search distribution parameterised by λ.
  • q(θ ∣ λ)probability density of the parameters θ given distribution parameters λ.
  • J(θ)fitness (or return) of the policy with parameters θ; assumed independent of λ.
  • λ log q(θ ∣ λ)score function (gradient of the log‑density with respect to λ).
  • 𝔼θ∼q(·∣λ)[·]expectation over θ drawn from q(·∣λ).
A13.73

Lemma — Zero-Mean Gaussian Perturbation

Since ν is sampled from a standard Gaussian, on average:

𝔼ν ∼ 𝒩(0, I) [ Ĵ(θ) / σ · ν ] = (Ĵ(θ) / σ) 𝔼ν ∼ 𝒩(0, I) [ν] = 0.

Consequently, (2.10) estimates the same gradient as the formula

θk+1 := θk + α ∑i=0N (Ĵ(θ + σ νi) / σ) νi,

which coincides with the OpenAI-ES formula up to a change of notation: it suffices to note that θ + σν is a sample from 𝒩(θ, σ²I). ∎

  • νperturbation vector drawn from the standard Gaussian 𝒩(0, I).
  • σstandard deviation of the search distribution; controls exploration scale.
  • Ĵ(θ)estimated fitness (or return) of the policy with parameters θ.
  • θ + σνa sample from the Gaussian search distribution 𝒩(θ, σ²I).
  • αlearning rate (step size) for the parameter update.
  • Nnumber of perturbation samples (population size).
A13.74

Remark — Generality–Efficiency Tradeoff

The generality–efficiency tradeoff governs the relationship between problem structure and algorithm performance:

  • More general problem(less structure) → less efficient algorithm. The algorithm must search a larger hypothesis space with weaker inductive biases, requiring more samples and compute to converge.
  • More assumptions(more structure) → provably better algorithms. Exploiting domain-specific structure — convexity, smoothness, Lipschitz continuity, linearity — yields tighter convergence rates and lower sample complexity.

This tradeoff is a fundamental organising principle across optimisation and learning theory: the no free lunch theorems imply that no algorithm outperforms all others on every problem class, while structural assumptions enable specialised methods that excel on restricted subclasses. It also mirrors the bias–variance and sample complexity–model capacity tradeoffs in statistical learning. ∎

A13.75

Remark — Glutton's Paradox

Glutton's Paradox captures a subtle failure mode in optimisation and sequential decision-making: an agent that greedily consumes the largest immediate reward at each step may, in the long run, end up worse off than one that exercises restraint.

The paradox arises when the objective function has diminishing returns, hidden state dependencies, or non-stationary structure — the greedy choice depletes future resources, forecloses valuable options, or shifts the environment to an unfavourable regime. It is a cautionary tale against conflating myopic optimality with global optimality, and it motivates mechanisms such as exploration bonuses, long-term credit assignment, and budget constraints that temper short-term greed with long-term foresight. ∎

  • Myopic optimalitychoosing the action with the highest immediate payoff without considering future consequences.
  • Global optimalitymaximising cumulative return over the full horizon, which may require sacrificing short-term gain.
  • Diminishing returnsa setting where each additional unit of a resource yields progressively smaller marginal benefit.
  • Exploration bonusan added reward term that incentivises visiting under-explored states, counteracting greed.
A13.76

Lemma — Markov Independence (Conditional Independence)

Claim.

p(T:t, Tt: ∣ st) = p(T:t ∣ st) · p(Tt: ∣ st).

In words: the past and future are conditionally independent given the present.

Proof.

p(T:t, Tt: ∣ st)
= p(T:t ∣ st) · p(Tt: ∣ st, T:t)  (chain rule of probability)
= p(T:t ∣ st) · p(Tt: ∣ st)  (Markov property: the future depends on the past only through the present state).

This property is the defining feature of Markov systems: once the current state st is known, additional knowledge of the history T:t provides no extra information about the future Tt:. It underpins the Bellman equation, the factorisation of value functions, and the efficiency of dynamic programming in MDPs.

  • T:tthe past trajectory (transitions and rewards up to time t).
  • Tt:the future trajectory (transitions and rewards from time t onward).
  • stthe present state — a sufficient statistic that renders past and future independent.
  • Markov propertythe conditional independence p(future ∣ past, present) = p(future ∣ present).
A13.77

Definition — Reward-to-Go

Reward-to-Go. The discounted return from time t onward:

Rt ≐ R(Tt:) = ∑t̂ ≥ t γt̂ − t r.
  • t̂ = tweight γ0 = 1: the current step's reward counts fully, with no discount.
  • t̂ > tweight γt̂ − t: future rewards are exponentially discounted by the time lag.

This object isolates the future contribution to the total return, discarding the past. It is the natural target for state-value and action-value functions, and it satisfies the recursive identity Rt = rt + γ Rt+1, which is the foundation of the Bellman equation. ∎

  • Rtreturn from time t onward; also called the reward-to-go or discounted future return.
  • γdiscount factor, γ ∈ [0, 1], controlling the present value of future rewards.
  • rscalar reward received at time step t̂.
A13.78

Future Determinism by Current State

Claim. The distribution of the future trajectory from time t given the current state st = s is identical to the distribution of a full trajectory starting from initial state s0 = s:

p(Tt: ∣ st = s) ≡ p(T ∣ s0 = s).

In words: the future from t looks exactly like a complete trajectory generated from the beginning with the same starting state.

Proof. Let Tt: = (at, st+1, at+1, …). Then

p(Tt: ∣ st = s) = ∏t̂ ≥ t p(st̂+1 ∣ s, a) π(a ∣ s),

where the product runs over time indices starting at t. This is exactly the same infinite product as the trajectory distribution p(T ∣ s0 = s) (see A13.21), merely with a shift in the index. By the Markov property and time‑homogeneity of the environment and policy, the conditional probabilities depend only on the state and action, not on the absolute time. Hence the two distributions coincide. ∎

  • Tt:future trajectory from time t onward: (at, st+1, at+1, …).
  • Tfull trajectory starting at t = 0: (s0, a0, s1, a1, …).
  • p(Tt: ∣ st = s)distribution of the future after time t given st = s.
  • p(T ∣ s0 = s)trajectory distribution with initial state s (as defined in A13.21).
  • π(a ∣ s)stationary policy (see A13.22).
  • p(s′ ∣ s, a)time‑homogeneous transition kernel (see A13.15).
A13.79

V‑Function (State Value Function)

For a given MDP and policy π, the state value function (or V‑function) Vπ(s) is the expected return when starting from state s and following π thereafter:

Vπ(s) ≐ 𝔼T∼π ∣ s0=s [ R(T) ] (3.2)
  • Vπ(s)value of state s under policy π; expected cumulative discounted reward.
  • πa stationary policy, π(a|s).
  • sinitial state (s0 = s).
  • Ttrajectory (s0, a0, s1, a1, …) drawn under π and the environment dynamics.
  • T ∼ π ∣ s0=strajectory distribution conditioned on starting at state s.
  • R(T)return of trajectory T (discounted sum of rewards).
  • 𝔼[·]expectation with respect to the trajectory distribution.
A13.80

Claims on the V‑Function

Claim For any time step t, the value function can be expressed in terms of the future return from that time:

Vπ(s) = 𝔼T∼π ∣ st=s [ Rt ],

where Rt is the return (discounted cumulative reward) from step t onward.

Explanation. Apply Claim 8 (future determinism by current state, A13.78) to the return random variable. ∎

Claim Vπ(s) is bounded:

| Vπ(s) | ≤ rmax1 − γ  (or ≤ Tmax rmax when γ = 1).

Claim For a terminal state s (see A13.25), the value is zero:

Vπ(s) = 0.

Notice that any policy π induces a unique function Vπ. For a given MDP and policy π, the value function is well‑defined by its definition, though computing it exactly is a separate challenge.

  • Vπ(s)state value function under policy π (see A13.79).
  • Rtreturn from step t: Rt = Σk=0 γk rt+k+1 (or simply the future discounted sum).
  • T ∼ π ∣ st=strajectory distribution conditioned on being in state s at time t.
  • rmaxuniform bound on absolute rewards.
  • γdiscount factor, 0 ≤ γ ≤ 1.
A13.81

Bellman Expectation Equation for Vπ

The value function Vπ satisfies a recursive consistency condition known as the Bellman expectation equation:

Vπ(s) = 𝔼a ∼ π(·∣s) [ r(s, a) + γ 𝔼s′ ∼ p(·∣s,a) Vπ(s′) ]. (3.3)

Proof. Starting from the definition (A13.79) and using the structure of the trajectory distribution (A13.21):

Vπ(s) = 𝔼T∼π∣s0=s[ R(T) ]
= 𝔼a0∼π(·∣s) 𝔼s1∼p(·∣s,a0) 𝔼a1,s2,…[ r(s, a0) + γ (r1 + γ r2 + …) ]
= 𝔼a∼π(·∣s) [ r(s, a) + γ 𝔼s′∼p(·∣s,a) 𝔼future∣s1=s′[ Σk=0 γk rk+1 ] ]
= 𝔼a∼π(·∣s) [ r(s, a) + γ 𝔼s′∼p(·∣s,a) Vπ(s′) ].

The last equality follows because, by the Markov property and Claim 8 (A13.78), the inner expectation from s′ onward is exactly Vπ(s′). ∎

  • Vπ(s)state value function for policy π (A13.79).
  • π(a∣s)policy distribution over actions in state s.
  • r(s, a)expected immediate reward for taking action a in state s.
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • p(s′∣s, a)transition probability from s to s′ given action a.
  • 𝔼a∼π, 𝔼s′∼pexpectations under the policy and environment dynamics.
A13.82

Optimal Policy

A policy π* is optimal if it achieves the highest possible value from every state:

∀ π, s :  Vπ*(s) ≥ Vπ(s).

Equivalently, it is sufficient that it dominates all other policies from the initial state s0:

∀ π :  Vπ*(s0) ≥ Vπ(s0).

Under mild conditions (e.g., stationary MDP with discounting, or finite horizon), these two characterisations coincide. The first, stronger definition is used to derive the Bellman optimality equations.

  • π*optimal policy.
  • Vπ(s)state value function under policy π (A13.79).
  • s0initial state of the MDP.
A13.83

Non‑Equivalence of Optimality Definitions

Claim. The condition “∀π, s : Vπ*(s) ≥ Vπ(s)” (optimal from every state) is not equivalent to “∀π : Vπ*(s0) ≥ Vπ(s0)” (optimal only from the initial state) without additional assumptions (e.g., ergodicity).

Proof (counterexample). Consider an MDP with two states, s0 and s1. The initial state is s0. Transitions from s0: every action leads deterministically to a terminal state sT with reward 1. From s1: two actions are available — action a yields reward 0 and terminal; action b yields reward 100 and terminal. The environment dynamics never transition to s1 from s0; s1 is unreachable under any policy.

Now define two policies:

  • π1 : in s0 any action (same), in s1 choose a (reward 0).
  • π2 : in s0 any action, in s1 choose b (reward 100).

Values from s0 are identical: Vπ1(s0) = Vπ2(s0) = 1 (the reward from the single step). Both policies are equally good from s0 and satisfy the second definition relative to each other. However, from s1 we have Vπ1(s1) = 0 < 100 = Vπ2(s1). Hence π1 is not optimal under the state‑wise definition because it is strictly worse from s1. The two optimality notions diverge when the MDP contains states unreachable from s0. ∎

In practical RL, one often assumes that all states are reachable under some policy (or that the optimal value function is unique up to irrelevant states), making the definitions effectively equivalent, but the distinction matters in general.

  • s0initial state (start state).
  • s1unreachable state in the counterexample.
  • π1, π2policies demonstrating the non‑equivalence.
  • Vπ(s)state value function (A13.79).
A13.84

Optimal V‑Function

The optimal state value function V* is the maximum possible expected return achievable from any state s under any policy:

V*(s) ≐ maxπ Vπ(s) (3.4)
  • V*(s)optimal value of state s; the highest expected return from s.
  • πany stationary policy.
  • Vπ(s)state value function under policy π (A13.79).

If an optimal policy π* exists, then V*(s) = Vπ*(s) for all s. The function V* plays a central role in the Bellman optimality equations.

A13.85

Q‑Function (State‑Action Value Function)

For a given MDP and policy π, the Q‑function (or state‑action value function) Qπ(s, a) is the expected return when starting from state s, taking action a, and following π thereafter:

Qπ(s, a) ≐ 𝔼T∼π ∣ s0=s, a0=at≥0 γt rt
  • Qπ(s, a)expected return when taking action a in state s and then following policy π.
  • πstationary policy, π(a|s).
  • sinitial state (s0 = s).
  • ainitial action (a0 = a).
  • Ttrajectory (s0, a0, s1, a1, …) drawn under the given condition.
  • T ∼ π ∣ s0=s, a0=atrajectory distribution conditioned on starting state s and initial action a, then following π.
  • rtreward at time t, rt = r(st, at).
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • 𝔼[·]expectation over trajectories conditioned as specified.

Unlike Vπ(s) (A13.79), the Q‑function separates the initial action from the subsequent policy, which is essential for learning and control.

A13.86

Relationship Between Value Functions

The V-function and Q-function for a given policy π are linked by two fundamental equations:

Qπ(s, a) = r(s, a) + γ 𝔼s′ ∼ p(·∣s,a) Vπ(s′) (3.5)
Vπ(s) = 𝔼a ∼ π(·∣s) Qπ(s, a) (3.6)

Proof. Equation (3.5) decomposes the expected return after taking action a in state s into the immediate reward plus the discounted value of the next state, by the Markov property and the definition of Vπ. Equation (3.6) follows directly from the definitions: Vπ(s) is the expectation of Qπ(s, a) when the action is drawn from the policy π(·∣s). ∎

  • Vπ(s)state value function (A13.79).
  • Qπ(s, a)state‑action value function (A13.85).
  • r(s, a)expected immediate reward for state‑action pair.
  • γdiscount factor.
  • p(s′ ∣ s, a)transition probability.
  • 𝔼s′∼pexpectation over next state.
  • 𝔼a∼πexpectation over actions drawn from the policy.
A13.87

Bellman Expectation Equation for Qπ

The Bellman expectation equation for the Q‑function is:

Qπ(s, a) = r(s, a) + γ 𝔼s′ ∼ p(·∣s,a) 𝔼a′ ∼ π(·∣s′) Qπ(s′, a′) (3.7)

Proof. Starting from the definition of Qπ(s,a) (A13.85), write the return as the immediate reward plus the discounted future:

Qπ(s,a) = 𝔼[ r0 + γ r1 + γ2 r2 + … ∣ s0=s, a0=a ]
= r(s,a) + γ 𝔼s′∼p(·∣s,a), a′∼π(·∣s′) 𝔼[ r1 + γ r2 + … ∣ s1=s′, a1=a′ ]
= r(s,a) + γ 𝔼s′∼p(·∣s,a) 𝔼a′∼π(·∣s′) Qπ(s′, a′).

The inner expectation is exactly Qπ(s′,a′) because it is the return from t=1 onward given s1=s′ and a1=a′, which by time‑homogeneity equals the definition. ∎

  • Qπ(s, a)state‑action value function under policy π (A13.85).
  • r(s, a)expected immediate reward.
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • s′ ∼ p(·∣s,a)next state drawn from the transition dynamics.
  • a′ ∼ π(·∣s′)next action drawn from the policy at the new state.
  • 𝔼s′ 𝔼a′nested expectations over the next state and action.
A13.88

Bellman’s Principle of Optimality

An optimal policy has the property that whatever the initial state and initial decision are, the remaining decisions must constitute an optimal policy with regard to the state resulting from the first decision.

Formally, if a policy π* is optimal, then for every s and every reachable next state s′, the tail of the policy (from step 1 onward) must be optimal for the sub‑problem starting at s′.

This principle is the foundation of dynamic programming and leads directly to the Bellman optimality equations for V* and Q*.

A13.89

Optimal Q‑Function

For a given MDP, the optimal Q‑function (or optimal state‑action value function) is the maximum possible expected return achievable after taking a specific action a in state s:

Q*(s, a) ≐ maxπ Qπ(s, a)

Here the maximum is taken over all stationary policies. Q* plays a central role in control: if it is known, an optimal policy can be obtained by acting greedily. However, the connection to V* requires additional steps.

  • Q*(s, a)optimal state‑action value: the maximum expected return achievable from state s after taking action a.
  • Qπ(s, a)state‑action value function under a specific policy π (A13.85).
  • πany stationary policy.
  • maxπsupremum over all policies; in finite MDPs a maximum is attained.
A13.90

Claim — Optimal Q‑Function Inequality

Claim . For any state s and action a,

Q*(s, a) ≤ r(s, a) + γ 𝔼s′ ∼ p(·∣s,a) V*(s′).

This inequality bounds the optimal value of a state‑action pair by the immediate reward plus the discounted expected optimal value of the next state. It does not yet establish equality because the maximum over policies for the tail may not be attained by a single policy that also attains the maximum for the first step. The full Bellman optimality equation (equality) requires additional arguments.

  • Q*(s, a)optimal state‑action value (A13.89).
  • V*(s)optimal state value (A13.84).
  • r(s, a)expected immediate reward.
  • γdiscount factor.
  • p(·∣s, a)transition kernel from (s, a).
  • 𝔼s′expectation over the next state.
A13.91

Claim — Optimal V‑Function Inequality

Claim For any state s,

V*(s) ≤ maxa Q*(s, a).

The optimal value of a state is bounded above by the maximum over actions of the optimal Q‑value. This follows from the definition of V* as the maximum expected return over all policies, while Q*(s,a) is the maximum expected return after a specific first action. Equality will be established once the Bellman optimality equation is proved.

  • V*(s)optimal state value (A13.84).
  • Q*(s, a)optimal state‑action value (A13.89).
  • maxamaximum over all actions a ∈ A.
A13.92

Greedy Policy with Respect to a Q‑Function

For a given (approximate) Q‑function Q(s, a), the deterministic policy that selects the action with the highest estimated value in each state is called greedy with respect to Q:

π(s) ≐ arg maxa Q(s, a).
  • Q(s, a)an approximation (or the true) state‑action value function.
  • π(s)greedy policy; ties are broken arbitrarily (e.g., uniformly among maximisers).
  • arg maxathe action(s) that maximise the given expression.

When Q = Q*, the greedy policy is optimal.

A13.93

Abandoning Stationarity

Abandoning stationarity means considering policies that depend on the time step or on the full interaction history, rather than limiting oneself to stationary policies π(a|s) that are functions of the current state only. Formally, a non‑stationary policy at time t may be written as πt(a | s0, a0, …, st) or simply πt(a|s) if only the time index matters.

In an infinite‑horizon discounted MDP with a stationary environment, stationary policies are sufficient for optimality. However, abandoning stationarity can be beneficial in:

  • Finite‑horizon problems, where the optimal policy naturally depends on the remaining number of steps.
  • Exploration strategies during learning (e.g., ε‑greedy with a time‑varying ε).
  • Cases with function approximation, where the policy network may implicitly encode a time‑varying representation.
  • Non‑stationary environments (where the transition or reward function changes over time) – here stationarity is impossible to maintain in the strict sense.
  • πtpolicy at time t, potentially dependent on history or time index.
  • stationary policya policy π(a|s) that uses only the current state (A13.22).
  • non‑stationaryany policy that does not satisfy the time‑invariance property.
A13.95

Bellman Equations for Non‑Stationary Value Functions

Claim. For a non‑stationary policy π = {πt}, the time‑dependent value functions satisfy:

Vtπ(s) = 𝔼a ∼ πt(·∣s) [ r(s, a) + γ 𝔼s′ ∼ p(·∣s,a) Vt+1π(s′) ]
Qtπ(s, a) = r(s, a) + γ 𝔼s′ ∼ p(·∣s,a) Vt+1π(s′)

Proof. Starting from the definition of Vtπ(s) (A13.94), we factor the return into the immediate reward at time t and the discounted remainder:

Vtπ(s) = 𝔼at∼πt(·∣s) 𝔼st+1∼p(·∣s,at) 𝔼at+1∼πt+1(·∣st+1)… [ r(s, at) + γ (rt+1 + γ rt+2 + …) ]

By linearity of expectation, the inner expectation from step t+1 onward is precisely Vt+1π(s′) (by definition A13.94, applied at time t+1). Thus

Vtπ(s) = 𝔼a∼πt(·∣s) [ r(s, a) + γ 𝔼s′∼p(·∣s,a) Vt+1π(s′) ].

The second identity follows by conditioning on the first action being fixed to a rather than sampled from the policy. ∎

  • Vtπ(s)state value at time t under non‑stationary policy π (A13.94).
  • Qtπ(s, a)state‑action value at time t under non‑stationary policy π (A13.94).
  • πt(a ∣ s)policy at time step t.
  • r(s, a)expected immediate reward.
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • p(s′ ∣ s, a)transition probability from s to s′ given action a (time‑homogeneous environment).
A13.96

Optimal Non‑Stationary Value Functions

For a given MDP, the optimal value functions among all non‑stationary policies are defined as the suprema (maxima) over future policy sequences:

Vt*(s) ≐ maxπt, πt+1, … Vtπ(s)
Qt*(s, a) ≐ maxπt+1, πt+2, … Qtπ(s, a)

In words: Vt*(s) is the highest expected return achievable from state s at time t, where the maximisation is over all sequences of decision rules from step t onward. Qt*(s,a) is the highest expected return after taking a specific action a at time t and then acting optimally from t+1 onward. These definitions generalise the stationary optimal values to the time‑dependent case. When the MDP is stationary, it can be shown that the optimal non‑stationary values coincide with the stationary optimal values (i.e., Vt*(s) = V*(s) for all t), but the framework is essential for finite‑horizon problems.

  • Vt*(s)optimal state value at time t, maximised over all policies from time t onward.
  • Qt*(s, a)optimal state‑action value at time t, maximised over policies from time t+1 onward given at=a.
  • Vtπ(s)value under a given non‑stationary policy π (A13.94).
  • Qtπ(s, a)state‑action value under a given non‑stationary policy π (A13.94).
  • πt, πt+1, …sequence of decision rules (policies) at successive time steps.
A13.97

Claim — Time Independence of Optimal Non‑Stationary Value Functions

Claim. In a stationary (time‑homogeneous) MDP, the optimal non‑stationary value functions do not depend on the time index. That is, for any state s, action a, and any two time steps t1, t2:

Vt1*(s) = Vt2*(s),  Qt1*(s, a) = Qt2*(s, a).

Proof. By definition, Vt*(s) = maxπt, πt+1, … Vtπ(s). For a stationary environment, the dynamics p(s′|s,a) and reward r(s,a) are identical for all time steps. Moreover, the set of available future policy sequences {πt, πt+1, …} is the same as the set of sequences starting at any other time index — one can simply shift the time indices without changing the resulting expected return because the initial state is the same. Formally, for any sequence starting at time t, we can define a shifted sequence π̂0 = πt, π̂1 = πt+1, … that yields the same value from the same state. Hence the maximum is independent of t. The argument for Qt* is identical, with the first action fixed. ∎

Because of this invariance, one can drop the time subscript and simply write V*(s) and Q*(s,a) in stationary MDPs, consistent with the earlier definitions (A13.84, A13.89).

  • Vt*(s)optimal state value at time t (A13.96).
  • Qt*(s, a)optimal state‑action value at time t (A13.96).
  • stationary MDPan MDP with time‑independent transition and reward functions (A13.16).
A13.99

Bellman Optimality Criterion

Theorem (Bellman Optimality Criterion). A stationary policy π is optimal if and only if, for every state s and every action a for which π(a|s) > 0, the action maximises the state‑action value function of π itself:

a ∈ arg maxa′ Qπ(s, a′).

Proof (necessity). Assume π is optimal. Then its value functions coincide with the optimal ones: Vπ(s) = V*(s) and Qπ(s, a) = Q*(s, a) for all s, a. From the optimality relation (A13.98, adapted to the stationary case) we have

V*(s) = maxa Q*(s, a).

Hence,

Vπ(s) = V*(s) = maxa Q*(s, a) = maxa Qπ(s, a).

On the other hand, the relationship between V and Q (A13.86) gives

Vπ(s) = 𝔼a ∼ π(·∣s) Qπ(s, a).

Equating the two expressions for Vπ(s) yields

𝔼a ∼ π(·∣s) Qπ(s, a) = maxa Qπ(s, a).

The expectation of a set of real numbers, weighted by the policy distribution, can equal its maximum only if the distribution is supported exclusively on actions that achieve the maximum. Therefore, for any a with π(a|s) > 0, we must have Qπ(s, a) = maxa′ Qπ(s, a′), i.e., a ∈ arg maxa′ Qπ(s, a′). ∎

(Sufficiency can be proved by showing that a policy satisfying this criterion is a fixed point of the Bellman optimality operator, and therefore its value function satisfies Vπ = V*.)

  • πstationary policy (A13.22).
  • Vπ(s)state value function under π (A13.79).
  • Qπ(s, a)state‑action value function under π (A13.85).
  • V*(s)optimal state value function (A13.84).
  • Q*(s, a)optimal state‑action value function (A13.89).
  • arg maxaset of actions that maximise the given function.
A13.100

Claims on the Existence of Optimal Policies

Claim (Finite Action Space). If |A| < +∞, an optimal policy always exists.

Proof. The set A is finite, so arg maxa Q*(s,a) is non‑empty for every s. The deterministic policy π(s) := arg maxa Q*(s,a) is optimal. ∎

Claim (Continuous Action Space — Non‑existence). An optimal policy may not exist.

Counterexample. Consider a trivial MDP with a single state, action space A = [−1, 1], and deterministic immediate reward r(a). After one action the episode terminates (γ = 1). Choose r(a) = a for a < 1 and, say, r(1) = 0 (or any function that does not attain its supremum). Then Q*(s,a) = r(a) has no maximum; the supremum is 1, but no action achieves it. Hence no optimal policy exists. ∎

Claim (Continuum of Optimal Policies). If there exist at least two distinct optimal policies, then there exists a continuum of optimal policies.

Proof. Two distinct optimal policies imply that for some state s the set arg maxa Q*(s,a) contains at least two different actions. Any stochastic policy that mixes arbitrarily among these maximizers (e.g., assigning probability p to one and 1−p to the other) will also achieve the same expected value, because the expectation over maximum-valued actions is the maximum itself. Hence there is an uncountable family of optimal stochastic policies. ∎

Claim (Deterministic Optimal Policy). If at least one optimal policy exists, then there exists a deterministic optimal policy.

Proof. Let π* be an optimal policy. Then Vπ* = V* and Qπ* = Q*. By the Bellman optimality criterion, for any s and any a with π*(a|s) > 0, we have a ∈ arg maxa′ Q*(s,a′). Thus arg maxa′ Q*(s,a′) is non‑empty for every s. Define πdet(s) by picking any action from that set. Then Vπdet(s) = maxa Q*(s,a) = V*(s), so πdet is a deterministic optimal policy. ∎

  • Q*(s,a)optimal state‑action value function (A13.89).
  • V*(s)optimal state value function (A13.84).
  • arg maxaset of actions achieving the maximum.
  • π(s)a (possibly stochastic) policy.
A13.101

Advantage Function

For a given MDP and policy π, the advantage function Aπ(s, a) quantifies how much better (or worse) taking action a in state s is compared to following the policy’s average behaviour from that state:

Aπ(s, a) ≐ Qπ(s, a) − Vπ(s)

A positive advantage indicates an action better than the policy’s average; a negative advantage indicates a worse action. The advantage is central in many policy gradient and actor‑critic algorithms.

  • Aπ(s, a)advantage of action a in state s under policy π.
  • Qπ(s, a)state‑action value function (A13.85).
  • Vπ(s)state value function (A13.79).
  • πstationary policy (A13.22).
A13.102

Claims on the Advantage Function

Claim (Zero Mean). For any stationary policy π and any state s, the expectation of the advantage over actions drawn from the policy is zero:

𝔼a ∼ π(·∣s) Aπ(s, a) = 0.

Proof. By definition, Aπ(s,a) = Qπ(s,a) − Vπ(s). Taking the expectation over a ∼ π(·∣s) gives

𝔼a[Aπ(s,a)] = 𝔼a[Qπ(s,a)] − Vπ(s) = Vπ(s) − Vπ(s) = 0,

where we used the relationship Vπ(s) = 𝔼a∼π(·∣s) Qπ(s,a) (A13.86). ∎

Claim (Maximum is Non‑negative). For any stationary policy π and any state s, the maximum advantage is non‑negative:

maxa Aπ(s, a) ≥ 0.

Proof. From the previous claim, the weighted average of Aπ(s,a) under π is zero. If all actions had strictly negative advantage, the expectation would be negative, a contradiction. Hence there must exist at least one action with Aπ(s,a) ≥ 0, and the maximum over all actions is therefore at least zero. ∎

These simple properties of the advantage function are used to justify why many algorithms can safely discard the baseline (which is analogous to Vπ) without introducing bias in gradient estimates.

  • Aπ(s, a)advantage function for policy π (A13.101).
  • Vπ(s)state value function (A13.79).
  • Qπ(s, a)state‑action value function (A13.85).
  • πstationary policy (A13.22).
  • 𝔼a∼πexpectation over actions drawn from the policy.
A13.103

Relative Performance Identity

Theorem (Relative Performance Identity). For any two policies π1 and π2, and any initial state s, the difference in their value functions can be expressed as an expectation over trajectories generated by π2 of the discounted sum of advantages of π1:

Vπ2(s) − Vπ1(s) = 𝔼T ∼ π2 ∣ s0=s [ ∑t≥0 γt Aπ1(st, at) ].

Proof. Start with the definition of the value of π2 from state s:

Vπ2(s) = 𝔼π2[ ∑t≥0 γt r(st, at) ∣ s0=s ].

The value of π1 from the same state can be written as a telescoping expectation under π2. For any trajectory, the following identity holds (assuming bounded values and γ < 1 or termination):

Vπ1(s) = 𝔼π2[ ∑t≥0 γt ( Vπ1(st) − γ Vπ1(st+1) ) ∣ s0=s ],

because the sum telescopes: t=0 γt Vπ1(st) − ∑t=0 γt+1 Vπ1(st+1) = Vπ1(s0), where the boundary term at infinity vanishes (since γt Vπ1 → 0).

Subtracting the two expressions, we obtain:

Vπ2(s) − Vπ1(s) = 𝔼π2[ ∑t≥0 γt ( r(st, at) + γ Vπ1(st+1) − Vπ1(st) ) ].

By the Markov property, the expectation of the term inside the parentheses conditioned on st and at equals:

𝔼[ r(st, at) + γ Vπ1(st+1) ∣ st, at ] − Vπ1(st) = Qπ1(st, at) − Vπ1(st) = Aπ1(st, at).

Applying the law of total expectation to the whole trajectory then yields the desired identity. ∎

This identity is fundamental in policy improvement guarantees and in the derivation of algorithms such as TRPO and PPO. It shows that improving the policy in the direction of increasing the expected advantage guarantees an increase in the overall value.

  • Vπ(s)state value function under policy π (A13.79).
  • Qπ(s, a)state‑action value function under π (A13.85).
  • Aπ(s, a)advantage function under π (A13.101).
  • γdiscount factor, 0 ≤ γ < 1.
  • 𝔼π2[·]expectation over trajectories generated by policy π2.
  • st, atstate and action at time t along a trajectory.
A13.104

Policy Comparison Relations

We say that a policy π2 is not worse than π1 (written π2 ⪰ π1) if it yields at least as high a value from every state:

∀ s :  Vπ2(s) ≥ Vπ1(s).

If additionally there exists at least one state s where the inequality is strict, we say that π2 is better than π1 (written π2 ≻ π1):

( ∀ s : Vπ2(s) ≥ Vπ1(s) )  and   ( ∃ s : Vπ2(s) > Vπ1(s) ).
  • π2 ⪰ π1π2 dominates or equals π1 from all states.
  • π2 ≻ π1π2 is strictly better than π1 (dominates everywhere and strictly better somewhere).
  • Vπ(s)state value function of policy π (A13.79).
A13.105

Policy Improvement

Theorem (Policy Improvement). Let π1 and π2 be stationary policies such that for every state s,

𝔼a ∼ π2(·∣s) Qπ1(s, a) ≥ Vπ1(s),

or, equivalently, using the advantage function,

𝔼a ∼ π2(·∣s) Aπ1(s, a) ≥ 0.

Then π2 is not worse than π1, i.e. π2 ⪰ π1. If the inequality is strict for at least one state s, then π2 is strictly better than π1, i.e. π2 ≻ π1.

Proof. Using the Relative Performance Identity (A13.103), the difference in values from any initial state s0 is

Vπ2(s0) − Vπ1(s0) = 𝔼T ∼ π2 ∣ s0 [ ∑t≥0 γt Aπ1(st, at) ].

For each time step t, the inner expectation conditioned on st is exactly 𝔼a ∼ π2(·∣st) Aπ1(st, a), which by assumption is ≥ 0 for all states. Consequently, every term in the sum has non‑negative expectation, and the total expected sum is non‑negative. Hence Vπ2(s0) ≥ Vπ1(s0) for every initial state, proving π2 ⪰ π1.

If there exists a state s* where the expected advantage is strictly positive, then from that same state the difference at t=0 alone is positive, and the remaining terms are non‑negative, giving Vπ2(s*) > Vπ1(s*). Thus π2 ≻ π1. ∎

This result is the foundation of policy iteration: greedifying a policy with respect to its own Q‑function yields a policy that is better or equal; if it is equal, the policy is optimal.

  • π1, π2stationary policies (A13.22).
  • Vπ(s)state value function (A13.79).
  • Qπ(s, a)state‑action value function (A13.85).
  • Aπ(s, a)advantage function (A13.101).
  • ⪰, ≻policy comparison relations (A13.104).
  • γdiscount factor, 0 ≤ γ < 1.
  • 𝔼a ∼ π2(·∣s)expectation over actions drawn from π2.
A13.106

Contraction Operator

An operator f mapping a metric space X to itself is called a contraction with contraction coefficient γ < 1 with respect to the metric ρ if for all x1, x2 ∈ X:

ρ( f(x1), f(x2) ) ≤ γ ρ( x1, x2 ).

By Banach’s fixed‑point theorem, every contraction on a complete metric space has a unique fixed point x* satisfying f(x*) = x*, and iterating f from any starting point converges to that fixed point.

  • fcontraction operator, f : X → X.
  • Xmetric space (e.g., the space of bounded real‑valued functions on S).
  • ρmetric (distance) on X.
  • γcontraction coefficient, 0 ≤ γ < 1.
  • x1, x2arbitrary points in X.
  • x*unique fixed point of f (if X is complete).
A13.107

Fixed Point

A point x ∈ X for an operator f : X → X is called a fixed point if it remains unchanged under the action of f:

x = f(x).
  • xa point in the set X.
  • fan operator mapping X to itself.
  • Xthe domain and codomain of the operator f.

In the context of reinforcement learning, fixed points arise naturally when solving Bellman equations: the optimal value function V* is the unique fixed point of the Bellman optimality operator, and similar fixed-point properties hold for policy evaluation operators.

A13.108

Method of Simple Iteration (Point Iteration)

The method of simple iteration (or point iteration) generates a sequence of approximations (xk) by repeatedly applying an operator f starting from an initial guess x0 ∈ X:

xk+1 = f(xk),  k = 0, 1, 2, …

If f is a contraction mapping on a complete metric space, Banach’s fixed‑point theorem guarantees that the sequence converges to the unique fixed point x* satisfying x* = f(x*). In reinforcement learning, such iterative schemes arise in value iteration and policy evaluation.

  • xkthe k‑th iterate (approximation).
  • x0initial approximation (starting point).
  • foperator mapping the space X to itself (often a contraction).
  • Xthe underlying set (typically a complete metric space).
  • x*fixed point (limit of the sequence if f is a contraction).
A13.109

Banach Fixed‑Point Theorem

Theorem (Banach Fixed‑Point Theorem). Let (X, ρ) be a complete metric space and f : X → X a contraction with coefficient γ ∈ [0, 1). Then:

  1. There exists a unique fixed point x* ∈ X, i.e. f(x*) = x*.
  2. For any initial point x0 ∈ X, the sequence defined by the method of simple iteration
    xk+1 = f(xk),  k = 0, 1, 2, …
    converges to x*.

Proof.

Uniqueness. Suppose x* and y* are two fixed points. Then

ρ(x*, y*) = ρ(f(x*), f(y*)) ≤ γ ρ(x*, y*).

Since γ < 1, the inequality can hold only if ρ(x*, y*) = 0, which by the properties of a metric implies x* = y*. Hence the fixed point is unique.

Existence and convergence. Let x0 ∈ X be arbitrary and define xk+1 = f(xk). First, we show that (xk) is a Cauchy sequence. For any m > n ≥ 0, by the triangle inequality and repeated application of the contraction property:

ρ(xm, xn) ≤ Σi=nm−1 ρ(xi+1, xi)   (telescoping and triangle inequality)
≤ Σi=nm−1 γi ρ(x1, x0)   (since ρ(xi+1, xi) ≤ γi ρ(x1, x0) by induction)
≤ γn ρ(x1, x0) Σj=0 γj = γn1 − γ ρ(x1, x0).

As n → ∞, γn → 0, so the right‑hand side becomes arbitrarily small. Thus (xk) is Cauchy. Since X is complete, there exists a limit x* = limk→∞ xk.

Finally, a contraction is Lipschitz (and hence uniformly continuous), so f is continuous. Taking the limit in the recurrence relation:

x* = limk→∞ xk+1 = limk→∞ f(xk) = f( limk→∞ xk ) = f(x*).

Therefore x* is a fixed point. ∎

In RL, Banach’s theorem ensures that value iteration converges to the optimal value function, because the Bellman operator is a contraction in the supremum norm.

  • (X, ρ)complete metric space.
  • fcontraction mapping with coefficient γ ∈ [0,1).
  • x*unique fixed point, f(x*) = x*.
  • xksequence of iterates converging to x*.
  • γcontraction coefficient (0 ≤ γ < 1).
A13.110

Policy Evaluation

Policy evaluation is the process of computing the state value function Vπ for a given stationary policy π. It solves the Bellman expectation equation, typically by iterative application of the Bellman expectation operator:

Vk+1(s) = 𝔼a ∼ π(·∣s) [ r(s, a) + γ 𝔼s′ ∼ p(·∣s,a) Vk(s′) ],  k = 0, 1, 2, …

Starting from an arbitrary initial approximation V0, the sequence Vk converges to the true value function Vπ because the Bellman expectation operator is a contraction in the supremum norm. This procedure is also called iterative policy evaluation.

  • Vπ(s)state value function for the fixed policy π (A13.79).
  • Vk(s)approximation to Vπ(s) at iteration k.
  • π(a∣s)given stationary policy.
  • r(s, a)expected immediate reward.
  • γdiscount factor, 0 ≤ γ < 1.
  • p(s′∣s, a)transition probability.
  • 𝔼a∼π, 𝔼s′∼pexpectations under the policy and environment dynamics.
A13.111

Bellman Operator and Supremum Metric

For a given MDP and stationary policy π, the Bellman expectation operator B maps a value function V : S → ℝ to a new value function B[V] : S → ℝ defined by

B[V](s) ≐ 𝔼a ∼ π(a∣s) [ r(s, a) + γ 𝔼s′ ∼ p(·∣s,a) V(s′) ].

The function space S → ℝ is equipped with the supremum metric (uniform norm distance):

d(V1, V2) ≐ maxs ∈ S | V1(s) − V2(s) |.

With this metric, the space of bounded functions on S is complete, and the operator B is a contraction, which underlies the convergence of iterative policy evaluation and value iteration.

  • B[V]Bellman expectation operator applied to value function V.
  • Va real‑valued function on S (value function).
  • π(a∣s)the given stationary policy.
  • r(s, a)expected immediate reward.
  • γdiscount factor, 0 ≤ γ < 1.
  • p(s′∣s, a)transition probability.
  • d(V1, V2)distance between two value functions V1 and V2 under the supremum norm.
  • maxsmaximum over all states (supremum, finite if S is bounded).
A13.112

Bellman Operator is a Contraction

Claim. If γ < 1, the Bellman expectation operator B (defined in A13.111) is a contraction mapping on the space of bounded real‑valued functions on S with respect to the supremum metric d, and its contraction coefficient is exactly γ.

Proof. Let V1 and V2 be arbitrary bounded functions from S to . For any state s,

| B[V1](s) − B[V2](s) |
= | 𝔼a ∼ π(·∣s) [ γ 𝔼s′ ∼ p(·∣s,a) ( V1(s′) − V2(s′) ) ] |
≤ 𝔼a ∼ π(·∣s) [ γ 𝔼s′ ∼ p(·∣s,a) | V1(s′) − V2(s′) | ]   (Jensen / triangle inequality)
≤ γ 𝔼a ∼ π(·∣s) [ 𝔼s′ ∼ p(·∣s,a) ( maxs″ | V1(s″) − V2(s″) | ) ]
= γ maxs″ | V1(s″) − V2(s″) |
= γ d(V1, V2).

Since this bound holds uniformly for every s, taking the maximum over s on the left‑hand side yields

d( B[V1], B[V2] ) ≤ γ d(V1, V2).

Thus B is a contraction with coefficient γ < 1. ∎

This contraction property guarantees, via the Banach fixed‑point theorem (A13.109), that the sequence Vk+1 = B[Vk] converges to the unique fixed point Vπ, i.e., the true value function of policy π.

  • BBellman expectation operator (A13.111).
  • V1, V2arbitrary bounded value functions.
  • dsupremum metric (A13.111).
  • γdiscount factor, 0 ≤ γ < 1.
  • π(a∣s)given stationary policy.
  • p(s′∣s,a)transition probability.
A13.113

Episodic Convergence of Simple Iteration

Claim. In an episodic environment (A13.26) with maximum episode length Tmax, the method of simple iteration applied to the Bellman expectation equation converges to the unique solution Vπ in at most Tmax steps, even when the discount factor γ = 1.

Reason. In an episodic setting, every trajectory terminates after at most Tmax steps. Consequently, the value function is a sum of at most Tmax rewards, and the Bellman operator becomes a finite‑horizon backup. Starting from any initial guess V0, after Tmax successive applications of the operator, the estimate at each state depends only on the terminal reward (zero) and thus matches the true value exactly. No contraction argument is needed; the iteration simply “unrolls” the finite horizon.

  • Tmaxmaximum number of steps per episode (finite, see A13.26).
  • γdiscount factor; can be 1 in the episodic case.
  • V0arbitrary initial value function.
  • Vπtrue state value function for policy π (A13.79).
A13.114

Algorithm 6: Policy Evaluation

Input: policy π(a ∣ s)

Hyperparameters: ε — stopping criterion

Initialize V0(s) arbitrarily for all s ∈ S

At the k-th step:

  1. For all states s, compute the Bellman backup:
    Vk+1(s) = 𝔼a ∼ π(·∣s) [ r(s, a) + γ 𝔼s′ ∼ p(·∣s,a) Vk(s′) ]
  2. Stopping criterion: if maxs | Vk(s) − Vk+1(s) | < ε, terminate.

Output: Vk(s), an approximation to Vπ(s) (A13.79).

This algorithm iteratively applies the Bellman expectation operator B (A13.111). Because B is a contraction mapping (A13.112), the sequence Vk converges to the true value function Vπ.

A13.115

Value Iteration

Value iteration is a dynamic programming algorithm that computes the optimal state value function V* (A13.84) by iteratively applying the Bellman optimality operator. Unlike policy evaluation, it does not require a fixed policy; instead, it performs a greedification step (max over actions) at each backup:

Vk+1(s) = maxa [ r(s, a) + γ 𝔼s′ ∼ p(·∣s,a) Vk(s′) ].

Starting from an arbitrary initial V0, the sequence Vk converges to V* because the Bellman optimality operator is a contraction (with coefficient γ). Once V* is obtained, an optimal policy is the greedy policy with respect to V*:

π*(s) = arg maxa [ r(s, a) + γ 𝔼s′ V*(s′) ].

Algorithm (Value Iteration):

Initialize V0(s) arbitrarily for all s ∈ S.
Hyperparameters: ε — stopping threshold.

At iteration k:

  1. For each state s, compute:
    Vk+1(s) = maxa [ r(s, a) + γ ∑s′ p(s′ ∣ s, a) Vk(s′) ].
  2. If maxs |Vk+1(s) − Vk(s)| < ε, stop and output the greedy policy derived from Vk+1.

Value iteration implicitly combines one step of policy evaluation with one step of policy improvement, making it efficient for computing optimal value functions in finite MDPs.

  • Vk(s)approximation of optimal value at iteration k.
  • V*(s)optimal state value function (A13.84).
  • r(s, a)expected immediate reward.
  • γdiscount factor, 0 ≤ γ < 1.
  • p(s′ ∣ s, a)transition probability.
  • maxamaximum over actions; the greedification step.
A13.116

Policy Iteration

Policy iteration is a dynamic programming algorithm that alternates between exact policy evaluation and policy improvement. Because each improvement yields a strictly better policy in a finite MDP, the process converges to an optimal policy in a finite number of iterations.

Algorithm 8: Policy Iteration (Exact)

Hyperparameters: ε — stopping criterion for the PolicyEvaluation procedure

Initialize π0(s) arbitrarily for all s ∈ S

At the k-th step:

  1. Policy Evaluation: compute the value function of the current policy (e.g., by iterative policy evaluation until convergence):
    Vπk ← PolicyEvaluation(πk, ε)
  2. Compute Q‑function for the current policy from the obtained V‑function:
    Qπk(s, a) = r(s, a) + γ 𝔼s′ ∼ p(·∣s,a) Vπk(s′)
  3. Policy Improvement: build a new policy that is greedy with respect to this Q‑function:
    πk+1(s) = arg maxa Qπk(s, a)
  4. Stopping criterion: if πk+1 ≡ πk (the policy did not change), terminate. Otherwise, set k ← k+1 and repeat.

Algorithm 9: Generalized Policy Iteration (GPI)

Generalized policy iteration relaxes the requirement of full policy evaluation. Instead, only N steps of iterative policy evaluation are performed before each policy improvement. This covers a spectrum from value iteration (N = 1) to full policy iteration (N → ∞).

Hyperparameters: N — number of policy evaluation steps per outer loop.

Initialize π(s) arbitrarily for all s ∈ S; initialize V(s) arbitrarily for all s ∈ S.

At the k-th step:

  1. Partial Policy Evaluation: repeat N times:
    ∀ s :  V(s) ← 𝔼a ∼ π(·∣s) [ r(s, a) + γ 𝔼s′ ∼ p(·∣s,a) V(s′) ]
  2. Compute Q‑function from the current (partially evaluated) V:
    Q(s, a) ← r(s, a) + γ 𝔼s′ ∼ p(·∣s,a) V(s′)
  3. Policy Improvement: update the policy to be greedy with respect to this Q:
    π(s) ← arg maxa Q(s, a)
  4. Repeat from step 1 until the policy no longer changes (or a stopping criterion on value changes is met).

Policy iteration and its generalized variant form the conceptual backbone of many modern RL algorithms, where the evaluation and improvement steps are implemented using sample‑based methods.

  • πk, πstationary policy.
  • Vπk, V(s)state value function (exact or approximate).
  • Qπk, Q(s,a)state‑action value function (A13.85).
  • r(s, a)expected immediate reward.
  • γdiscount factor, 0 ≤ γ < 1.
  • p(s′ ∣ s, a)transition probability.
  • PolicyEvaluationsubroutine that computes Vπ for a given π (A13.114).
  • εconvergence threshold.
  • Nnumber of evaluation sweeps between policy updates (GPI).
A13.117

Theorem — N‑step Bellman Equation

Theorem. For any stationary policy π, any initial state s0, and any integer N ≥ 1, the value function Vπ satisfies the following N‑step Bellman expectation:

Vπ(s0) = 𝔼T:N ∼ π ∣ s0[ ∑t=0N−1 γt rt + γN Vπ(sN) ],

where T:N = (a0, s1, a1, …, sN) denotes the first N steps of a trajectory generated under π and the environment dynamics.

Proof by induction.

Base case (N = 1). The formula reduces to

Vπ(s0) = 𝔼a0 ∼ π(·∣s0) 𝔼s1 ∼ p(·∣s0,a0) [ r0 + γ Vπ(s1) ],

which is exactly the Bellman expectation equation for Vπ (A13.81). Thus the statement holds for N = 1.

Inductive step. Assume the statement holds for some N ≥ 1. We show it holds for N + 1. Consider the (N+1)-step truncation:

𝔼T:N+1[ ∑t=0N γt rt + γN+1 Vπ(sN+1) ]
= 𝔼T:N[ ∑t=0N−1 γt rt + γN 𝔼aN, sN+1 ∣ sN[ rN + γ Vπ(sN+1) ] ].

By the one‑step Bellman equation (the base case applied to state sN), the inner expectation equals Vπ(sN). Hence the whole expression becomes

𝔼T:N[ ∑t=0N−1 γt rt + γN Vπ(sN) ],

which by the induction hypothesis equals Vπ(s0). Therefore the statement holds for N+1. ∎

This identity interpolates between the one‑step Bellman equation and the full definition of Vπ as the expected discounted sum of rewards, and it underpins N‑step temporal‑difference learning methods.

  • Vπ(s)state value function of policy π (A13.79).
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • rtreward received at time step t.
  • T:Npartial trajectory consisting of the first N steps (actions and states).
  • 𝔼T:N ∼ π ∣ s0expectation over the first N transitions when starting at s0 and following π.
  • π(a∣s)stationary policy (A13.22).
  • p(s′∣s,a)transition probability (A13.15).
A13.118

Tabular Algorithms

Model‑Based (Dynamic Programming):

  • Policy Iteration
  • Value Iteration
  • Generalized Policy Iteration (GPI)

Model‑Free Prediction:

  • Monte‑Carlo Prediction (Every‑Visit / First‑Visit MC)
  • Temporal‑Difference Prediction — TD(0)
  • N‑step TD Prediction
  • TD(λ) (Forward / Backward view)

Model‑Free Control (On‑Policy):

  • Monte‑Carlo Control (e.g., GLIE MC Control)
  • SARSA (On‑Policy TD Control)
  • N‑step SARSA
  • SARSA(λ)

Model‑Free Control (Off‑Policy):

  • Q‑Learning
  • Expected SARSA
  • Double Q‑Learning
A13.119

Monte Carlo Algorithm

Monte Carlo (MC) methods estimate value functions by averaging the returns observed after visiting a state (or state‑action pair) over multiple complete episodes. They are model‑free and require only experience, updating values only at the end of an episode.

For a state s and policy π, the every‑visit Monte Carlo estimate of Vπ(s) is the average of the returns Gt following all visits to s across episodes. The incremental update rule (constant‑α version) is:

V(s) ← V(s) + α [ Gt − V(s) ]

where Gt is the observed return from the first (or every) visit to state s at time t until the end of the episode.

First‑visit MC averages returns only from the first visit to s in each episode, while every‑visit MC uses all visits. Both converge to Vπ as the number of episodes goes to infinity.

  • V(s)estimated state value for state s.
  • Gtreturn (cumulative discounted reward) from time step t until the end of the episode.
  • αstep‑size (learning rate), constant or decreasing.
  • πtarget policy being evaluated.
A13.120

Exponential Smoothing

Exponential smoothing (or exponential moving average) is a recursive technique for estimating a quantity by combining a new observation with the previous estimate, giving exponentially decaying weight to past observations. In reinforcement learning, it is the basis of constant‑α Monte Carlo and TD updates.

For a sequence of targets G1, G2, … and a step‑size α ∈ (0, 1], the smoothed estimate Vk after the k-th target is:

Vk+1 = Vk + α ( Gk+1 − Vk ) = (1 − α) Vk + α Gk+1.

Expanding the recurrence shows that Vk+1 = (1−α)k+1 V0 + α Σi=1k+1 (1−α)k+1−i Gi, an exponentially weighted sum with most weight on recent data. For a stationary target distribution, constant α allows the estimate to track changes; for a fixed target, decreasing α (e.g., αk = 1/k) yields the sample average.

  • Vksmoothed estimate after k observations.
  • Gkk‑th observed target (e.g., return from an episode or TD target).
  • αstep‑size (learning rate), 0 < α ≤ 1.
A13.121

Robbins–Monro Conditions

A sequence of learning rates αk ∈ [0, 1] satisfies the Robbins–Monro conditions if

k≥0 αk = +∞,  ∑k≥0 αk2 < +∞.

The first condition ensures that the estimates can eventually move any distance (sufficient exploration), while the second guarantees that the variance of the updates vanishes, allowing convergence to the true value under mild assumptions. A classical example is αk = 1/k.

  • αklearning rate (step size) at iteration k.
  • k≥0 αk = +∞the series of learning rates diverges, guaranteeing that the process can overcome initial bias.
  • k≥0 αk2 < +∞the squared learning rates sum to a finite value, so the noise in the estimates decreases sufficiently fast.
A13.122

Stochastic Approximation

Stochastic approximation is a family of iterative algorithms for solving equations of the form h(θ) = 0 or finding an extremum of a function when only noisy observations of h(θ) (or its gradient) are available. The classical Robbins–Monro algorithm updates a parameter θk using:

θk+1 = θk + αk ( h(θk) + εk ),

where εk is a zero‑mean noise term, and the learning rates αk satisfy the Robbins–Monro conditions (A13.121). Under mild assumptions the sequence converges to the root of h. In reinforcement learning, many algorithms (e.g., TD‑learning) are instances of stochastic approximation.

  • θkparameter estimate at iteration k.
  • αklearning rate satisfying Robbins–Monro conditions (A13.121).
  • h(θ)target function whose root is sought (e.g., the Bellman error).
  • εknoise in the observation at iteration k (mean zero).
A13.123

Temporal Difference Learning

Temporal Difference (TD) learning is a model‑free prediction method that updates value estimates by bootstrapping from the current value function rather than waiting for a complete episode. The simplest form, TD(0), updates the value of a state s after a transition (s, a, r, s′):

V(s) ← V(s) + α [ r + γ V(s′) − V(s) ],

where r + γ V(s′) is the TD target and δ = r + γ V(s′) − V(s) is the TD error. Unlike Monte Carlo methods, TD updates are online and do not require episode termination. They are instances of stochastic approximation and converge to the true value function under appropriate conditions.

The framework extends to TD(λ), which uses eligibility traces to blend multiple n‑step returns, and to control algorithms such as SARSA and Q‑learning.

  • V(s)current estimate of the value of state s.
  • αstep‑size (learning rate).
  • rimmediate reward received after taking an action.
  • γdiscount factor.
  • V(s′)current estimate of the value of the next state s′.
  • δTD error (temporal difference).
A13.124

Q‑Learning

Q‑Learning is an off‑policy temporal‑difference control algorithm that directly approximates the optimal action‑value function Q*, independent of the policy being followed. It updates Q‑values after each transition (s, a, r, s′) using the maximum Q‑value in the next state:

Q(s, a) ← Q(s, a) + α [ r + γ maxa′ Q(s′, a′) − Q(s, a) ].

This update uses a sample of the Bellman optimality operator. Under appropriate exploration conditions (e.g., ε‑greedy) and Robbins–Monro learning rates, Q(s, a) converges to Q*(s, a) in tabular finite MDPs. The learned policy is implicitly the greedy policy with respect to the final Q‑function.

  • Q(s, a)current estimate of the optimal action‑value for state‑action pair (s, a).
  • αstep‑size (learning rate).
  • rimmediate reward.
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • maxa′ Q(s′, a′)maximum Q‑value in the next state (bootstrapped optimal value).
  • Q*(s, a)true optimal state‑action value function (A13.89).
A13.125

Theorem – Convergence of Q‑learning

Theorem. Suppose the state and action spaces are finite, an initial approximation Q0(s, a) is given, and for the k-th update of a particular pair (s, a) the update rule is

Qk+1(s, a) = Qk(s, a) + αk(s, a) ( r(s, a) + γ maxa′ Qk( s′k(s, a), a′ ) − Qk(s, a) ),

where s′k(s, a) ∼ p(s′ ∣ s, a) is a random next state, and the learning rates αk(s, a) ∈ [0, 1] are random variables that, with probability one, satisfy the Robbins–Monro conditions for every (s, a):

k≥0 αk(s, a) = +∞,  ∑k≥0 αk2(s, a) < +∞.

Then Qk converges to the optimal action‑value function Q* with probability one.

Proof. Define the Bellman optimality operator T acting on any Q‑function by

(TQ)(s, a) = r(s, a) + γ 𝔼s′ ∼ p(·∣s, a) [ maxa′ Q(s′, a′) ].

It is well known (and follows directly from the contraction proof of the Bellman expectation operator, with the addition of a max) that T is a contraction in the supremum norm with factor γ < 1. Its unique fixed point is Q*.

The Q‑learning update can be rewritten as

Qk+1(s, a) = (1 − αk) Qk(s, a) + αk ( T Qk(s, a) + wk ),

where the noise term

wk = r(s, a) + γ maxa′ Qk( s′k(s, a), a′ ) − (TQk)(s, a)

has zero mean conditioned on the history up to step k. This is exactly a stochastic approximation process for finding the fixed point of the contraction T. Under the Robbins–Monro conditions, which guarantee that the cumulative step‑sizes diverge (ensuring persistent updates) while their squares converge (suppressing the noise), and because the noise terms form a martingale difference sequence with bounded variance (the rewards and Q‑values are bounded in the tabular finite MDP), standard convergence results (e.g., Dvoretzky’s theorem, or the ODE method) imply that the iterate Qk converges with probability one to the unique solution of Q = TQ, namely Q*. ∎

  • Qk(s, a)estimate of Q*(s, a) after the k‑th update of that pair.
  • Q*(s, a)optimal state‑action value function (A13.89).
  • αk(s, a)learning rate used when updating (s, a) at its k‑th visit.
  • r(s, a)expected immediate reward (or a sample reward, here taken deterministic for simplicity).
  • γdiscount factor, 0 ≤ γ < 1.
  • s′k(s, a)random next state drawn from p(s′ ∣ s, a) at the k‑th update.
  • p(s′ ∣ s, a)transition probability.
  • TBellman optimality operator (contraction with factor γ).
  • wkzero‑mean noise term at step k.
A13.126

Risk of Pure Greedy Policy

Collecting trajectories exclusively with a greedy strategy (i.e., always selecting a = arg maxa Q(s,a)) may fail to explore the state–action space sufficiently. Without exploration, the agent can become trapped in a local optimum, never discovering actions that yield higher long‑term returns. This is why exploration mechanisms such as ε‑greedy, softmax, or optimism in the face of uncertainty are essential for convergence to the global optimum in reinforcement learning algorithms like Q‑learning.

A13.127

ε‑greedy and Boltzmann Strategies

ε‑greedy strategy. With probability ε a random action is chosen uniformly; otherwise the action with the highest estimated Q‑value is selected:

μ(s) = a ∼ Uniform(A) arg maxa Q(s, a) with probability ε, otherwise.

Boltzmann strategy (softmax). Actions are sampled according to a softmax distribution over their estimated values, scaled by a temperature parameter τ > 0:

μ(a ∣ s) = softmaxa( Q(s, a) / τ ) = exp( Q(s, a) / τ ) Σa′ exp( Q(s, a′) / τ ) .

As τ → 0, the Boltzmann strategy approaches the greedy policy; as τ → ∞, it approaches a uniform random policy.

  • μ(s)exploration policy (deterministic in ε‑greedy, stochastic in Boltzmann).
  • Q(s, a)current estimate of action‑value function.
  • εprobability of choosing a random action, 0 ≤ ε ≤ 1.
  • τtemperature parameter, τ > 0.
  • Uniform(A)uniform distribution over the action space A.
A13.128

Replay Buffer (Experience Replay)

A replay buffer (or experience replay) is a memory storing a collection of transitions (s, a, r, s′, done) that the agent has observed during interaction with the environment.

  • sstate before the transition.
  • aaction taken.
  • rreward received after taking action a in state s.
  • s′next state after the transition.
  • doneboolean flag indicating whether s′ is terminal.
A13.129

Algorithm: Q‑learning with Experience Replay

Hyperparameters: α – exponential smoothing parameter, ε – exploration parameter

Initialize Q(s, a) arbitrarily for all s ∈ S, a ∈ A. Observe initial state s0.

At the k-th step:

  1. With probability ε choose ak ∼ Uniform(A); otherwise ak = arg maxa Q(sk, a).
  2. Execute ak, observe reward rk and next state sk+1.
  3. Store transition (sk, ak, rk, sk+1) in the replay buffer.
  4. Sample a random transition (s, a, r, s′) from the buffer.
  5. Update:
    Q(s, a) ← Q(s, a) + α ( r + γ maxa′ Q(s′, a′) − Q(s, a) ).

This breaks the temporal correlation between consecutive samples and stabilizes training.

  • Q(s, a)action‑value estimate.
  • αlearning rate.
  • εexploration probability.
  • γdiscount factor.
  • Uniform(A)uniform distribution over actions.
  • replay buffermemory of past transitions (A13.128).
A13.130

Q‑learning (Online)

Hyperparameters: α – exponential smoothing parameter, ε – exploration parameter

Initialize Q(s, a) arbitrarily for all s ∈ S, a ∈ A. Observe initial state s0.

At the k-th step:

  1. With probability ε choose ak ∼ Uniform(A); otherwise ak = arg maxa Q(sk, a).
  2. Execute ak, observe reward rk and next state sk+1.
  3. Update the Q‑value for the current state‑action pair:
    Q(sk, ak) ← Q(sk, ak) + α ( rk + γ maxa′ Q(sk+1, a′) − Q(sk, ak) ).

This is the online version of Q‑learning (A13.124), updating after each environment step without a replay buffer.

  • Q(s, a)action‑value estimate.
  • αlearning rate.
  • εexploration probability.
  • γdiscount factor.
  • sk, ak, rkstate, action, reward at step k.
  • maxa′ Q(sk+1, a′)maximum Q‑value in the next state.
A13.131

SARSA

SARSA (State–Action–Reward–State–Action) is an on‑policy temporal‑difference control algorithm. It updates the action‑value function Qπ for the policy currently being followed, using transitions (s, a, r, s′, a′) where the next action a′ is sampled from the same policy. The update rule is:

Q(s, a) ← Q(s, a) + α [ r + γ Q(s′, a′) − Q(s, a) ].

Because the next action a′ is drawn from the behaviour policy (not the greedy maximum), SARSA is on‑policy and learns the value of the policy being executed, including any exploration noise. Under appropriate conditions (e.g., GLIE policies and Robbins–Monro rates), SARSA converges to the optimal Q‑function Q*.

  • Q(s, a)current estimate of the action‑value function for state s and action a.
  • αlearning rate (step‑size).
  • rimmediate reward after taking action a in state s.
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • s′next state reached.
  • a′next action chosen from the same policy (on‑policy).
A13.132

ε‑soft Policy

A policy π is called ε‑soft if it assigns a non‑negligible probability to every action in every state. Formally, for all states s and actions a,

π(a ∣ s) ≥ ε|A|,

where ε ∈ [0, 1] controls the minimum exploration level and |A| is the number of available actions. The ε‑greedy policy (A13.127) is an example of an ε‑soft policy.

  • π(a ∣ s)probability of selecting action a in state s under policy π.
  • εminimum exploration parameter; 0 ≤ ε ≤ 1.
  • |A|cardinality of the action space (number of actions).
A13.133

Optimal ε‑soft Value Functions

For a given MDP, the optimal ε‑soft value functions are defined as the maximum achievable expected return under the constraint that the policy belongs to the class of ε‑soft policies (A13.132):

Vε‑soft*(s) ≐ maxπ ∈ ε‑soft Vπ(s),
Qε‑soft*(s, a) ≐ maxπ ∈ ε‑soft Qπ(s, a).
  • Vε‑soft*(s)optimal state value within the class of ε‑soft policies.
  • Qε‑soft*(s, a)optimal action‑value within the class of ε‑soft policies.
  • ε‑softthe set of policies satisfying π(a|s) ≥ ε/|A| for all s, a (A13.132).
  • Vπ(s)state value function of policy π (A13.79).
  • Qπ(s, a)state‑action value function of policy π (A13.85).
A13.134

Algorithm : Expected‑SARSA

Hyperparameters: α – exponential smoothing parameter, ε – exploration parameter

Initialize Q(s, a) arbitrarily for all s ∈ S, a ∈ A. Initialize an ε‑greedy policy π0 derived from Q (or arbitrarily). Observe initial state s0.

At the k-th step:

  1. Choose action ak ∼ πk(· ∣ sk).
  2. Execute ak, observe reward rk and next state sk+1.
  3. Define the next policy πk+1 as the ε‑greedy policy with respect to the current Q‑function:
    πk+1(a ∣ sk+1) = ε / |A| (1 − ε) + ε / |A| for non‑greedy actions, for the greedy action.
  4. Update the Q‑value for the current pair using the expectation under the new policy:
    Q(sk, ak) ← Q(sk, ak) + α ( rk + γ 𝔼a′ ∼ πk+1(·∣sk+1) Q(sk+1, a′) − Q(sk, ak) ).

Expected SARSA replaces the max operation of Q‑learning with an expectation over the next action, eliminating the overestimation bias of Q‑learning while remaining off‑policy. Under standard conditions it converges to the optimal ε‑soft value function.

  • Q(s, a)action‑value estimate for state s and action a.
  • αlearning rate (step‑size).
  • εexploration parameter; policy is ε‑greedy.
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • πkε‑greedy policy at step k derived from current Q.
  • 𝔼a′ ∼ πk+1[·]expectation over the next action following the ε‑greedy policy.
  • |A|number of actions in the finite action space.
A13.135

Bias–Variance Dilemma

The bias–variance dilemma (or trade‑off) is a fundamental problem in function approximation and learning that arises from the decomposition of expected error. For an estimator θ̂ of a true value θ, the mean squared error can be expressed as

𝔼[(θ̂ − θ)2] = (𝔼[θ̂] − θ)2 + 𝔼[(θ̂ − 𝔼[θ̂])2] + σ2,

where the three terms are the squared bias, the variance, and irreducible noise. In reinforcement learning, the dilemma manifests when choosing between Monte Carlo (high variance, zero bias) and temporal‑difference (low variance, some bias) estimates, or when selecting the bootstrapping depth in n‑step methods.

  • θtrue value to be estimated (e.g., Vπ(s) or Qπ(s,a)).
  • θ̂estimator (e.g., Monte Carlo return, TD target).
  • Bias(θ̂) = 𝔼[θ̂] − θexpected difference from the true value.
  • Var(θ̂) = 𝔼[(θ̂ − 𝔼[θ̂])2]variability of the estimator across training sets.
  • σ2irreducible noise variance inherent in the data.
A13.136

Rollout and N‑Step Estimation Target

A fragment of a trajectory

s, a, r, s′, a′, r′, s′′, a′′, r′′, …, s(N), a(N),

where s(N) and a(N) are the state and action encountered after N steps, is called a rollout of length N.

The N‑step estimation target for Qπ(s, a) is defined as

yQ ≐ r + γ r′ + γ2 r′′ + ⋯ + γN−1 r(N−1) + γN Q( s(N), a(N) ),

where Q is an estimate (or the true) action‑value function. This target interpolates between the one‑step TD target (N = 1) and the full Monte Carlo return (N → ∞).

  • s, a, rinitial state, action, and reward of the rollout.
  • s′, a′, r′state, action, reward after one transition.
  • s(N), a(N)state and action after N steps.
  • Nrollout length (number of steps before bootstrapping).
  • yQN‑step estimation target for the Q‑function.
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • Q(·, ·)current approximation of the action‑value function.
A13.137

N‑Step Temporal Difference Error

For a state s and a rollout of length N obtained by following policy π, the N‑step temporal difference error is defined as

Ψ(N)(s) ≐ ∑t=0N−1 γt r(t) + γN V(s(N)) − V(s),

where r(t) is the reward received t steps after leaving state s, s(N) is the state encountered N steps later, and V is the current approximate value function. This error drives the N‑step TD update for state‑value prediction.

  • Ψ(N)(s)N‑step TD error for state s.
  • Nnumber of steps before bootstrapping (rollout length).
  • γdiscount factor.
  • r(t)reward at step t after the start of the rollout.
  • s(N)state reached after N steps.
  • V(s)current estimate of the value of state s.
  • V(s(N))bootstrapped value at the end of the rollout.
A13.138

Theorem — N‑Step TD Error Telescoping Identity

Theorem 31. For a rollout (s, a, r, s′, a′, r′, …, s(N), a(N)) generated by a policy π, the N‑step temporal difference error (for the Q‑function) telescopes into a sum of discounted one‑step errors:

Ψ(N)(s, a) = ∑t=0N−1 γt Ψ(1)(s(t), a(t)),

where s(0) = s, a(0) = a, and the one‑step TD error at step t is defined as

Ψ(1)(s(t), a(t)) ≐ rt + γ Q(s(t+1), a(t+1)) − Q(s(t), a(t)).

Proof. The N‑step TD error is by definition

Ψ(N)(s, a) = ( r0 + γ r1 + ⋯ + γN−1 rN−1 + γN Q(s(N), a(N)) ) − Q(s, a).

Now substitute each reward rt from the one‑step error: rt = Ψ(1)(s(t), a(t)) − γ Q(s(t+1), a(t+1)) + Q(s(t), a(t)). Then

Ψ(N)(s, a) = ∑t=0N−1 γt [ Ψ(1)(s(t), a(t)) − γ Q(s(t+1), a(t+1)) + Q(s(t), a(t)) ]
            + γN Q(s(N), a(N)) − Q(s(0), a(0)).

Expand the sum: the terms Q(s(t), a(t)) and −γ Q(s(t+1), a(t+1)) cancel telescopically. Specifically, for t = 0, we obtain +Q(s(0), a(0)); for each t = 0,…, N−2, the term −γ Q(s(t+1), a(t+1)) from step t cancels with the +Q(s(t+1), a(t+1)) from step t+1 multiplied by γt+1? Wait, careful: The term Q(s(t+1), a(t+1)) appears in the sum for t+1 as γt+1 Q(...), while the term −γ Q(...) from step t is multiplied by γt, giving −γt+1 Q(...). They cancel exactly. The only remaining Q terms are −Q(s(0), a(0)) from the last explicit subtraction outside the sum? Let's do the algebra carefully:

Sum of Q‑terms from the reward substitution:

t=0N−1 γt Q(s(t), a(t)) − ∑t=0N−1 γt+1 Q(s(t+1), a(t+1))
= Q(s(0), a(0)) + ∑t=1N−1 γt Q(s(t), a(t)) − ∑t=1N γt Q(s(t), a(t))
= Q(s(0), a(0)) − γN Q(s(N), a(N)).

Adding the remaining terms γN Q(s(N), a(N)) − Q(s(0), a(0)) from the original expression, everything cancels, leaving exactly t=0N−1 γt Ψ(1)(s(t), a(t)). ∎

This identity shows that the N‑step error is a discounted sum of the familiar one‑step TD errors encountered along the trajectory. It is used, for instance, to derive the forward view of TD(λ).

  • Ψ(N)(s, a)N‑step TD error for the Q‑function.
  • Ψ(1)(s, a)one‑step TD error, r + γ Q(s′, a′) − Q(s, a).
  • γdiscount factor.
  • s(t), a(t)state and action at step t of the rollout (t = 0 is the starting pair).
  • rtreward received at step t.
A13.139

Eligibility Trace

An eligibility trace is a memory variable associated with each state (or state‑action pair) that records how recently and how frequently it has been visited. It bridges the gap between temporal‑difference (TD) and Monte Carlo (MC) methods by allowing online TD learning while still assigning credit to past states.

For a state s, the accumulating trace is updated on each visit as

et(s) = γ λ et−1(s) + 1 γ λ et−1(s) if s = st, otherwise,

where γ is the discount factor and λ ∈ [0, 1] is the trace‑decay parameter. The replacing trace sets et(s) = 1 when s is visited instead of adding one. The trace is then used to update the value estimate proportionally to the current TD error δt:

V(s) ← V(s) + α δt et(s),  ∀s ∈ S.

This yields the backward view of the TD(λ) algorithm. Setting λ = 0 reduces to TD(0); setting λ = 1 approximates Monte Carlo.

  • et(s)eligibility trace of state s at time t.
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • λtrace‑decay parameter, 0 ≤ λ ≤ 1.
  • δtTD error at time t: δt = rt+1 + γ V(st+1) − V(st).
  • αstep‑size (learning rate).
A13.140

Equivalent Forms of the TD(λ) Error

Claim. For a rollout starting at s, a, the TD(λ) error Ψ(s,a) can be expressed equivalently as a λ-discounted sum of one‑step TD errors or as a weighted sum of N-step TD errors:

Ψ(s, a)  ≐  ∑t≥0 (γλ)t Ψ(1)(s(t), a(t))
 =  (1 − λ) ∑N=1 λN−1 Ψ(N)(s, a).

Proof. Start from the right‑hand side, the weighted sum of N-step errors. Substitute each N-step error by its telescoping representation (Theorem 31, A13.138):

Ψ(N)(s, a) = ∑t=0N−1 γt Ψ(1)(s(t), a(t)).

Then

(1 − λ) ∑N=1 λN−1 Ψ(N)(s, a)
= (1 − λ) ∑N=1 λN−1t=0N−1 γt Ψ(1)(s(t), a(t))
= ∑t=0 γt Ψ(1)(s(t), a(t)) (1 − λ) ∑N=t+1 λN−1.

The inner sum is a geometric series:

(1 − λ) ∑N=t+1 λN−1 = (1 − λ) λtm=0 λm = (1 − λ) λt · 1/(1 − λ) = λt.

Thus the expression reduces to t≥0 (γλ)t Ψ(1)(s(t), a(t)), which proves the identity. ∎

This equivalence is fundamental to understanding TD(λ) as a continuous interpolation between one‑step TD (λ = 0) and Monte Carlo (λ = 1).

  • Ψ(s, a)TD(λ) error for the pair s, a (the target minus the current estimate).
  • Ψ(1)(s(t), a(t))one‑step TD error at the t-th step of the rollout.
  • Ψ(N)(s, a)N-step TD error (A13.137, A13.138).
  • γdiscount factor.
  • λtrace‑decay parameter, 0 ≤ λ ≤ 1.
  • s(t), a(t)state and action at step t after the start (t=0 is s, a).
A13.141

Algorithm : TD(λ)

Input: policy π
Hyperparameters: α – exponential smoothing parameter (learning rate), λ ∈ [0, 1] – trace decay degree

Initialize V(s) arbitrarily for all s ∈ S; set eligibility trace e(s) = 0 for all s ∈ S. Observe initial state s0.

At the k-th step:

  1. Select action ak ∼ π(· ∣ sk).
  2. Execute ak, observe reward rk and next state sk+1.
  3. Increment the accumulating trace for the current state:
    e(sk) ← e(sk) + 1.
  4. Compute the one‑step TD error:
    δk = rk + γ V(sk+1) − V(sk).
  5. For every state s ∈ S, update the value estimate proportionally to the eligibility trace and the current TD error:
    V(s) ← V(s) + α δk e(s).
  6. Decay all eligibility traces by γ λ:
    ∀ s ∈ S:  e(s) ← γ λ e(s).

Output: V(s) — an approximation of the state value function Vπ(s) (A13.79).

This is the backward view of TD(λ) with accumulating traces. The trace decay λ controls the bias‑variance trade‑off: λ = 0 gives TD(0) (one‑step bootstrap), λ = 1 approximates Monte Carlo (complete return). The forward view equivalence is given in A13.140.

  • V(s)current estimate of the value of state s.
  • e(s)eligibility trace for state s (A13.139).
  • αstep‑size (learning rate).
  • λtrace‑decay parameter, 0 ≤ λ ≤ 1.
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • δkone‑step TD error at step k.
  • πstationary policy being evaluated.
A13.142

Retrace(λ)

Retrace(λ) is an off‑policy value‑based algorithm that uses eligibility traces with a clipped importance‑sampling ratio to safely learn from trajectories generated by a behaviour policy μ while evaluating or improving a target policy π. It corrects the distribution mismatch without suffering from the high variance of naive importance sampling.

The Retrace operator for a Q‑function is defined by the following error (or target) for a transition sequence starting at (s, a):

ΨRetrace(s, a) ≐ ∑t≥0 γt (∏i=1t ci) δt,

where the one‑step error δt is computed with respect to the target policy π (or the current estimate):

δt = rt + γ 𝔼a′ ∼ π(·∣st+1) Q(st+1, a′) − Q(st, at),

and the trace‑cut coefficients ci are defined as

ci = λ min( 1, ρi ),

with the single‑step importance ratio ρi = π(ai | si) / μ(ai | si) and c0 = 1. The update applied to the current Q‑function uses this error as a target: Q(s,a) ← Q(s,a) + α ΨRetrace(s,a).

By clipping the product of importance ratios, Retrace(λ) reduces variance and guarantees convergence even when μ is far from π. In the on‑policy case (μ = π), it reduces to standard TD(λ).

  • ΨRetrace(s,a)the Retrace error (or target) for state‑action pair (s,a).
  • μbehaviour policy used to generate the trajectory.
  • πtarget policy being learned.
  • Q(s,a)current estimate of the action‑value function.
  • δttemporal difference error at step t under the target policy.
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • λtrace‑decay parameter, 0 ≤ λ ≤ 1.
  • ρiimportance sampling ratio π(ai|si) / μ(ai|si).
  • ciclipped and decayed ratio controlling the trace length; c0 = 1.
  • αstep‑size (learning rate).
A13.143

Retrace(λ) – Formal Update Rule

Update rule. Suppose the state and action spaces are finite and an initial table Q0(s, a) is given. At the k-th update for pair (s, a), the entry is modified according to the off‑policy Retrace(λ) target:

Qk+1(s, a)  =  Qk(s, a) + αk(s, a) ∑t≥0 γt ( ∏i=1t ci ) δt,

where the one‑step TD error δt is evaluated under the current target policy πk (which may be greedy w.r.t. Qk):

δt  =  rt + γ 𝔼a′ ∼ πk(·∣st+1) Qk(st+1, a′) − Qk(st, at),

and the coefficients ci (with c0 = 1) are defined by the clipped importance ratio:

ci  =  λ min( 1, ρi ),   ρi = πk(ai ∣ si)μ(ai ∣ si).

Here μ is the behaviour policy that generated the trajectory, λ ∈ [0, 1] is the trace‑decay parameter, γ the discount factor, and αk(s, a) are learning rates that satisfy the Robbins–Monro conditions (A13.121). Under these conditions and the boundedness of rewards, Qk converges to the optimal action‑value function Q* with probability one.

  • Qk(s, a)approximation of Q*(s, a) after the k-th update of that pair.
  • αk(s, a)learning rate for (s, a) at its k-th visit.
  • γdiscount factor, 0 ≤ γ < 1.
  • λtrace‑decay parameter, 0 ≤ λ ≤ 1.
  • δtTD error at time step t of the rollout (computed under target policy πk).
  • πktarget policy, typically greedy w.r.t. Qk.
  • μbehaviour policy used to generate the trajectory (off‑policy).
  • ρiimportance sampling ratio πk(ai∣si) / μ(ai∣si).
  • ciclipped and decayed coefficient: c0 = 1, ci = λ min(1, ρi) for i≥1.
  • st, at, rtstate, action, and reward at step t of the trajectory starting from (s,a).
A13.144

Deep Q‑Learning

Deep Q‑Learning (DQN) extends tabular Q‑learning to high‑dimensional state spaces by representing the action‑value function with a deep neural network Q(s, a; θ) with weights θ. It is an off‑policy, model‑free algorithm that uses two key stabilisation techniques: experience replay and a target network.

The network is trained by minimising the mean‑squared Bellman error over mini‑batches sampled from a replay buffer D (A13.128). The loss function for a mini‑batch B is

L(θ) = 𝔼(s,a,r,s′) ∼ B[ ( r + γ maxa′ Q(s′, a′; θ) − Q(s, a; θ) )2 ],

where θ denotes the parameters of a separate target network that are periodically copied from θ (or updated via Polyak averaging) to keep the target relatively stationary during optimization. The agent acts according to an ε‑greedy policy derived from the current online network Q(s, a; θ).

Algorithm sketch:

  1. Initialise online network Q(·,·; θ) and target network Q(·,·; θ) with θ = θ.
  2. For each step, select action using ε‑greedy from Q(s,·; θ), store transition in D.
  3. Sample a random mini‑batch from D.
  4. Update θ by gradient descent on L(θ).
  5. Every C steps, update the target network: θ ← θ.

DQN approximates the optimal Q‑function Q* (A13.89) under the same convergence assumptions as Q‑learning, with the additional approximations inherent in neural network function approximation. Variants include Double DQN, Dueling DQN, and Rainbow.

  • Q(s, a; θ)online action‑value network parameterised by θ.
  • Q(s, a; θ)target network with frozen (or slowly moving) parameters θ.
  • θweights of the online network (updated every step).
  • θweights of the target network (updated periodically).
  • Dreplay buffer storing past transitions (A13.128).
  • γdiscount factor.
  • εexploration probability for the behaviour policy.
  • Ctarget network update frequency (in number of steps).
A13.146

Theorem – Fitted Q‑Iteration under Ideal Conditions

Theorem 34. Assume the parametric Q‑function Qθ(s, a) has sufficient capacity (can represent any function), the training dataset { (s, a, r, s′) } is infinitely large and covers the whole state‑action space, and the regression problem

θk+1 = arg minθ 𝔼(s,a,r,s′)[ ( r + γ maxa′ Qθk(s′, a′) − Qθ(s, a) )2 ]

is solved perfectly (global minimum). Then the resulting function satisfies, for every s, a,

Qθk+1(s, a) = r(s, a) + γ 𝔼s′ ∼ p(·∣s,a) maxa′ Qθk(s′, a′).

In words: one fitting step exactly applies the Bellman optimality operator to the previous Q‑function.

Proof. For each pair (s, a), the squared loss inside the expectation is a mean squared error. The minimiser of the conditional expectation of a squared loss is the conditional expectation of the target. That is,

Qθk+1(s, a) = 𝔼[ r + γ maxa′ Qθk(s′, a′) ∣ s, a ].

Because r = r(s, a) is deterministic given the state and action (or its expectation is r(s,a)), and the next state s′ is drawn from the stationary transition kernel p(·∣s, a), the right‑hand side simplifies to r(s, a) + γ 𝔼s′∼p maxa′ Qθk(s′, a′). This is precisely one application of the Bellman optimality operator. ∎

Thus, under idealised conditions, fitted Q‑iteration reproduces exact value iteration, forming the conceptual basis for algorithms like Neural Fitted Q‑Iteration (NFQ) and Deep Q‑Networks (DQN) when combined with finite‑sample and function‑approximation techniques.

  • Qθ(s, a)parametric action‑value function with parameters θ.
  • θkparameter vector after the k-th fitting step.
  • r(s, a)expected immediate reward for state‑action pair (s, a).
  • γdiscount factor, 0 ≤ γ < 1.
  • p(s′ ∣ s, a)transition probability from s to s′ given a.
  • maxa′ Qθk(s′, a′)maximistic value of the next state under the current estimate.
  • 𝔼[· ∣ s, a]conditional expectation given the current state and action.
A13.147

Sample Decorrelation

Sample decorrelation refers to the requirement that the training examples used to update a function approximator (e.g., a neural network) are not strongly correlated. In reinforcement learning, consecutive transitions (st, at, rt, st+1) are highly correlated, which can destabilise gradient‑based optimisation. Breaking this correlation is a key motivation for techniques such as experience replay (A13.128), where mini‑batches are randomly sampled from a large buffer of past transitions.

A13.148

Target Network

A target network is a separate copy of the action‑value function approximator (e.g., a neural network) whose parameters are kept relatively fixed during training to stabilise the learning of the online network. It is used to compute the TD target in value‑based deep RL algorithms such as DQN.

y = r + γ maxa′ Q(s′, a′; θ),

where θ are the parameters of the target network. The target parameters are periodically updated to match the online parameters θ (hard update) or slowly blended (soft update: θ ← τ θ + (1 − τ) θ). This decouples the target from the rapid changes of the online network and reduces the risk of divergence due to non‑stationary target values.

  • θparameters of the online (current) Q‑network.
  • θparameters of the target network.
  • yTD target used to compute the loss for the online network.
  • γdiscount factor.
  • τinterpolation factor for soft updates (0 < τ ≪ 1).
A13.149

Overestimation Bias

Overestimation bias is a systematic error in Q‑learning and DQN where the maximum over estimated action values tends to overstate the true maximum. Formally, for a set of noisy estimates of the true values Q(s′, a′),

𝔼[ maxa′ Qθ(s′, a′) ] ≥ maxa′ 𝔼[ Qθ(s′, a′) ].

This inequality becomes strict whenever there is any uncertainty in the estimates. In DQN, the max operator in the TD target r + γ maxa′ Q(s′, a′; θ) therefore produces overoptimistic values, which can accumulate and degrade policy performance. Double DQN addresses this by decoupling action selection from evaluation: the online network selects the action, while the target network evaluates it.

  • Qθ(s, a)action‑value estimate parameterised by θ.
  • maxa′maximum over actions; the source of overestimation.
  • θtarget network parameters (in DQN).
  • Double DQNvariant that uses online network for action selection, target network for value estimation.
A13.150

Twin DQN

Twin DQN (or Clipped Double Q‑learning for discrete actions) extends DQN by maintaining two independent Q‑networks, Qθ1 and Qθ2. To reduce overestimation bias, the TD target uses the minimum of the two networks' estimates:

y = r + γ mini=1,2 Qθi( s′, arg maxa′ Qθ1(s′, a′) ).

The online networks are updated by regressing onto this target. The action is typically selected by the first network, and the two target networks θi are updated periodically (or via Polyak averaging). This technique provides a more conservative estimate and stabilises learning, forming the basis of algorithms like TD3 for continuous control and its discrete counterparts.

  • Qθ1, Qθ2two online Q‑networks with independent parameters.
  • θitarget network parameters for the i‑th Q‑network.
  • yTD target using the minimum over the two target networks.
  • γdiscount factor.
  • mini=1,2operator that picks the smaller Q‑value to prevent overestimation.
A13.151

Double DQN

Double DQN is a variant of Deep Q‑Learning (A13.144) that reduces the overestimation bias of the max operator by decoupling action selection from action evaluation. It uses the online network to select the action, and the target network to evaluate that action:

y = r + γ Q(s′, arg maxa′ Q(s′, a′; θ); θ).

Here θ are the parameters of the online network and θ those of the target network. This simple modification yields more accurate value estimates and often better performance.

  • Q(·, ·; θ)online action‑value network (policy for action selection).
  • Q(·, ·; θ)target network (evaluates the selected action).
  • yTD target used for training the online network.
  • γdiscount factor.
  • arg maxa′ Q(s′, a′; θ)greedy action selected by the online network.
A13.152

Dueling DQN

Dueling DQN is a neural network architecture for value‑based deep RL that decomposes the Q‑function into two separate streams: a state value V(s) and an advantage A(s, a), which are then combined to avoid identifiability issues:

Q(s, a) = V(s) + A(s, a) − (1/|A|) ∑a′ A(s, a′).

This separation allows the agent to learn which states are valuable without requiring every action to be evaluated separately, often leading to more efficient learning and improved policy evaluation.

  • V(s)state value stream (scalar per state).
  • A(s, a)advantage stream (vector over actions).
  • Q(s, a)combined action‑value estimate.
  • |A|number of discrete actions (for mean subtraction).
A13.153

Noisy Nets

Noisy Nets are a method for exploration in deep reinforcement learning that adds parametric noise directly to the weights of the neural network, replacing the traditional ε‑greedy heuristic. The parameters of the noise distribution are learned alongside the value‑function parameters via gradient descent.

For a fully‑connected layer, a noisy linear transformation replaces the standard y = W x + b with

y = (μW + σW ⊙ εW) x + (μb + σb ⊙ εb),

where μW, σW and μb, σb are the learnable mean and standard deviation parameters, εW, εb are zero‑mean random variables with fixed statistics (typically Gaussian or factorised Gaussian), and denotes element‑wise multiplication. At the end of training, the noise can be removed by setting σ = 0, yielding a deterministic policy.

  • μW, μblearnable mean parameters of the weight and bias noise distributions.
  • σW, σblearnable standard deviation parameters.
  • εW, εbrandom noise variables (e.g., factorised Gaussian samples).
  • element‑wise (Hadamard) product.
A13.154

Prioritized Replay

Prioritized experience replay improves upon uniform sampling from the replay buffer by assigning higher selection probability to transitions with larger temporal‑difference (TD) error, so that the agent more frequently replays experiences from which it can learn the most.

The sampling probability of transition i is proportional to a priority pi, typically based on the TD error magnitude:

P(i) = piαk pkα,  pi = |δi| + ε,

where δi is the TD error of the transition, ε is a small positive constant ensuring non‑zero probability, and α controls the amount of prioritization (α = 0 recovers uniform sampling).

Prioritized sampling introduces bias; to correct it, importance‑sampling weights wi are multiplied with the update:

wi = ( 1N · P(i) )β,

where N is the buffer size and β anneals from an initial value (e.g., 0.4) to 1 towards the end of training, fully compensating the bias when β = 1.

  • δitemporal‑difference error of transition i (e.g., r + γ max Q(s′,a′) − Q(s,a)).
  • pipriority of transition i; typically |δi| + ε.
  • εsmall positive constant to avoid zero priority.
  • αexponent determining the strength of prioritization, 0 ≤ α ≤ 1.
  • P(i)sampling probability of transition i.
  • wiimportance‑sampling weight for transition i to correct the bias.
  • βexponent controlling the degree of bias correction, annealed towards 1.
  • Ncapacity of the replay buffer.
A13.155

Multi‑step DQN

Multi‑step DQN extends standard DQN (which uses one‑step TD targets) by replacing the target with an n‑step return that accumulates rewards over several steps before bootstrapping. This provides a bias‑variance trade‑off: larger n reduces bias at the cost of increased variance.

For a sequence of n transitions (st, at, rt, …, st+n), the n‑step target is

yt(n) = ∑k=0n−1 γk rt+k + γn maxa′ Q(st+n, a′; θ).

The online network Q(·, ·; θ) is trained to minimize the mean‑squared error between Q(st, at; θ) and this target, using mini‑batches from a replay buffer. All other DQN components (experience replay, target network, ε‑greedy exploration) remain unchanged.

  • nnumber of steps before bootstrapping (rollout length).
  • yt(n)n‑step TD target for the transition at time t.
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • rt+kreward received k steps after time t.
  • Q(s, a; θ)online action‑value network (parameters θ).
  • Q(s, a; θ)target network (parameters θ).
A13.156

Distributional RL

Distributional reinforcement learning models the full probability distribution of the random return Zπ(s, a) instead of only its expectation Qπ(s, a). This provides richer learning signals, can improve robustness, and often yields state‑of‑the‑art performance.

The return distribution satisfies a distributional Bellman equation:

Zπ(s, a)  =  r(s, a) + γ Zπ(S′, A′),  S′ ∼ p(·∣s,a), A′ ∼ π(·∣S′),

where equality is in distribution. In practice, the distribution is approximated with a categorical (C51) or quantile (QR‑DQN) representation, and the loss is a statistical distance (e.g., KL divergence or quantile regression loss) between the predicted distribution and the distributional Bellman target.

  • Zπ(s, a)random return (cumulative discounted reward) starting from state s and action a, following policy π.
  • r(s, a)immediate reward (may be random).
  • γdiscount factor, 0 ≤ γ < 1.
  • S′, A′random next state and action, drawn from the dynamics and policy.
  • C51categorical distributional algorithm with 51 atoms.
  • QR‑DQNquantile regression DQN, approximating quantiles of the return distribution.
A13.157

Z‑function (Distributional State‑Action Value)

For a given MDP, the distributional state‑action value function for a policy π is the random variable Zπ(s, a) whose distribution equals the distribution of the return (reward‑to‑go) when starting from state s and action a, then following π:

Zπ(s, a)  ≐  R(T),  T ∼ π ∣ s0 = s, a0 = a,

where R(T) is the random cumulative discounted reward along trajectory T. Equivalently, the cumulative distribution function (c.d.f.) of Zπ(s, a) coincides with the c.d.f. of the return under the specified conditioning. The ordinary Q‑function is the expectation of Z: Qπ(s, a) = 𝔼[ Zπ(s, a) ].

  • Zπ(s, a)random variable representing the return (discounted sum of rewards) from (s, a) under policy π.
  • R(T)return of trajectory T: Σt≥0 γt rt.
  • T ∼ π ∣ s0=s, a0=atrajectory distribution induced by policy π with initial state s and initial action a.
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • c.d.f.cumulative distribution function; the distribution of Z is fully characterised by it.
A13.158

Distributional Bellman Equation

For a policy π, the random return Zπ(s, a) satisfies the following equality in distribution:

Zπ(s, a)  =c.d.f.  r(s, a) + γ Zπ(s′, a′),
s′ ∼ p(s′ ∣ s, a),  a′ ∼ π(a′ ∣ s′).

Proof. For any trajectory T starting at (s, a), the return decomposes into the immediate reward and the discounted future return:

R(T) = r(s, a) + γ R(T1:),

where T1: is the trajectory from step 1 onward. By the Markov property and time‑homogeneity, the distribution of R(T1:) given s′, a′ is exactly the distribution of Zπ(s′, a′). Therefore, the c.d.f. of Zπ(s, a) coincides with the c.d.f. of r(s, a) + γ Zπ(s′, a′) when s′ and a′ are drawn as indicated. ∎

  • Zπ(s, a)distributional state‑action value (A13.157).
  • r(s, a)immediate reward (deterministic in expectation; may be random).
  • γdiscount factor, 0 ≤ γ < 1.
  • s′ ∼ p(·∣s,a)next state drawn from the transition kernel.
  • a′ ∼ π(·∣s′)next action drawn from the policy.
  • R(T1:)return from step 1 onward.
  • c.d.f.cumulative distribution function; equality in distribution.
A13.159

Distributional Value Iteration

In analogy with the classical optimal value function Q*, one defines the optimal distributional state‑action value function Z*(s, a) as the distribution of the return under an optimal policy π*:

Z*(s, a)  ≐  Zπ*(s, a),  (4.15)

where the equality is in the sense of cumulative distribution functions (i.e., the random variables have the same distribution). The deterministic optimal policy π* is any policy that achieves the maximum expected return from every state‑action pair.

Under the optimal policy, the distributional Bellman equation becomes a distributional Bellman optimality equation:

Z*(s, a)  =c.d.f.  r(s, a) + γ Z*( s′, arg maxa′ 𝔼[ Z*(s′, a′) ] ),
s′ ∼ p(s′ ∣ s, a).

This equation forms the basis of distributional value iteration, where the distribution of Z* is iteratively updated using a contraction operator analogous to the classical Bellman operator, but acting on probability distributions.

  • Z*(s, a)optimal distributional state‑action value – the random return under an optimal policy starting from (s, a).
  • Zπ*(s, a)distributional value of (s, a) under a particular optimal policy π*.
  • π*an optimal stationary policy (A13.82).
  • r(s, a)immediate reward.
  • γdiscount factor, 0 ≤ γ < 1.
  • s′ ∼ p(·∣s, a)random next state from the transition kernel.
  • arg maxa′ 𝔼[ Z*(s′, a′) ]greedy action with respect to the mean of the optimal distribution; this is the action chosen by π*.
  • c.d.f.cumulative distribution function; indicates equality in distribution of the random variables.
A13.160

Algorithm Categorical DQN (C51)

Categorical DQN (C51) is a distributional reinforcement learning algorithm that models the distribution of the random return Z(s, a) as a discrete categorical distribution over a fixed set of N = A+1 atoms (support values) zi. A neural network outputs the probability mass pi(s, a; θ) for each atom i. The algorithm is trained by minimizing the cross‑entropy loss between the projected target distribution and the predicted distribution.

Hyperparameters:

  • B – mini‑batch size.
  • Vmax, Vmin – bounds of the value support.
  • A – number of intervals; the grid has N = A+1 atoms.
  • K – periodicity of target network update (in steps).
  • ε(t) – exploration strategy (e.g., decaying ε‑greedy).
  • pi(s, a; θ) – neural network output: probability of atom i for state‑action pair (s, a), parameterised by θ.
  • SGD‑optimizer (e.g., Adam).

Algorithm:

  1. Precompute grid nodes:
    zi ≐ Vmin + (i / A) (Vmax − Vmin),  i = 0, 1, …, A.
  2. Initialize: network parameters θ arbitrarily; set target network θ ← θ.
  3. Observe initial state s0.
  4. For each step t:
    1. Select action: with probability ε(t) pick at uniformly at random; otherwise,
      at = arg maxai=0A zi pi(st, a; θ).
    2. Execute at, observe reward rt, next state st+1, and terminal flag donet+1.
    3. Store transition (st, at, rt, st+1, donet+1) in replay buffer.
    4. Sample a random mini‑batch of size B from the buffer.
    5. For each sampled transition (s, a, r, s′, done), compute the target distribution:
      P( y(T) = r + γ (1 − done) zi ) = pi( s′, arg maxa′j=0A zj pj(s′, a′; θ) ; θ ).
    6. Project the target onto the fixed grid {z0, …, zA} using the projection operator Π (i.e., for each i, P(y(T) = zi) is computed by distributing the probability mass of r + γ zj proportionally to the nearest grid nodes).
    7. Compute the cross‑entropy loss:
      Loss(θ) = − (1/B) ∑Ti=0A P( y(T) = zi ) log pi(s, a; θ).
    8. Perform a gradient descent step on θ using θ Loss(θ).
    9. If t mod K = 0, update the target network: θ ← θ.
  • zii‑th atom (support value) of the categorical distribution; i=0,…,A.
  • pi(s, a; θ)probability mass assigned to atom zi for state‑action pair (s,a), output by the online network.
  • θparameters of the online network.
  • θparameters of the target network (frozen periodically).
  • Vmin, Vmaxminimum and maximum possible values for the return distribution support.
  • Anumber of intervals; there are N = A+1 atoms.
  • γdiscount factor (implicitly used; often a fixed hyperparameter).
  • doneterminal flag; done = 1 if s′ is terminal, else 0.
  • Πprojection operator that maps the target distribution onto the fixed grid {zi}.
  • Loss(θ)cross‑entropy between the projected target distribution and the predicted probabilities.
  • ε(t)exploration probability at step t (typically decayed over time).
  • Ktarget network update frequency (number of steps).
  • Bmini‑batch size.
A13.161

Algorithm : Quantile Regression DQN (QR‑DQN)

Quantile Regression DQN (QR‑DQN) is a distributional reinforcement learning algorithm that represents the distribution of the random return Z(s, a) by a set of N = A quantile locations zi(s, a; θ) output by a neural network. The quantiles are learned by minimizing the quantile regression loss, which provides a robust and sample‑efficient alternative to categorical methods.

Hyperparameters:

  • B – mini‑batch size.
  • A – number of quantiles (atoms).
  • K – periodicity of target network update (in steps).
  • ε(t) – exploration strategy (e.g., decaying ε‑greedy).
  • zi(s, a; θ) – neural network output: the i-th quantile of the return distribution for state‑action pair (s, a), parameterised by θ (i = 0, …, A−1).
  • SGD‑optimizer (e.g., Adam).

Precompute:

τi = (i / A + (i+1) / A) / 2,  i = 0, 1, …, A−1.

These τi are the target quantile midpoints used in the loss function.

Algorithm:

  1. Initialize: network parameters θ arbitrarily; set target network θ ← θ.
  2. Observe initial state s0.
  3. For each step t:
    1. Select action: with probability ε(t) pick at uniformly at random; otherwise,
      at = arg maxa (1/A) ∑i=0A−1 zi(st, a; θ).
      (The expected value is approximated by the mean of the quantiles.)
    2. Execute at, observe reward rt, next state st+1, and terminal flag donet+1.
    3. Store transition (st, at, rt, st+1, donet+1) in replay buffer.
    4. Sample a random mini‑batch of size B from the buffer.
    5. For each sampled transition (s, a, r, s′, done), compute the target quantiles:
      yj = r + (1 − done) γ zj( s′, arg maxa′ (1/A) ∑i zi(s′, a′; θ) ; θ ),
      for j = 0, …, A−1.
    6. Compute the quantile regression loss:
      Loss(θ) = (1 / (B A)) ∑Ti=0A−1j=0A−1 ( τi − I[ zi(s, a; θ) < yj ] ) ( zi(s, a; θ) − yj ),
      where I[·] is the indicator function.
    7. Perform a gradient descent step on θ using θ Loss(θ).
    8. If t mod K = 0, update the target network: θ ← θ.
  • zi(s, a; θ)the i-th quantile estimate of the return distribution for state‑action pair (s,a), output by the online network (i = 0,…,A−1).
  • τitarget quantile midpoint; the model aims to estimate the τi-th quantile of the return distribution.
  • θparameters of the online network.
  • θparameters of the target network (frozen periodically).
  • Anumber of quantiles (atoms).
  • γdiscount factor (implicit in the target).
  • doneterminal flag; done = 1 if s′ is terminal, else 0.
  • yjtarget quantile value computed from the target network for the j-th quantile.
  • I[·]indicator function, 1 if condition is true, else 0.
  • Loss(θ)quantile regression loss (pinball loss) summed over quantile pairs.
  • ε(t)exploration probability at step t.
  • Ktarget network update frequency (number of steps).
  • Bmini‑batch size.
A13.162

Implicit Quantile Networks

Implicit Quantile Networks (IQN) is a distributional reinforcement learning algorithm that parameterises the quantile function of the return distribution as a continuous mapping (s, a, τ) ↦ Zτ(s, a; θ), where τ ∈ [0,1] is a quantile fraction sampled uniformly during training. Unlike QR‑DQN, which outputs a fixed set of quantiles, IQN learns a function that can be evaluated at any τ, enabling risk‑sensitive policies and improved sample efficiency.

For a transition (s, a, r, s′), the greedy action a* is chosen by maximising the expected value, approximated by sampling τ ∼ U[0,1] and taking the mean of Zτ(s′, a′; θ). The target distribution is given by the target network evaluated at N′ sampled quantiles. The loss is a sum of quantile regression losses (often Huber quantile loss) over all pairs of sampled τ and τ′:

Loss(θ) = (1/N′) ∑i=1Nj=1N′ ρτiκ( Zτi(s, a; θ) − ( r + γ Zτ′j(s′, a*; θ) ) ),

where ρ is the Huber quantile loss with threshold κ, N and N′ are the numbers of quantile samples used for the current and target estimates, respectively, and θ are the target network parameters. IQN generalises QR‑DQN and achieves strong performance on a variety of benchmarks.

  • Zτ(s, a; θ)quantile function parameterised by θ; returns the τ-th quantile of the return distribution for (s, a).
  • τquantile fraction, τ ∈ [0,1], sampled from a uniform distribution during training.
  • θonline network parameters.
  • θtarget network parameters (frozen periodically).
  • a*greedy action for next state s′, selected by maximising the expected value approximated from sampled quantiles.
  • ρτκHuber quantile loss at level τ with threshold κ (smooth version of the pinball loss).
  • N, N′numbers of sampled quantiles for the online and target estimates, respectively.
A13.163

Rainbow DQN

Rainbow DQN integrates six DQN enhancements – Double DQN, Prioritized Replay, Dueling, Multi‑step, Distributional C51, and Noisy Nets – into a single agent. The algorithm learns a categorical distribution over returns using a dueling‑noisy network, minimizes a cross‑entropy loss with importance‑sampling corrections, and uses learned parameter noise for exploration.

Algorithm (Rainbow DQN):

  • Hyperparameters: N atoms, support [Vmin, Vmax], n‑step, prioritization α, β, learning rate η, replay buffer size, target network update frequency K.
  • Initialize: online network parameters θ (dueling, noisy layers, categorical output probabilities pi(s,a; θ)); target network θ ← θ; prioritized replay buffer D with max priority pmax = 1.

For each step t = 0, 1, … :

  1. Observe state s; select action a from the online network (no ε‑greedy, noise provides exploration).
  2. Execute a; observe r, s′, done.
  3. Store transition (s, a, r, s′, done) in D with maximal priority pmax.
  4. Sample mini‑batch of B transitions (sj, aj, rj, s′j, donej) with probability P(j) ∝ pjα. Compute importance‑sampling weights wj = (B·P(j))−β (normalized).
  5. For each transition j, compute the n-step distributional target:
    Gt:t+n = (∑k=0n−1 γk rt+k) + γn (1 − donet+n) Ztarget(st+n, a*),
    where a* = arg maxa′ 𝔼[ Zonline(st+n, a′) ] (double Q‑learning with mean of categorical), and Z denotes the categorical distribution output.
  6. Project the target distribution Ztarget onto the fixed support {zi} using the projection Π (as in C51).
  7. Compute the weighted cross‑entropy loss:
    L(θ) = − (1/B) ∑j wji Πi log pi(sj, aj; θ).
  8. Update θ by gradient descent on L(θ). Update each priority pj in the buffer with the KL divergence between the predicted and target distribution (or TD error).
  9. Every K steps, set θ ← θ.
  • pi(s,a; θ)predicted probability mass for atom zi (categorical distribution).
  • θ, θonline and target network parameters.
  • zisupport atoms: zi = Vmin + i/(N−1) (Vmax−Vmin).
  • nmulti‑step return length.
  • αprioritization exponent (e.g., 0.5).
  • βimportance‑sampling exponent, annealed from β0 to 1.
  • wjimportance weight for transition j.
  • Πiprojected target probability at atom zi.
  • L(θ)loss (weighted cross‑entropy).
  • Ktarget network update period.
A13.164

Policy Gradient Theorem

Theorem (Policy Gradient). For a stationary policy πθ(a|s) parameterised by θ, the gradient of the expected discounted return J(θ) = 𝔼πθ[∑t≥0 γt rt] with respect to θ is

θ J(θ) = 𝔼T ∼ πθ[ ∑t≥0 γt Qπθ(st, at) ∇θ log πθ(at | st) ].

Equivalently, using the advantage function Aπθ = Qπθ − Vπθ,

θ J(θ) = 𝔼T ∼ πθ[ ∑t≥0 γt Aπθ(st, at) ∇θ log πθ(at | st) ].

Proof. Consider the expected return from a given start state s0:

J(θ) = 𝔼πθ[ R(τ) ] = ∫ πθ(τ) R(τ) dτ,

where πθ(τ) is the trajectory density. Using the log‑likelihood trick,

θ J(θ) = ∫ ∇θ πθ(τ) R(τ) dτ = ∫ πθ(τ) ∇θ log πθ(τ) R(τ) dτ.

From the Markov property, the log‑gradient of the trajectory decomposes as

θ log πθ(τ) = ∑t≥0θ log πθ(at | st),

and the return R(τ) can be written as t≥0 γt rt. Then

θ J(θ) = 𝔼πθ[ ∑t≥0θ log πθ(at|st) ∑k=0 γk rk ].

For a given time step t, future rewards rk for k < t do not depend on at. Consequently, their expectation with respect to the policy at step t vanishes (the score function has zero mean conditioned on past). Thus, only the sum of future rewards starting at time t remains:

θ J(θ) = 𝔼πθ[ ∑t≥0 γt ( ∑k=0 γk rt+k ) ∇θ log πθ(at|st) ].

By definition, the term in parentheses is the action‑value function Qπθ(st, at). This gives the first identity. The second follows from the fact that Vπθ(st) does not depend on at and therefore the term Vπθ(st) ∇θ log πθ(at|st) has expectation zero, allowing Q to be replaced by the advantage A. ∎

  • J(θ)expected discounted return (score) of policy πθ.
  • πθ(a|s)parameterised policy with parameters θ.
  • θ log πθscore function (gradient of the log‑probability).
  • Qπθ(s,a)state‑action value function under policy πθ (A13.85).
  • Aπθ(s,a)advantage function under πθ (A13.101).
  • γdiscount factor, 0 ≤ γ < 1.
  • 𝔼πθexpectation over trajectories generated by πθ.
A13.165

Principle of Causality

Principle of Causality. For any t and with t > t̂, the gradient of the log‑probability of a later action is uncorrelated with an earlier reward:

𝔼T ∼ π[ ∇θ log πθ(at ∣ st) γ r ] = 0.

Proof. Express the trajectory expectation as a nested sequence of conditional expectations. All variables up to time (including s, a, and the reward r) are determined before action at is chosen. Therefore, they can be factored out of the innermost expectation that involves at:

𝔼T[ ∇θ log πθ(at ∣ st) γ r ]
= 𝔼a0, s1, …, s, a[ γ r 𝔼st̂+1, at̂+1, …, st, at, …[ ∇θ log πθ(at ∣ st) ] ].

For any state st, the conditional expectation of the score function over the action at is zero:

𝔼at ∼ πθ(·∣st)[ ∇θ log πθ(at ∣ st) ] = 0.

Hence the inner expectation vanishes, making the entire expression zero regardless of the earlier reward. ∎

This principle justifies dropping rewards that precede an action when computing the policy gradient, leading to the standard Monte Carlo estimate that sums future rewards only.

  • πθpolicy parameterised by θ.
  • θ log πθ(a|s)score function (gradient of log‑probability).
  • γdiscount factor.
  • rreward received at time (earlier than t).
  • 𝔼T ∼ πexpectation over trajectories generated by policy π.
A13.166

REINFORCE

REINFORCE is a Monte Carlo policy gradient algorithm that directly estimates the gradient of the expected return using the score function and the empirical return (reward‑to‑go) from sampled episodes. It updates the policy parameters in the direction of the gradient, increasing the probability of actions that led to higher returns.

Hyperparameters: N — number of episodes per gradient estimate, π(a∣s, θ) — policy with parameters θ, SGD‑optimizer.

Initialize θ arbitrarily.

At each iteration:

  1. Play N episodes T1, T2, …, TN ∼ πθ.
  2. For each time step t in each episode T, compute the reward‑to‑go (return from t):
    Rt(T) ≐ ∑t̂ = t γt̂ − t r.
  3. Estimate the policy gradient as the sample mean over episodes:
    θ J(θ) = (1/N) ∑Tt ≥ 0 γtθ log πθ(at | st) Rt(T).
  4. Update the policy parameters by gradient ascent:
    θ ← θ + α ∇θ J(θ).

The algorithm is on‑policy; the collected episodes must be discarded after each update. Variants may use a baseline (like the state value) to reduce variance.

  • θpolicy parameters.
  • πθ(a|s)stochastic policy parameterised by θ.
  • Nnumber of episodes used per gradient estimate.
  • Ta trajectory (episode).
  • Rt(T)return (reward‑to‑go) from time t in trajectory T.
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • θ log πθscore function (gradient of the log‑policy).
A13.167

State Visitation Frequency

Under a stationary policy π, the discounted state visitation frequency (or unnormalised occupancy measure) measures how often, on average, the agent reaches a state s when following π, with future visits discounted by γ. It is defined as

dπ(s) ≐ ∑t=0 γt Pr( St = s ∣ S0 = s0, π ),

where s0 is a fixed initial state or the start distribution. A closely related normalised version is the discounted stationary distribution μπ(s) = (1−γ) dπ(s), which integrates to one over the state space. When γ = 1 and the Markov chain induced by π is ergodic, dπ(s) (appropriately scaled) coincides with the stationary distribution of the chain.

  • dπ(s)unnormalised discounted visitation frequency of state s under policy π.
  • μπ(s)discounted stationary distribution: (1−γ) dπ(s), a proper probability mass function.
  • γdiscount factor, 0 ≤ γ < 1.
  • Pr(St=s ∣ S0=s0, π)probability of being in state s at time t, when starting from s0 and following π.
  • s0initial state (or initial distribution).
A13.168

Decoupling External and Internal Stochasticity

Decoupling external and internal stochasticity refers to separating the randomness originating from the environment (external, e.g., transitions p(s′|s,a)) from the randomness deliberately introduced by the policy (internal, e.g., sampling a ∼ πθ(·|s)). This separation is exploited to obtain lower‑variance gradient estimates.

In standard policy gradients, the trajectory log‑likelihood decouples because the environment dynamics do not depend on the policy parameters:

θ log pθ(τ) = ∑tθ log πθ(at | st).

The reparameterization trick further decouples the policy’s internal noise source from the parameters by expressing the action as a deterministic function of state and a fixed noise variable:

a = fθ(s, ε),  ε ∼ p0(ε),

where p0 is a parameter‑free distribution (e.g., standard Gaussian). This allows the gradient to be moved inside the expectation, often reducing variance when combined with critics.

  • πθ(a|s)stochastic policy with parameters θ.
  • pθ(τ)probability density of trajectory τ under the policy and environment dynamics.
  • fθ(s, ε)deterministic function parameterised by θ that outputs an action given state s and noise ε.
  • εauxiliary noise variable drawn from a fixed distribution p0 (e.g., N(0,I)).
  • p0(ε)parameter‑free base noise distribution (external to the optimisation).
A13.169

Connection with Policy Improvement

Policy gradient methods are deeply connected to policy improvement (A13.105). The policy gradient theorem ensures that an update in the direction θ J(θ) moves the policy toward a region of higher expected return. In fact, using the relative performance identity (A13.103) and a compatible function approximator, the gradient update can be seen as performing a soft version of the greedy policy improvement step of policy iteration. When the policy is parameterised appropriately, gradient ascent on J(θ) converges to a locally optimal policy, mimicking the monotonic improvement property of exact dynamic programming.

A13.170

Baseline

A baseline is a state‑dependent (or constant) function b(s) subtracted from the return (or Q‑function) in a policy gradient estimator to reduce its variance without introducing bias. For any b(s) that does not depend on the action a,

𝔼a ∼ πθ(·∣s)[ ∇θ log πθ(a∣s) b(s) ] = 0.

A common choice is b(s) = Vπ(s), which turns the return estimate into an advantage estimate Aπ(s,a), often leading to substantial variance reduction.

  • b(s)baseline function; can be a learned value function Vφ(s) or a simple average return.
  • πθparameterised policy.
  • θ log πθscore function.
A13.171

Actor‑Critic Schemes

Actor‑critic methods combine policy‑based and value‑based approaches. They maintain two distinct components:

  • Actor (πθ): a parameterised policy that selects actions.
  • Critic (Vφ or Qφ): a parameterised value function that evaluates the current policy and provides a learning signal (e.g., the TD error or advantage).

The critic reduces the variance of the policy gradient estimate by providing a lower‑variance baseline. The update typically follows a two‑timescale or simultaneous scheme:

δt = rt+1 + γ Vφ(st+1) − Vφ(st),
θ ← θ + α δtθ log πθ(at|st),
φ ← φ + β δtφ Vφ(st).

Here δt is the TD error, used to update both the actor (policy parameters θ) and the critic (value parameters φ). This is the simplest one‑step actor‑critic (TD(0) AC). Many variants exist, including advantage actor‑critic (A2C), asynchronous A3C, and soft actor‑critic (SAC).

  • πθ(a|s)actor (policy) with parameters θ.
  • Vφ(s)critic (value function) with parameters φ.
  • δttemporal‑difference error at time t: rt+1 + γ V(st+1) − V(st).
  • αlearning rate for the actor (policy).
  • βlearning rate for the critic (value function).
  • γdiscount factor.
A13.172

Generalized Advantage Estimation (GAE)

Generalized Advantage Estimation (GAE) is a technique for estimating the advantage function Aπ(s,a) as an exponentially weighted sum of temporal‑difference errors, controlled by a parameter λ ∈ [0,1]. It provides a bias‑variance trade‑off between one‑step TD (λ=0) and Monte Carlo (λ=1) estimates.

Given a sequence of states, actions, and rewards generated under policy π, and a value function approximator V, define the one‑step TD error at time t as

δt = rt + γ V(st+1) − V(st).

The GAE advantage estimator at time t is then defined by the summation

ÂtGAE(γ,λ) = ∑l=0 (γλ)l δt+l.

Equivalently, it can be expressed as a λ-weighted average of k-step advantage estimators:

ÂtGAE(γ,λ) = (1 − λ) ∑k=1 λk−1 ( ∑i=0k−1 γi rt+i + γk V(st+k) − V(st) ).

In practice, the infinite sum is truncated at the end of an episode (where future δ are zero). GAE is widely used in policy gradient methods such as PPO and TRPO to compute stable, low‑variance advantage estimates.

  • ÂtGAE(γ,λ)estimated advantage at time t using GAE with discount γ and trace decay λ.
  • δtone‑step TD error: rt + γ V(st+1) − V(st).
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • λtrace‑decay parameter, 0 ≤ λ ≤ 1; controls the bias‑variance trade‑off.
  • V(s)approximate state value function (critic).
  • rtreward received at time t.
  • knumber of steps until bootstrapping in the k‑step return.
A13.173

Training the Critic

In actor‑critic methods, the critic is a value function approximator Vφ(s) (or Qφ(s,a)) trained to predict the expected return under the current policy. Its parameters φ are updated to minimise a mean‑squared error (MSE) between the predicted value and a target return Gt. A typical one‑step TD loss is

L(φ) = 𝔼(st, rt, st+1)[ ( rt + γ Vφ(st+1) − Vφ(st) )2 ],

where the target rt + γ Vφ(st+1) is typically computed with a frozen (target) or detached copy of the network to avoid moving‑target instability. The critic provides a baseline for the actor’s policy gradient update, reducing variance without introducing bias.

  • Vφ(s)state value function (critic) parameterised by φ.
  • φparameters of the critic network.
  • rtreward observed after taking action at time t.
  • γdiscount factor.
  • L(φ)loss function for the critic (typically MSE).
A13.174

Advantage Actor‑Critic (A2C)

Advantage Actor‑Critic (A2C) is a synchronous, on‑policy actor‑critic algorithm that uses multiple parallel environments to collect rollouts and updates both a policy (actor) and a value function (critic) simultaneously. The advantage estimate A(s,a) = Q(s,a) − V(s) serves as the actor’s learning signal, reducing gradient variance while maintaining unbiased updates.

Hyperparameters: M – number of parallel environments, N – rollout length, Vφ(s) – critic network with parameters φ, πθ(a|s) – actor network with parameters θ, α – critic loss coefficient, SGD optimizer.

Initialize θ and φ arbitrarily.

At each iteration:

  1. In each of the M parallel environments, collect a rollout of N steps using the current policy πθ:
    s0, a0, r0, s1, …, sN.
  2. For every state‑action pair (st, at) in each rollout, compute the N‑step return (Q‑function estimate) treating the critic’s value at the end as the bootstrap:
    Qest(st, at) = ∑k=tN-1 γk-t rk + γN-t Vφ(sN).
    (Gradients are not propagated through the target Vφ(sN).)
  3. Compute the critic loss as the mean squared error over all collected data:
    Lcritic(φ) = (1 / (M N)) ∑t ( Qest(st, at) − Vφ(st) )2.
  4. Update the critic by gradient descent: φ ← φ − η ∇φ Lcritic(φ) (or using the optimizer).
  5. Compute the actor gradient using the advantage estimate:
    θ J(θ) = (1 / (M N)) ∑tθ log πθ(at|st) ( Qest(st, at) − Vφ(st) ).
  6. Update the actor by gradient ascent: θ ← θ + η ∇θ J(θ) (using the same or separate optimizer).

The algorithm is synchronous: the parallel environments proceed in lockstep, and the gradient updates are averaged over all environments and time steps. A2C is a simplified, efficient version of A3C that works well on many control problems.

  • πθ(a|s)actor (policy) parameterised by θ.
  • Vφ(s)critic (value function) parameterised by φ.
  • Mnumber of parallel environments.
  • Nlength of each rollout (number of steps).
  • γdiscount factor, 0 ≤ γ ≤ 1.
  • Qest(s,a)N‑step return estimate used as target for the critic.
  • Lcritic(φ)mean squared error loss for the critic.
  • θ J(θ)policy gradient estimate (with baseline subtraction).
A13.175

Surrogate Function

In policy gradient methods, a surrogate function is a local approximation of the expected return J(πθ) that is used as a tractable objective for updating the policy. It is typically constructed from the current policy πold and provides theoretical guarantees of monotonic improvement when the policy change is sufficiently small.

The standard surrogate objective used in TRPO and PPO is the expected advantage reweighted by the importance‑sampling ratio:

L(θ) = 𝔼s ∼ dπold, a ∼ πold(·∣s)[ πθ(a ∣ s)πold(a ∣ s) Aπold(s, a) ].

Maximising this surrogate while constraining the Kullback–Leibler divergence between πθ and πold leads to reliable policy updates with guaranteed performance improvement.

  • L(θ)surrogate objective; a first‑order approximation of J(πθ) − J(πold).
  • πθnew policy parameterised by θ.
  • πoldcurrent policy (before the update), with fixed parameters.
  • Aπold(s, a)advantage function under the old policy (A13.101).
  • dπolddiscounted state visitation distribution under the old policy (A13.167).
  • πθ(a∣s)/πold(a∣s)importance‑sampling ratio (probability ratio).
A13.176

Trust Region Policy Optimization (TRPO)

Trust Region Policy Optimization (TRPO) is an on‑policy policy gradient algorithm that enforces a Kullback–Leibler (KL) divergence constraint on the policy update to guarantee monotonic improvement. It maximises a surrogate objective subject to a trust‑region constraint.

For a current policy πold (parameters θold) and a new policy πθ, the constrained optimisation problem is

maximiseθ   𝔼s ∼ dπold, a ∼ πold(·∣s)[ πθ(a ∣ s)πold(a ∣ s) Aπold(s, a) ]
subject to   𝔼s ∼ dπold[ DKL( πold(·∣s) ∥ πθ(·∣s) ) ] ≤ δ,

where Aπold is the advantage function of the old policy and δ is a small constant (e.g., 0.01).

The algorithm approximately solves the constrained problem by taking a linear approximation to the objective and a quadratic approximation to the KL divergence, yielding a natural gradient step. The step direction is computed using conjugate gradient on the Fisher‑vector product, avoiding explicit matrix inversion. A backtracking line search then ensures the KL constraint is satisfied and the true objective improves.

Algorithm (TRPO):

  1. Collect a set of trajectories using the current policy πθold.
  2. Compute advantage estimates Ât for all time steps (e.g., using GAE, A13.172).
  3. Form the sample estimate of the surrogate objective L(θ) and its gradient g = ∇θ L(θ)|θ=θold.
  4. Use the conjugate gradient method to compute the search direction s ≈ F−1 g, where F is the Fisher information matrix (the Hessian of the sample KL divergence). The matrix‑vector products Fv are computed via automatic differentiation.
  5. Scale the step: Δθ = s √(2δ / (sT F s)) to satisfy the KL constraint linearly.
  6. Perform a backtracking line search along Δθ: for each candidate step size α (starting at 1 and decaying), compute the new parameters θ = θold + α Δθ, evaluate the actual KL divergence and the surrogate objective. Accept the first step that satisfies the KL constraint DKL ≤ δ and improves the objective L(θ) ≥ 0.
  7. Update the policy parameters to the accepted θ.
  • πθparameterised policy (actor).
  • θoldparameters before the update.
  • Aπold(s, a)advantage function under the old policy (A13.101).
  • dπoldstate visitation distribution under the old policy (A13.167).
  • DKL(· ∥ ·)Kullback–Leibler divergence between action distributions.
  • δKL‑divergence bound (trust‑region size).
  • ggradient of the surrogate objective w.r.t. θ at θ = θold.
  • FFisher information matrix (sample estimate of the Hessian of the KL).
  • ssearch direction (approximate natural gradient).
  • Δθparameter update step.
A13.177

Proximal Policy Loss

The proximal policy loss is the clipped surrogate objective used in Proximal Policy Optimization (PPO). It prevents excessively large policy updates by clipping the importance‑sampling ratio rt(θ) = πθ(at|st) / πold(at|st) when it moves outside a small interval around 1. The loss for a single time step is

LCLIP(θ) = 𝔼t[ min( rt(θ) Ât,   clip( rt(θ), 1−ε, 1+ε ) Ât ) ],

where Ât is an estimator of the advantage at time t, and ε (e.g., 0.1 or 0.2) is a small positive constant that defines the clipping range. The min operation ensures that the objective is a lower (pessimistic) bound on the unclipped surrogate, thereby improving stability and sample efficiency.

This loss is typically combined with a value‑function error term and an entropy bonus to form the full PPO objective.

  • LCLIP(θ)clipped surrogate loss for policy parameters θ.
  • rt(θ)ratio of the new policy probability to the old policy probability for action at in state st.
  • Âtadvantage estimate at time t (e.g., from GAE).
  • εclipping parameter; restricts rt to the interval [1−ε, 1+ε].
  • πθ(a|s)current policy (being optimised).
  • πold(a|s)policy used to collect the batch of data (fixed during the update).
  • clip(r, a, b)function that clamps r to the range [a, b].
A13.178

Clipped Value Loss

The clipped value loss is a variant of the mean squared error (MSE) used to train the critic (value function) in actor‑critic methods, typically combined with a clipped objective to prevent excessively large updates. For a given value target Vtarg and an old value prediction Vold (frozen before the update), the loss is defined as

LV(φ) = max(   ( Vφ(s) − Vtarg )2,   ( Vold + clip( Vφ(s) − Vold, −ε, ε ) − Vtarg )2 ).

Here ε is a small positive clipping parameter. The loss takes the element‑wise maximum between the unclipped squared error and the squared error after clipping the difference Vφ(s) − Vold. This prevents the value function from changing too much in a single update, improving stability.

  • Vφ(s)current value estimate from the critic network with parameters φ.
  • Vtargtarget value (e.g., bootstrapped return or Monte‑Carlo return).
  • Voldvalue prediction under the parameters φold before the update (used as a reference).
  • εclipping range for the value update (same as or similar to the policy clipping ε).
  • clip(x, −ε, ε)function that clamps x to the interval [−ε, ε].
A13.179

Proximal Policy Optimization (PPO)

Proximal Policy Optimization (PPO) is an on‑policy policy gradient algorithm that alternates between sampling data from the current policy and optimizing a clipped surrogate objective. It simplifies TRPO by using a clipped probability ratio to penalize large policy updates, achieving comparable stability and performance with lower implementation complexity.

Algorithm 21: Proximal Policy Optimization (PPO)

Hyperparameters: M – number of parallel environments, N – rollout length, B – mini‑batch size, n_epochs – number of epochs, λ – GAE estimate parameter, ϵ – clipping parameter for the actor, ϵ̂ – clipping parameter for the critic, Vφ(s) – critic network with parameters φ, πθ(a∣s) – actor network with parameters θ, α – scaling coefficient for the critic loss, SGD optimizer.

Initialize θ and φ.

At each iteration:

  1. In each of M parallel environments, collect a rollout of N steps using πθ. Store, for every visited state s, the action a, the reward r, the next state s′, the terminal flag done, the action probability under the current policy πold(a∣s) = πθ(a∣s), and the critic’s value estimate Vold(s) = Vφ(s).
  2. For every collected transition (s, a, r, s′, done), compute the one‑step TD error:
    δ = r + γ (1 − done) Vφ(s′) − Vφ(s).
  3. Compute the Generalized Advantage Estimate (GAE) recursively backward from t = N−1 to 0:
    ÂN−1 = δN−1,
    Ât = δt + γ λ (1 − donet) Ât+1,  t = N−2, …, 0.
  4. Form the critic target as y(s) = Â + Vφ(s) (the bootstrapped return).
  5. Construct a dataset of tuples (s, a, Â, y, πold(a∣s), Vold(s)) from all rollouts.
  6. For n_epochs passes over the dataset in mini‑batches of size B:
    1. Critic update: for each mini‑batch, compute the clipped value loss
      LV(φ) = (1/B) ∑T max( (Vφ(s) − y)2,
                    (Vold(s) + clip( Vφ(s) − Vold(s), −ϵ̂, ϵ̂ ) − y)2 ).
      Update φ via gradient descent on LV.
    2. Advantage normalization: standardize  within the mini‑batch to zero mean and unit variance (helps stabilize training).
    3. Actor update: for each mini‑batch, compute the importance sampling ratio
      rθ = πθ(a∣s) / πold(a∣s).
      Compute the clipped surrogate objective:
      LCLIP(θ) = (1/B) ∑T min( rθ Â, clip( rθ, 1−ϵ, 1+ϵ ) Â ).
      Update θ via gradient ascent on LCLIP.

PPO’s simplicity, robustness, and sample efficiency make it one of the most widely used policy gradient methods for both discrete and continuous control tasks.

  • πθ(a|s)actor (policy) network with parameters θ.
  • Vφ(s)critic (value) network with parameters φ.
  • Mnumber of parallel environments.
  • Nrollout length (number of steps per environment per iteration).
  • Bmini‑batch size.
  • n_epochsnumber of epochs per iteration over the collected data.
  • λGAE trace‑decay parameter (A13.172).
  • ϵclipping parameter for the actor (e.g., 0.1 or 0.2).
  • ϵ̂clipping parameter for the critic (e.g., same as ϵ).
  • γdiscount factor.
  • δone‑step TD error: r + γ (1−done) V(s′) − V(s).
  • ÂtGeneralized Advantage Estimate at time t.
  • πold(a|s)action probability under the policy before the update (frozen).
  • Vold(s)value estimate before the update (frozen).
  • rθprobability ratio πθ(a|s) / πold(a|s).
  • LCLIP(θ)clipped surrogate loss for the actor.
  • LV(φ)clipped value loss for the critic.
A13.180

Derivation from Deep Q‑learning

Deep Q‑learning (DQN, A13.144) generalises tabular Q‑learning (A13.124) to high‑dimensional or continuous state spaces by replacing the tabular Q‑table Q(s,a) with a parametric function approximator Q(s,a; θ), typically a deep neural network. The parameters θ are learned by minimising the mean‑squared Bellman error over samples drawn from a replay buffer.

Starting from the tabular Q‑learning update at step k for a transition (s, a, r, s′):

Qk+1(s, a) = Qk(s, a) + α ( r + γ maxa′ Qk(s′, a′) − Qk(s, a) ),

we can view it as a stochastic gradient descent step on the squared TD error:

L(θ) = ( r + γ maxa′ Q(s′, a′; θ) − Q(s, a; θ) )2,

where θ denotes the parameters of a separate target network used to stabilise the moving target. The gradient θ L(θ) then gives the update for the online network. This loss is minimised over mini‑batches of uncorrelated transitions sampled from an experience replay buffer (A13.128), which breaks temporal correlations and stabilises training.

  • Q(s,a; θ)online action‑value function approximator with parameters θ.
  • Q(s,a; θ)target network with frozen parameters θ.
  • αlearning rate.
  • γdiscount factor.
  • L(θ)loss function (mean squared Bellman error).
  • θ L(θ)gradient used for optimization of the online network.
A13.181

Derivation from Policy Gradient

Starting from the policy gradient theorem (A13.164), the stochastic gradient of the expected discounted return J(θ) = 𝔼πθ[∑ γt rt] with respect to the policy parameters θ is

θ J(θ) = 𝔼τ ∼ πθ[ ∑t≥0 γt Qπθ(st, at) ∇θ log πθ(at | st) ].

Because the true action‑value function Qπθ is unknown, it is replaced by a sample return or by a learned critic.

Derivation of the Monte‑Carlo policy gradient (REINFORCE):
Sample a trajectory τ = (s0, a0, r0, s1, …) and approximate Qπθ(st, at) by the discounted return from time t, Gt = ∑k≥0 γk rt+k. Dropping the expectation, we obtain the unbiased estimate

θ J(θ) ≈ ∑t≥0 γt Gtθ log πθ(at | st).

This is the REINFORCE update (A13.166), which is unbiased but has high variance.

Derivation of the Actor‑Critic update:
To reduce variance, subtract a state‑dependent baseline Vπ(s) (which does not bias the gradient). Using the advantage Aπ(s,a) = Qπ(s,a) − Vπ(s), the gradient becomes

θ J(θ) = 𝔼[ ∑t≥0 γt Aπ(st, at) ∇θ log πθ(at|st) ].

A practical implementation uses a critic Vφ(s) to estimate the state value and a bootstrapped estimate of the advantage (e.g., one‑step TD error δt = rt + γ Vφ(st+1) − Vφ(st)). Substituting Ât ≈ δt yields the standard one‑step actor‑critic gradient:

θ J(θ) ≈ ∑t γt δtθ log πθ(at|st).

The critic parameters φ are updated concurrently to minimise the TD error.

Connection to deterministic policies (DPG):
If the policy is deterministic, a = μθ(s), the stochastic policy gradient is replaced by the deterministic policy gradient theorem:

θ J(θ) = 𝔼s ∼ dμ[ ∇a Qμ(s, a) |a=μθ(s)θ μθ(s) ].

This forms the basis for off‑policy actor‑critic algorithms such as DDPG and TD3, where a critic Qφ is learned and the actor is updated via the chain rule.

  • J(θ)expected discounted return.
  • πθ(a|s)stochastic policy with parameters θ.
  • μθ(s)deterministic policy with parameters θ.
  • Qπ, Aπstate‑action value and advantage functions.
  • Gtdiscounted return from time t (Monte‑Carlo target).
  • δtone‑step TD error: rt + γ V(st+1) − V(st).
  • dμdiscounted state visitation distribution under deterministic policy μ.
  • γdiscount factor.
A13.182

Equivalence between Q‑learning and Policy Gradient Derivations

The derivations from Deep Q‑learning (A13.180) and from the policy gradient (A13.181) are connected through a common underlying principle: both aim to reduce a form of Bellman error and can be expressed as stochastic gradient updates on the same expected loss, depending on the policy parameterisation.

Consider a softmax policy πθ(a|s) ∝ exp( Qθ(s, a) ), where the Q‑values themselves are parameterised by θ. The log‑policy gradient can then be written as

θ log πθ(a|s) = ∇θ Qθ(s, a) − 𝔼a′∼πθ[ ∇θ Qθ(s, a′) ].

Substituting this into the policy gradient theorem (A13.164) and using a baseline Vθ(s) = 𝔼πθ[ Qθ(s, a) ], the policy gradient reduces to

θ J(θ) = 𝔼[ ∑ γt ( Qθ(st, at) − Vθ(st) ) ∇θ Qθ(st, at) ].

If the advantage Aθ(s,a) is approximated by the TD error δ = r + γ maxa′ Qθ(s′, a′) − Qθ(s, a) and the greedy action is used, the update becomes

θ J(θ) ≈ 𝔼[ δ ∇θ Qθ(s, a) ].

This is exactly the gradient of the squared TD error L(θ) = ( r + γ max Qθ(s′, a′) − Qθ(s, a) )2, which is the loss minimised by DQN (A13.180). Thus, for a tabular or function‑approximated softmax policy with a greedy target, the policy gradient update coincides with the Q‑learning update on the underlying Q‑function.

More generally, the deterministic policy gradient (DPG) theorem shows that for a deterministic policy μθ(s) and a critic Qφ,

θ J(θ) = 𝔼[ ∇a Qφ(s, a)|a=μθ(s)θ μθ(s) ].

If we choose μθ(s) to be the greedy policy with respect to Qθ and use a single critic that is simultaneously optimised via the Bellman error, the resulting algorithm (e.g., DDPG) is precisely an actor‑critic method derived from the same value‑iteration principle as DQN. Hence the two derivations are equivalent under appropriate choices of the policy representation and the gradient estimator.

  • πθ(a|s)softmax policy derived from Q‑values Qθ(s,a).
  • Qθ(s,a)parameterised Q‑function (could be the same network as the policy).
  • δTD error used in both value‑based and policy‑based updates.
  • μθ(s)deterministic policy (DPG).
  • θ J(θ)policy gradient; reduces to TD‑error‑based gradient under softmax/greedy choices.
A13.183

Ornstein–Uhlenbeck Noise

Ornstein–Uhlenbeck (OU) noise is a temporally correlated random process often used in reinforcement learning for continuous action spaces to generate temporally smooth exploration. It is defined by the stochastic differential equation

dxt = θ (μ − xt) dt + σ dWt,

where Wt is a Wiener process (Brownian motion), μ is the mean (long‑term) value to which the process reverts, θ > 0 is the speed of mean reversion, and σ > 0 is the volatility. In discrete time, a common approximation used in RL updates the noise nt at each step as

nt+1 = nt + θ (μ − nt) + σ εt,  εt ∼ N(0, I),

with a suitable time step Δt absorbed into the parameters. OU noise produces a correlated random walk that decays toward the mean, providing more persistent exploration than independent Gaussian noise. It was popularised by the DDPG algorithm for continuous control.

  • xtthe noise process value at time t (in RL, often added to the action).
  • θspeed of mean reversion (θ > 0); larger values cause faster decay toward μ.
  • μlong‑term mean of the process (often 0 for exploration noise).
  • σvolatility (scale) of the Wiener process (noise intensity).
  • WtWiener process (standard Brownian motion).
  • εtindependent Gaussian random variables with zero mean and identity covariance in discrete time.
A13.184

Deep Deterministic Policy Gradient (DDPG)

Deep Deterministic Policy Gradient (DDPG) is an off‑policy actor‑critic algorithm for continuous action spaces. It maintains a deterministic actor πω(s) and a critic Qθ(s, a), both implemented as deep neural networks. DDPG adapts the success of DQN to continuous control by using the deterministic policy gradient theorem, experience replay, and target networks with soft updates.

Algorithm:

  • Hyperparameters: B – mini‑batch size, β – soft update coefficient, α, σ – noise parameters (e.g., OU or Gaussian noise), K – target network update frequency, discount γ.
  • Initialization: online critic Qθ and actor πω arbitrarily; target networks θ ← θ, ω ← ω; replay buffer D; noise process ε = 0 (if using Ornstein–Uhlenbeck).

For each step t:

  1. Update exploration noise: ε ← α ε + ε̂, where ε̂ ∼ N(0, σ2 I) (or sample fresh Gaussian noise ε ∼ N(0, σ)).
  2. Select action: at = πω(st) + ε (clip to valid action range).
  3. Execute at, observe reward rt, next state st+1, and terminal flag donet+1.
  4. Store transition (st, at, rt, st+1, donet+1) in replay buffer D.
  5. Sample a random mini‑batch of B transitions (s, a, r, s′, done) from D.
  6. Compute target: y = r + γ (1 − done) Qθ( s′, πω(s′) ).
  7. Update critic by minimizing the MSE loss: L(θ) = (1/B) ∑ (Qθ(s,a) − y)2 (one gradient step).
  8. Update actor by the sampled deterministic policy gradient (one gradient ascent step):
    ω J ≈ (1/B) ∑ ∇a Qθ(s, a)|a=πω(s)ω πω(s).
  9. Every K steps, soft‑update target networks:
    θ ← (1−β) θ + β θ,  ω ← (1−β) ω + β ω.
  • πω(s)deterministic policy (actor) with parameters ω.
  • Qθ(s, a)action‑value function (critic) with parameters θ.
  • θ, ωtarget network parameters (slowly tracking the online networks).
  • βsoft update coefficient (e.g., 0.005).
  • α, σOrnstein–Uhlenbeck noise parameters: mean reversion rate and volatility; or use Gaussian noise with σ.
  • γdiscount factor.
  • Bmini‑batch size.
  • Ktarget network update frequency.
  • yTD target computed using target networks (clipped double Q in later variants).
A13.185

Twin Delayed DDPG (TD3)

Twin Delayed DDPG (TD3) is an off‑policy actor‑critic algorithm for continuous control that improves upon DDPG by addressing the overestimation bias and function approximation errors. It introduces three key techniques: clipped double Q‑learning (using two critics and taking the minimum for the target), delayed policy updates (updating the actor and target networks less frequently than the critics), and target policy smoothing (adding clipped noise to the target action to regularise the critic).

Algorithm (TD3):

  • Hyperparameters: B – mini‑batch size, β – soft update coefficient, σ – exploration noise standard deviation, σtarget – target policy smoothing noise, c – noise clipping, d – policy update delay, γ – discount factor.
  • Initialization: online critics Qθ1, Qθ2 and actor πω arbitrarily; target networks θ1 ← θ1, θ2 ← θ2, ω ← ω; replay buffer D.

For each step t:

  1. Select action with exploration noise: at = clip( πω(st) + ε, alow, ahigh ), where ε ∼ N(0, σ2) (noise can be OU or Gaussian).
  2. Execute at, observe rt, st+1, donet+1; store transition in D.
  3. Sample a random mini‑batch of size B from D.
  4. Compute the target action with clipped smoothing noise:
    ã = πω(s′) + clip( ξ, −c, c ),  ξ ∼ N(0, σtarget2),
    and then clip ã to the valid action range.
  5. Compute the common target value using the minimum of the two target critics:
    y = r + γ (1 − done) mini=1,2 Qθi(s′, ã).
  6. Update both critics by one gradient descent step on their respective MSE losses:
    L(θi) = (1/B) ∑ ( Qθi(s,a) − y )2,  i = 1,2.
  7. Every d steps:
    • Update the actor by one gradient ascent step on the sampled deterministic policy gradient (using the first critic):
      ω J ≈ (1/B) ∑ ∇a Qθ1(s, a)|a=πω(s)ω πω(s).
    • Soft‑update the three target networks:
      θi ← (1−β) θi + β θi (i=1,2),  ω ← (1−β) ω + β ω.

TD3 often uses d = 2 (update actor and targets every two critic updates) and c = 0.5 for the target smoothing clip.

  • πω(s)deterministic policy (actor) with parameters ω.
  • Qθ1, Qθ2two online critic networks with parameters θ1, θ2.
  • θi, ωtarget network parameters (slowly tracking the online networks).
  • σstandard deviation of exploration noise added to the actor.
  • σtargetstandard deviation of smoothing noise added to target actions.
  • ctarget noise clipping bound (e.g., 0.5).
  • dpolicy delay: actor and targets are updated every d critic updates.
  • βsoft update coefficient (e.g., 0.005).
  • γdiscount factor.
  • yTD target computed with target networks and clipped double Q‑learning.
  • ξnoise sample for target policy smoothing (drawn from N(0, σtarget2)).
A13.186

Training Stochastic Policies

Training stochastic policies refers to the process of learning a parameterised probability distribution πθ(a|s) over actions, typically by maximizing the expected discounted return J(θ) = 𝔼πθ[∑ γt rt] using gradient‑based optimisation. The foundation is the policy gradient theorem (A13.164), which expresses the gradient as

θ J(θ) = 𝔼[ ∑t≥0 γt Qπθ(st, at) ∇θ log πθ(at|st) ].

In practice, the unknown Q‑function is replaced by a sample return (REINFORCE, A13.166) or a learned critic (actor‑critic, A13.171). To reduce variance, a baseline (A13.170) is subtracted, often the state value V(s), leading to the advantage estimator A(s,a) ≈ Q(s,a) − V(s).

For continuous action spaces, the policy is often represented by a Gaussian distribution πθ(a|s) = N( μθ(s), σθ(s)2 ). The reparameterization trick decouples the noise: a = μθ(s) + σθ(s) ⊙ ε with ε ∼ N(0,I), enabling lower‑variance gradient estimates via the chain rule through the critic.

Prominent algorithms for training stochastic policies include REINFORCE, A2C/A3C, PPO (with its clipped surrogate objective), TRPO (using a trust region), and SAC (Soft Actor‑Critic, which additionally maximizes policy entropy).

  • πθ(a|s)stochastic policy parameterised by θ.
  • J(θ)expected discounted return (score).
  • θ log πθscore function (gradient of log‑probability).
  • Qπ, Aπaction‑value and advantage functions (A13.85, A13.101).
  • μθ(s), σθ(s)mean and standard deviation of a Gaussian policy (continuous actions).
  • εauxiliary noise variable for reparameterization, ε ∼ N(0,I).
  • γdiscount factor.
A13.187

Entropy of a Distribution

The entropy of a probability distribution π(a) over actions (or any random variable) quantifies its randomness or uncertainty. It is defined as the negative expected log‑probability:

H(π) ≐ − 𝔼a ∼ π[ log π(a) ] = − ∑a π(a) log π(a)

(the integral replaces the sum for continuous distributions). Entropy is maximised by the uniform distribution and is zero for a deterministic (degenerate) distribution. In RL, adding an entropy bonus to the policy objective encourages exploration and prevents premature convergence.

  • H(π)entropy of policy π (a scalar).
  • π(a)probability mass/density of action a under the policy.
  • 𝔼a∼π[·]expectation with respect to the action distribution.
A13.188

Maximum Entropy RL

The Maximum Entropy RL (or entropy‑regularised RL) problem augments the standard expected return objective with an entropy bonus that encourages stochasticity. The goal is to maximise the functional

Jsoft(π) ≐ 𝔼T ∼ πt≥0 γt [ rt + α H( π(·∣st) ) ] → maxπ,

where α ≥ 0 is the temperature hyperparameter that trades off reward maximisation and entropy maximisation, and H(π(·∣s)) is the entropy of the policy in state s (A13.187).

  • Jsoft(π)soft (entropy‑regularised) expected return.
  • πa stochastic policy π(a|s).
  • T ∼ πtrajectory distribution induced by π.
  • rtreward at time t.
  • αtemperature parameter (α ≥ 0); controls the strength of the entropy bonus.
  • H(π(·∣s))entropy of the action distribution at state s (A13.187).
A13.189

Soft Relationship Equations

For a policy π and temperature α = 1, the soft Q‑function Qsoftπ and soft V‑function Vsoftπ are defined via the soft return (A13.188) and satisfy the following pair of equations:

Qsoftπ(s, a) = r(s, a) + γ 𝔼s′ ∼ p(·∣s,a) Vsoftπ(s′) (6.9)
Vsoftπ(s) = 𝔼a ∼ π(·∣s)[ Qsoftπ(s, a) − log π(a∣s) ] (6.10)

Proof. (6.9) By definition, Qsoftπ(s, a) is the expected soft return starting from s, taking action a, and then following π. The soft return decomposes into the immediate reward r(s, a) plus the discounted soft return from the next state. The latter, by the definition of the soft V‑function, is exactly γ 𝔼s′ Vsoftπ(s′).

(6.10) The soft V‑function Vsoftπ(s) is the expected soft return from state s. Expanding the expectation over the first action a ∼ π(·∣s):

Vsoftπ(s) = 𝔼a[ r(s, a) + (−log π(a∣s)) + γ 𝔼s′ Vsoftπ(s′) ].

Here the term −log π(a∣s) is the contribution of the policy entropy at state s to the soft return (since H(π(·∣s)) = −𝔼a log π(a∣s)). Substituting Qsoftπ(s, a) from (6.9) for r(s, a) + γ 𝔼s′ Vsoftπ(s′) yields (6.10). ∎

  • Qsoftπ(s, a)soft action‑value function: expected soft return after taking action a in state s.
  • Vsoftπ(s)soft state value function: expected soft return from state s under policy π.
  • r(s, a)expected immediate reward.
  • γdiscount factor.
  • p(s′ ∣ s, a)transition probability.
  • π(a∣s)stochastic policy.
  • log π(a∣s)log‑probability of the action; its negative adds the entropy bonus.
A13.190

Soft Bellman Equations

For a policy π and temperature α = 1, the soft Bellman expectation equations for the soft Q‑function and soft V‑function are:

Qsoftπ(s, a) = r(s, a) + γ 𝔼s′ ∼ p(·∣s,a) 𝔼a′ ∼ π(·∣s′)[ Qsoftπ(s′, a′) − log π(a′ ∣ s′) ] (6.11)
Vsoftπ(s) = 𝔼a ∼ π(·∣s)[ r(s, a) − log π(a ∣ s) + γ 𝔼s′ ∼ p(·∣s,a) Vsoftπ(s′) ] (6.12)

Proof. These equations follow directly from the soft relationship equations (A13.189).

(6.11): From Qsoftπ(s, a) = r(s, a) + γ 𝔼s′ Vsoftπ(s′) (equation 6.9). Substituting the expression for Vsoftπ(s′) from (6.10) into the expectation over s′ yields

Qsoftπ(s, a) = r(s, a) + γ 𝔼s′[ 𝔼a′ ∼ π(·∣s′)( Qsoftπ(s′, a′) − log π(a′ ∣ s′) ) ].

(6.12): From Vsoftπ(s) = 𝔼a ∼ π(·∣s)[ Qsoftπ(s, a) − log π(a ∣ s) ] (equation 6.10). Replacing Qsoftπ(s, a) with the right‑hand side of (6.9) gives

Vsoftπ(s) = 𝔼a[ r(s, a) + γ 𝔼s′ Vsoftπ(s′) − log π(a ∣ s) ].

  • Qsoftπ(s, a)soft action‑value function for policy π (expected soft return after action a).
  • Vsoftπ(s)soft state value function for policy π (expected soft return from state s).
  • r(s, a)expected immediate reward.
  • γdiscount factor.
  • p(s′ ∣ s, a)transition probability.
  • π(a∣s)stochastic policy.
  • log π(a∣s)log‑policy term representing the immediate entropy bonus in the soft return.
A13.191

Soft Policy Evaluation

Soft policy evaluation is the process of computing the soft state value function Vsoftπ and the soft action‑value function Qsoftπ for a given policy π under the maximum entropy RL objective (A13.188). These functions satisfy the soft Bellman expectation equations (A13.190) and can be found by iteratively applying the soft Bellman operator until convergence.

For a tabular MDP, soft policy evaluation repeatedly applies the update:

Vnew(s) ← 𝔼a ∼ π(·∣s)[ r(s, a) − α log π(a∣s) + γ 𝔼s′ ∼ p(·∣s,a) Vold(s′) ],

where α is the temperature. Equivalently, the soft Q‑function can be updated as

Qnew(s, a) ← r(s, a) + γ 𝔼s′ ∼ p(·∣s,a)[ 𝔼a′ ∼ π(·∣s′)( Qold(s′, a′) − α log π(a′∣s′) ) ].

When the dynamics are unknown, function approximators and stochastic gradient descent are used to minimize the soft Bellman error, giving rise to algorithms such as Soft Actor‑Critic (SAC).

  • Vsoftπ(s)soft state value function for policy π (target of evaluation).
  • Qsoftπ(s, a)soft action‑value function for policy π.
  • π(a∣s)given stochastic policy.
  • αtemperature parameter controlling the entropy bonus (A13.188).
  • r(s, a)expected immediate reward.
  • γdiscount factor, 0 ≤ γ < 1.
  • p(s′ ∣ s, a)transition probability.
A13.192

Soft Policy Improvement

Soft policy improvement is the step in entropy‑regularised RL that updates the policy towards the exponential of the current soft Q‑function, guaranteeing a monotonic increase in the soft expected return.

Given a policy πold and the corresponding soft state‑action value Qsoftπold, define a new policy πnew as the Boltzmann distribution (for temperature α > 0):

πnew(a ∣ s) = exp( Qsoftπold(s, a) / α )a′ exp( Qsoftπold(s, a′) / α ).

Then πnew is strictly better than πold unless πold is already optimal under the maximum entropy objective: for all states s,

Vsoftπnew(s) ≥ Vsoftπold(s).

Proof sketch. Using the soft relationship equation Vsoftπold(s) = 𝔼a ∼ πold[ Qsoftπold(s, a) − α log πold(a∣s) ] and the fact that πnew maximises the right‑hand side with respect to all possible policies, we obtain Vsoftπold(s) ≤ 𝔼a ∼ πnew[ Qsoftπold(s, a) − α log πnew(a∣s) ]. Applying the soft Bellman expectation equation recursively then shows Vsoftπnew(s) ≥ Vsoftπold(s). If equality holds for all states, πold satisfies the soft Bellman optimality equation and is optimal. ∎

Alternating soft policy evaluation and soft policy improvement converges to the optimal maximum‑entropy policy, forming the basis of Soft Actor‑Critic (SAC).

  • πold, πnewcurrent and improved stochastic policies.
  • Qsoftπold(s, a)soft Q‑function of the old policy (A13.189).
  • Vsoftπ(s)soft state value function (A13.189).
  • αtemperature parameter (A13.188).
  • soft optimalitythe unique policy that maximises the soft return Jsoft.
A13.193

Soft Actor‑Critic (SAC)

Soft Actor‑Critic (SAC) is an off‑policy maximum entropy reinforcement learning algorithm for continuous action spaces. It learns a stochastic policy πφ(a|s) that maximises the entropy‑regularised return Jsoft(π) = 𝔼[∑ γt (rt + α H(π(·|st))) ]. To mitigate overestimation, SAC uses two separate Q‑networks (Qθ1, Qθ2) and takes their minimum for the target. The temperature α can be fixed or automatically tuned by treating it as a learnable parameter that maintains a target entropy level.

Algorithm (SAC with automatic entropy tuning):

  • Hyperparameters: learning rates ηθ, ηφ, ηα, soft update coefficient τ, discount γ, target entropy (e.g., −dim(A)), replay buffer size, mini‑batch size B.
  • Initialization: policy parameters φ (outputs mean μφ(s) and log‑std log σφ(s)); two Q‑networks Qθ1, Qθ2; target networks θ̄1 ← θ1, θ̄2 ← θ2; temperature α (or log α); replay buffer D.

For each step:

  1. Observe state s. Sample action a ∼ πφ(·|s) (e.g., Gaussian with reparameterization: a = μφ(s) + σφ(s) ⊙ ε, ε ∼ N(0,I)). Clip to valid action range.
  2. Execute a, observe reward r, next state s′, and terminal flag done. Store transition (s, a, r, s′, done) in D.
  3. Sample a mini‑batch of B transitions from D.
  4. Compute the target value for the Q‑networks (using target networks and a sample of the current policy):
    y = r + γ (1 − done) ( mini=1,2 Qθ̄i(s′, ã) − α log πφ(ã ∣ s′) ),
    ã ∼ πφ(·∣s′).
  5. Update the Q‑networks by one step of gradient descent on the mean squared Bellman error:
    LQi) = (1/B) ∑ ( Qθi(s, a) − y )2,  i = 1, 2.
  6. Update the policy by one step of gradient ascent on the entropy‑regularised expected return (using the minimum of the two critics to reduce overestimation):
    Lπ(φ) = − (1/B) ∑ ( mini=1,2 Qθi(s, ã) − α log πφ(ã ∣ s) ),
    ã = μφ(s) + σφ(s) ⊙ ε,  ε ∼ N(0,I) (reparameterized).
    The gradient flows through the Q‑networks (which are not updated in this step).
  7. Automatically tune the temperature by minimising the loss:
    L(α) = − α (1/B) ∑ ( log πφ(ã ∣ s) + H̄ ),
    where is the desired average entropy (e.g., −dim(A)). Update α (or log α) by gradient descent on L(α).
  8. Soft‑update the target networks:
    θ̄i ← τ θi + (1 − τ) θ̄i,  i = 1, 2.
  • πφ(a|s)stochastic policy parameterised by φ (typically Gaussian).
  • Qθ1, Qθ2two online Q‑networks (critics) with parameters θ1, θ2.
  • θ̄1, θ̄2target Q‑networks with Polyak averaged parameters.
  • αtemperature coefficient (entropy weight); can be learned or fixed.
  • target entropy (usually −dim(A)).
  • τsoft update interpolation factor (0 < τ < 1).
  • γdiscount factor.
  • ε ∼ N(0,I)noise vector used for action reparameterization.
  • yTD target computed from target networks and entropy term.
A13.194

The Multi‑Armed Bandit Problem

The multi‑armed bandit (MAB) is a simplified reinforcement learning problem with a single state. At each time step t = 1, …, T, the agent chooses an arm (action) at ∈ {1, …, K} and receives a random reward rt ∼ pat(r) drawn independently from an unknown probability distribution associated with that arm. The objective is to maximise the cumulative reward or, equivalently, to minimise the regret with respect to the optimal arm.

Let μ(a) = 𝔼[ r ∣ a ] be the expected reward of arm a, and let μ* = maxa μ(a). The regret after T steps is

R(T) = T μ* − 𝔼[ ∑t=1T rt ] = ∑a=1K Δ(a) 𝔼[ Na(T) ],

where Δ(a) = μ* − μ(a) is the sub‑optimality gap of arm a and Na(T) is the number of times arm a was pulled. The agent must balance exploration (trying new arms to learn their rewards) and exploitation (choosing the arm that currently appears best).

Fundamental algorithms include ε‑greedy, Upper Confidence Bound (UCB), and Thompson Sampling. The MAB formulation captures the exploration–exploitation dilemma in its purest form.

  • Knumber of arms (actions).
  • Ttime horizon (number of pulls).
  • atarm chosen at time t.
  • rtreward observed at time t.
  • pa(r)unknown reward distribution of arm a.
  • μ(a)expected reward of arm a, μ(a) = 𝔼[r|a].
  • μ*maximal expected reward among all arms.
  • Δ(a)sub‑optimality gap: μ* − μ(a).
  • Na(T)number of pulls of arm a up to time T.
  • R(T)expected cumulative regret after T steps.
A13.195

Regret

The regret after T episodes is the total expected loss incurred by not always choosing the optimal arm. It is defined as

RegretT ≐ T V* − ∑k=0T Q(ak),

where the sum is taken over the actions actually selected.

  • RegretTcumulative regret after T episodes.
  • Tnumber of episodes (time horizon).
  • V*maximum expected reward per step (value of the optimal arm).
  • Q(a)expected reward of arm a (Q‑function in the bandit context).
  • akaction (arm) chosen at episode k.
A13.196

Naïve Bandit

Naïve Bandit is an exploratory algorithm for the multi‑armed bandit that mixes random exploration with greedy exploitation using an ε-greedy strategy. It maintains a running average Qk(a) of the rewards observed for each arm a up to step k.

Hyperparameters: ε(k) – exploration probability at step k (can be constant or decay).

Initialize Q0(a) arbitrarily for all arms a; set visit counters n0(a) = 0.

At each step k:

  1. With probability ε(k), select a random arm uniformly; otherwise choose the arm with the highest current Q‑value:
    ak = arg maxa Qk(a).
  2. Increment the visit counter for the selected arm:
    nk(a) = nk−1(a) + 𝟙[ ak = a ].
  3. Observe reward rk after playing arm ak.
  4. Update the running average for the selected arm using the incremental formula:
    Qk(a) = Qk−1(a) + 𝟙[ ak = a ] · (1 / nk(a)) · ( rk − Qk−1(a) ).

This algorithm ensures that every arm is tried infinitely often in the limit, allowing Qk(a) to converge to the true expected reward μ(a) if the exploration probabilities satisfy ∑ ε(k) = ∞ and ∑ ε(k)2 < ∞ (Robbins–Monro conditions, A13.121).

  • Qk(a)estimated expected reward of arm a after k steps.
  • nk(a)number of times arm a has been played up to step k.
  • akarm chosen at step k.
  • rkreward received at step k.
  • ε(k)exploration probability at step k (e.g., constant or decayed).
  • 𝟙[·]indicator function (1 if true, else 0).
A13.197

The Lai–Robbins Theorem

The Lai–Robbins Theorem provides a fundamental lower bound on the asymptotic regret for any consistent policy in the multi‑armed bandit problem. It states that the number of times any sub‑optimal arm a is pulled grows at least logarithmically with the time horizon T, and the constant is inversely proportional to the Kullback–Leibler divergence between the reward distribution of that arm and the optimal arm.

Formally, for a policy that satisfies mild consistency conditions (e.g., uniformly good policies that achieve sub‑polynomial regret for all problem instances), the following lower bound holds:

lim infT→∞ 𝔼[ Na(T) ]log T1DKL( pa ∥ pa* ),

where pa and pa* are the reward distributions of arm a and the optimal arm a*, and DKL is the Kullback–Leibler divergence. Consequently, the cumulative regret R(T) cannot grow slower than

R(T) ≥ ( ∑a: Δ(a) > 0 Δ(a)DKL( pa ∥ pa* ) ) log T + o(log T).

This result establishes that the optimal asymptotic regret scaling is O(log T) and motivates the design of algorithms such as UCB1 and Thompson Sampling, which achieve matching upper bounds.

  • Ttime horizon (number of pulls).
  • Na(T)number of times arm a is pulled up to time T.
  • a*optimal arm (the one with the highest expected reward).
  • Δ(a)sub‑optimality gap of arm a: μ* − μ(a).
  • paprobability density (or mass) function of the reward distribution of arm a.
  • DKL( p ∥ q )Kullback–Leibler divergence between distributions p and q.
  • R(T)expected cumulative regret after T steps.
  • o(log T)terms that grow slower than log T asymptotically.
A13.198

Upper Confidence Bound (UCB)

Upper Confidence Bound (UCB) algorithms for the multi‑armed bandit select arms by balancing exploitation of the empirically best arm and exploration driven by the uncertainty in the arm’s reward estimate. The most common variant, UCB1, at each step k chooses the arm that maximises an upper confidence bound constructed from the sample mean plus a bonus term that decreases with the number of times the arm was played and increases with the total number of steps:

ak = arg maxa [ Qk(a) + c √( ln knk(a) ) ],

where Qk(a) is the empirical mean reward of arm a after k total pulls, nk(a) is the number of times arm a was selected up to step k, and c > 0 is a constant that controls the exploration–exploitation trade‑off (usually c = √2 for sub‑Gaussian rewards with variance 1).

UCB1 achieves logarithmic regret O(log T), matching the lower bound of the Lai–Robbins theorem up to a constant factor for bounded rewards. Variants include UCB‑Tuned, UCB‑V (for variance estimates), and KL‑UCB (which uses KL divergence).

  • Qk(a)sample mean reward of arm a after k steps.
  • nk(a)number of pulls of arm a up to step k.
  • ktotal number of pulls (time step).
  • cexploration constant; typical value c = √2 for rewards in [0,1].
  • √(ln k / nk(a))confidence bound (uncertainty term) that shrinks as the arm is pulled more.
A13.199

Hoeffding's Inequality

Hoeffding's inequality bounds the probability that the sample mean of independent bounded random variables deviates from its expected value. It is a fundamental tool for constructing confidence intervals in bandit and reinforcement learning algorithms.

Let X1, …, Xn be independent random variables such that Xi ∈ [ai, bi] almost surely for all i. Define the sum Sn = ∑i=1n Xi. Then for any t > 0,

Pr( Sn − 𝔼[Sn] ≥ t ) ≤ exp( − 2 t2i=1n (bi − ai)2 ),
Pr( Sn − 𝔼[Sn] ≤ −t ) ≤ exp( − 2 t2i=1n (bi − ai)2 ).

For the special case of i.i.d. random variables bounded in [0,1] and t = ε n, this gives the familiar bound for the sample mean n:

Pr( X̄n − 𝔼[X] ≥ ε ) ≤ exp( −2 n ε2 ).
  • Xiindependent bounded random variables.
  • ai, bilower and upper bounds: ai ≤ Xi ≤ bi.
  • Snsum of the n random variables.
  • tdeviation threshold (t > 0).
  • nsample mean: Sn / n.
A13.200

Thompson Sampling

Thompson Sampling is a Bayesian algorithm for the multi‑armed bandit problem. It maintains a posterior distribution over the expected reward of each arm and, at each step, samples a value from each arm's posterior. The arm with the highest sampled value is selected. After observing the reward, the posterior of the chosen arm is updated. This approach naturally balances exploration and exploitation and often achieves state‑of‑the‑art empirical performance, with regret bounds that match the Lai–Robbins lower bound.

Algorithm (Bernoulli rewards with Beta priors):

  • Initialization: For each arm a = 1, …, K, set αa = 1 and βa = 1 (non‑informative Beta prior).
  • At each step k = 1, 2, …:
    1. For each arm a, draw a sample θa ∼ Beta(αa, βa).
    2. Select the arm ak = arg maxa θa (break ties arbitrarily).
    3. Play arm ak and observe reward rk ∈ {0, 1}.
    4. Update the posterior parameters of the selected arm:
      αak ← αak + rk,  βak ← βak + (1 − rk).

For Gaussian rewards with known variance, a Gaussian prior is used instead. The principle of sampling from the posterior and choosing the best sample is general and can be applied to any parametric reward distribution with a conjugate prior.

  • Knumber of arms.
  • αa, βaparameters of the Beta posterior for arm a (pseudo‑counts of successes and failures).
  • θarandom sample from arm a's posterior – interpreted as a plausible expected reward.
  • akarm selected at step k.
  • rkobserved reward at step k (0 or 1 for Bernoulli, real for other distributions).
  • Beta(α, β)Beta distribution with shape parameters α and β; mean = α/(α+β).
A13.201

Beta‑Bernoulli Bandit with Thompson Sampling

Beta‑Bernoulli Bandit with Thompson Sampling is the standard implementation of Thompson Sampling for multi‑armed bandits with binary (0/1) rewards. It maintains a Beta posterior distribution for each arm, samples an expected reward from each posterior, and plays the arm with the largest sampled value. The posterior is updated by incrementing a success count αk(a) when a reward of 1 is observed and a failure count βk(a) when a reward of 0 is observed.

Hyperparameters: α, β — prior pseudo‑counts (e.g., α = β = 1 for a uniform prior).

Initialize counters α0(a) := α and β0(a) := β for all arms a.

At each step k:

  1. For each arm a, draw a sample from its current posterior distribution:
    θa ∼ Beta( αk(a), βk(a) ).
  2. Select the arm with the highest sampled value:
    ak = arg maxa θa.
  3. Play arm ak and observe a binary reward rk ∈ {0, 1}.
  4. Update the success counter αk(a) for the chosen arm:
    αk(a) = αk−1(a) + 𝟙[ ak = a ] · 𝟙[ rk = 1 ].
  5. Update the failure counter βk(a) for the chosen arm:
    βk(a) = βk−1(a) + 𝟙[ ak = a ] · 𝟙[ rk = 0 ].

The algorithm requires no tuning of exploration rates; the Bayesian sampling automatically balances exploration and exploitation. It achieves expected regret that matches the Lai–Robbins lower bound under Bernoulli rewards.

  • αk(a)posterior pseudo‑count of successes (reward 1) for arm a up to step k.
  • βk(a)posterior pseudo‑count of failures (reward 0) for arm a up to step k.
  • θarandom sample from arm a's Beta posterior; represents a plausible expected reward.
  • akarm selected at step k.
  • rkbinary reward observed at step k (0 or 1).
  • Beta(α, β)Beta distribution with shape parameters α and β; mean = α/(α+β).
  • 𝟙[·]indicator function (1 if condition true, else 0).
A13.202

Generalization to Tabular MDPs

The principles of exploration and regret minimisation developed for the multi‑armed bandit (A13.194) extend naturally to tabular Markov Decision Processes (finite S and A). In this setting, each state–action pair (s, a) can be viewed as a distinct bandit, but the learner must also account for the sequential structure: the action chosen influences not only the immediate reward but also the future states and rewards via the transition kernel.

Regret in the MDP setting is typically defined as the expected difference between the cumulative reward of the optimal stationary policy and the cumulative reward of the learning algorithm over a horizon of T steps:

RegretT = T V*(s0) − 𝔼[ ∑t=0T−1 rt ],

where s0 is the initial state.

Algorithms such as UCRL2 (Upper Confidence Reinforcement Learning) extend the optimism‑in‑the‑face‑of‑uncertainty principle. They maintain empirical estimates of the reward and transition probabilities from visit counts:

r̂(s, a) = τ rτ 𝟙[ (sτ, aτ) = (s, a) ]N(s, a) ∨ 1,
p̂(s′ ∣ s, a) = N(s, a, s′)N(s, a) ∨ 1,

and construct confidence intervals around these estimates using concentration inequalities (e.g., Hoeffding or empirical Bernstein). An optimistic MDP is built by solving for the optimal value function within the plausible set of models, and the greedy policy of this optimistic MDP is executed. For a communicating MDP with diameter D, UCRL2 achieves a regret bound of Õ( D S √(A T) ), establishing that optimal regret scaling is possible in tabular MDPs.

Other approaches, such as R‑max, treat state‑action pairs as unknown until they have been visited sufficiently many times, then use a fixed model for planning. Both families illustrate how bandit‑style exploration bonuses (based on visit counts) can be lifted to the full reinforcement learning problem.

  • S, Afinite state and action spaces.
  • Ttime horizon.
  • V*(s)optimal state value function.
  • N(s, a)number of visits to (s, a).
  • N(s, a, s′)number of transitions from (s, a) to s′.
  • r̂, p̂empirical reward and transition estimates.
  • Ddiameter of the MDP (maximum expected time to transition from any state to any other under some policy).
A13.203

Learnable Environment Models

A learnable environment model is an approximate representation of the MDP dynamics, typically consisting of an estimated transition function p̂(s′ ∣ s, a) and an estimated reward function r̂(s, a) (or r̂(s, a, s′)), that is constructed from the agent’s interaction experience. In model‑based reinforcement learning, the agent learns this model from collected data and then uses it for planning or policy improvement, thereby improving sample efficiency by transferring experience across states and actions.

  • p̂(s′ ∣ s, a)learned transition probability (or a generative model) from state s to s′ under action a.
  • r̂(s, a)learned expected immediate reward for state‑action pair (s, a).
  • Model‑based RLalgorithms that explicitly learn and use an environment model (e.g., Dyna‑Q, PETS, MBPO).
A13.204

Plan

For a given initial state s0, a plan is an ordered sequence of actions a0, a1, a2, … to be executed in the environment. The sequence may be finite or infinite, and it is typically designed to achieve a long‑term objective without requiring further observation of the state. Plans are fundamental in model‑based RL and planning algorithms, distinguishing them from reactive policies that condition each action on the current state.

  • s0initial state from which the plan begins.
  • ataction to be executed at time step t (fixed in advance).
  • plansequence of actions, possibly open‑loop, not conditioned on future states.
A13.205

Planning

Planning is the problem of finding a sequence of actions (a plan) that maximises the expected return when the environment dynamics p(s′ ∣ s, a) and the reward function are fully known. The decision is made purely through mental simulation, without any additional interaction with the real environment. Formally,

arg maxa0, a1, a2, … 𝔼T ∣ s0, a0, a1, a2, …[ R(T) ].
  • s0initial state.
  • ataction at time step t (part of the open‑loop plan).
  • p(s′ ∣ s, a)known transition probability.
  • R(T)return (cumulative discounted reward) of trajectory T.
  • 𝔼T ∣ s0, a0, …expectation over trajectories conditioned on the plan and known dynamics.
A13.206

Suboptimality of Planning

Suboptimality of planning refers to the inherent limitation of open‑loop action sequences (plans) in stochastic environments. Because a plan fixes the entire sequence of actions in advance, it cannot adapt to the actual states encountered during execution. In contrast, a closed‑loop policy π(a|s) conditions each action on the current state, thereby exploiting the information gained from stochastic transitions. Consequently, for a stochastic MDP, the optimal expected return achievable by a plan is generally strictly lower than the optimal expected return achievable by a policy. This gap motivates the use of state‑dependent policies in reinforcement learning rather than relying solely on planning.

A13.207

World Model

A world model is any model that, explicitly or implicitly, learns a model of the environment dynamics.

  • world modela learned representation of the transition function p(s′ ∣ s, a) and/or reward function, used to simulate future states and rewards without real environment interaction.
A13.208

General Scheme of the Model‑based Approach

The model‑based reinforcement learning loop alternates between collecting real environment data using the current policy, training a world model (dynamics and possibly reward function) on the accumulated dataset, and then using a planner to improve the policy by simulating inside the learned model.

Hyperparameters: choice of Planner, choice of World Model architecture.

Initialize:

  • policy π0(a ∣ s) (e.g., random).
  • world model (e.g., neural network) with random parameters.
  • dataset D as an empty set.

At the k-th step:

  1. Data collection: interact with the real environment using the current policy πk, and add the observed transitions (s, a, r, s′) to the dataset D.
  2. Model training: perform additional training of the world model on the collected dataset D (e.g., by minimizing a prediction loss).
  3. Policy update: obtain an improved policy πk+1 from the planner, using the current world model for simulation (e.g., by planning or by generating simulated rollouts to train a model‑free algorithm).

The process is repeated; the world model becomes more accurate as more data is gathered, and the planner generates better policies. Famous instantiations include Dyna‑Q, PETS, and MBPO.

  • πkpolicy at iteration k.
  • world modellearned approximation of the environment dynamics p̂(s′ ∣ s, a) and/or reward function (A13.207).
  • planneralgorithm that produces a policy given a world model (e.g., MPC, value iteration on the learned model).
  • Ddataset of transitions collected from the real environment.
A13.209

Forward Dynamics Model

A forward dynamics model is a learned approximation of the environment's transition function. Given a state s and an action a, it predicts the next state s′ (and possibly the reward r). It can be deterministic,

ŝ′ = f(s, a),

or stochastic, where it outputs a distribution over next states,

s′ ∼ p̂(· ∣ s, a).

Such models are trained via supervised learning on transitions (s, a, r, s′) collected from the environment and are core components of model‑based reinforcement learning.

  • fdeterministic dynamics predictor.
  • p̂(s′ ∣ s, a)learned probabilistic transition function.
  • s, acurrent state and action.
  • ŝ′, s′predicted or sampled next state.
A13.210

Dreaming

Dreaming is the process of training an agent on simulated experience generated by a learned approximation of the environment dynamics pθ(s′, r ∣ s, a). The agent uses this imagined data to improve its policy or value function without additional real‑world interaction, often interleaved with real data collection.

  • pθ(s′, r ∣ s, a)learned world model parameterised by θ; predicts next state and reward from current state and action.
  • θparameters of the world model, trained on real environment data.
A13.211

Monte‑Carlo Tree Search (MCTS)

Monte‑Carlo Tree Search (MCTS) is a heuristic search algorithm that builds a search tree by incrementally expanding and evaluating states through random simulations. It is particularly effective in large state spaces where exact dynamic programming is infeasible, such as in the game of Go.

The algorithm iterates four phases from the current root state:

  1. Selection: Starting at the root, recursively select a child node according to a tree policy (typically the Upper Confidence Bound for Trees, UCT) until a non‑terminal leaf node is reached:
    a* = arg maxa [ Q(s, a) + c √( ln N(s)N(s, a) ) ].
  2. Expansion: Unless the state is terminal, add one or more child nodes corresponding to available actions (often a single unexplored action).
  3. Simulation (Rollout): From the new node, simulate a complete episode using a fast default policy (rollout policy) until termination, obtaining a cumulative return.
  4. Backpropagation: Propagate the simulation result back up the tree, updating the visit counts N(s, a), N(s) and the average return Q(s, a) for each node along the path.

After a computational budget (number of iterations or time) is exhausted, the action with the highest average return or the most visits at the root is selected for execution. MCTS is a central component of the AlphaGo/AlphaZero family of algorithms.

  • Q(s, a)mean return of taking action a in state s (estimated from simulations).
  • N(s)number of times state s has been visited.
  • N(s, a)number of times action a was selected in state s.
  • cexploration constant controlling the exploration–exploitation trade‑off (typically √2).
  • rollout policya fast, often stochastic, policy used to generate sequences of actions until a terminal state during simulation.
  • backpropagationprocess of updating the statistics of all visited nodes with the outcome of the simulation.
A13.212

Expansion Step in MCTS

In the expansion step of Monte‑Carlo Tree Search, at the leaf node chosen at the previous stage (selection), we create for each action a ∈ A a new leaf corresponding to the choice of that action: in this way, we expand the tree along the chosen branch “one step forward”.

  • leaf nodethe state node reached by the selection policy that has not yet been fully expanded.
  • Afinite set of actions available at the leaf state.
  • new leafa child node representing the state after taking a specific action (often unvisited with initial statistics).
A13.213

Simulation (Evaluation) Step in MCTS

The simulation (or evaluation) step of Monte‑Carlo Tree Search consists of constructing a heuristic estimate of the reward‑to‑go (the expected cumulative return) for each new leaf node created during the expansion phase. This estimate can be obtained by rolling out a fast default policy until a terminal state and averaging the observed return, or by querying a learned value network V(s). The resulting value is then used in the backpropagation phase to update the statistics of the nodes along the traversed path.

  • leaf nodea newly expanded state node with no recorded visit statistics yet.
  • reward‑to‑gothe future cumulative discounted reward expected from that leaf state onward under some rollout policy or value estimator.
  • default (rollout) policya fast, possibly random, policy used to generate complete episodes from the leaf state.
  • V(s)a learned state‑value function that directly estimates the return from state s (used as a substitute for rollouts in many modern implementations).
A13.214

Update (Backpropagation) Step in MCTS

The update (or backpropagation) step of Monte‑Carlo Tree Search consists of updating the counters and value estimates for all nodes along the path that was traversed during the selection and expansion phases. The Monte‑Carlo estimate obtained at the simulation phase (the return from the leaf) is propagated upward: for each state–action edge on the path, the visit count N(s, a) is incremented by 1, and the cumulative return sum is increased by the observed return, so that the average Q(s, a) can be updated as the running mean. The parent state visit counts N(s) are also incremented accordingly.

  • N(s, a)number of times action a has been selected in state s during the search (incremented).
  • N(s)total number of visits to state s (sum of child visit counts).
  • Q(s, a)estimated mean return of choosing action a in state s, updated via incremental averaging with the new simulation result.
  • backpropagation paththe sequence of state‑action edges from the root to the newly evaluated leaf node.
A13.215

MCTS Strategy (Variation)

This variant of Monte‑Carlo Tree Search performs K iterations of selection, expansion, simulation, and backpropagation to build a search tree from the current real state s0. It maintains per‑arc visit counts n(ℵ, a) and average returns Q(ℵ, a). After K iterations, a stochastic policy is derived from the root visit counts, often using a temperature T to control the sharpness of the distribution.

Input:

  • s0 – current state of the real environment.
  • p(s′, r ∣ s, a) – simulator (known dynamics and reward).
  • C – UCT exploration constant (bandit hyperparameter).
  • 0 – root node of the current tree, storing per‑action counters n(ℵ, a) and value estimates Q(ℵ, a).
  • K – number of search iterations.
  • T – temperature parameter for the output policy.

Algorithm:

  1. Initialize the root node 0; all counters n(ℵ, a) and values Q(ℵ, a) are zero (or appropriate prior).
  2. For k = 1, …, K do
    1. Set current node ℵ = ℵ0 and current state s = s0.
    2. Initialize trajectory T as a list containing only s0.
    3. While is not a leaf (has previously expanded children):
      • Compute total visits at node : n(ℵ) = ∑a n(ℵ, a).
      • Select action a using UCT:
        a = arg maxa [ Q(ℵ, a) + C √( ln n(ℵ)n(ℵ, a) ) ].
      • Sample s′, r ∼ p(s′, r ∣ s, a) from the simulator.
      • Append (a, r, s′) to trajectory T.
      • Move to child: ℵ ← child(ℵ, a), s ← s′.
    4. Expansion: for each action a ∈ A:
      • Create a new leaf node ℵ̂ as a child of via action a.
      • Simulate a rollout using a random policy πrandom from state s after action a: Ta ∼ πrandom ∣ s, a.
      • Initialize counters: n(ℵ̂, a) = 1, Q(ℵ̂, a) = R(Ta) (the return of the rollout).
    5. Backpropagation: for each visited arc (ℵ, a) along the path (including the newly created leaf and its parent arc):
      • Compute the total return from this arc onward. After reaching the leaf, the future reward is estimated as the average of the rollout returns from the new leaves: (1/|A|) ∑a R(Ta). The return is the sum of rewards collected in T after this arc plus the discounted leaf estimate.
      • Update the Q‑value using incremental averaging:
        Q(ℵ, a) ← Q(ℵ, a) + 1n(ℵ, a) ( V̂ − Q(ℵ, a) ).
      • Increment the visit count: n(ℵ, a) ← n(ℵ, a) + 1.
  3. Output: a policy for the real environment at state s0, proportional to the (possibly tempered) visit counts at the root:
    π(a ∣ s0) ∝ n(ℵ0, a)1/T   (or n(ℵ0, a)T depending on convention; typically a larger T makes the distribution more uniform).
  • a node in the search tree representing a state (or state‑action pair).
  • 0root node corresponding to the current real state s0.
  • n(ℵ)total number of visits to node (sum of n(ℵ, a)).
  • n(ℵ, a)number of times action a was selected in the state represented by node .
  • Q(ℵ, a)estimated mean return (Q‑value) for taking action a from the state of node .
  • CUCT exploration constant controlling the balance between exploration and exploitation.
  • Ttemperature parameter for the output policy; T → 0 gives a greedy policy, T → ∞ a uniform one.
  • Knumber of search iterations (rollouts) per move.
  • Tasimulated trajectory starting with action a under the random rollout policy.
  • R(·)cumulative discounted return of a trajectory.
  • πrandoma fast, possibly uniform random, default policy used for rollouts.
A13.216

Distillation of MCTS

Distillation of MCTS is the process of training a fast parametric policy πθ(a|s) (typically a neural network) to imitate the decision‑making of a computationally intensive Monte‑Carlo Tree Search. The MCTS is executed many times from a variety of states, and its output distribution over actions (often derived from the root visit counts with temperature τ) serves as a target for supervised learning. The cross‑entropy loss minimises the difference between the distilled policy and the MCTS policy, condensing the search effort into a single feed‑forward network that can be evaluated efficiently at deployment time.

L(θ) = − 𝔼s[ ∑a πMCTS(a ∣ s) log πθ(a ∣ s) ],

where πMCTS(a|s) ∝ N(s, a)1/τ is derived from the visit counts at the root node of the search tree. This technique is a crucial component of the AlphaGo Zero and AlphaZero frameworks, enabling strong performance without relying on rollouts during actual play.

  • πMCTS(a ∣ s)target policy obtained from MCTS, proportional to (possibly tempered) root visit counts.
  • πθ(a ∣ s)distilled parametric policy (e.g., a neural network) trained to approximate πMCTS.
  • θparameters of the distilled policy network.
  • τtemperature used to flatten or sharpen the visit‑count distribution before distillation.
  • L(θ)cross‑entropy loss function for distillation.
A13.217

AlphaZero Algorithm

AlphaZero is a model‑based reinforcement learning algorithm that masters two‑player zero‑sum games with perfect information, such as chess, Go, and shogi. It maintains a deep neural network fθ with two heads: a policy πθ(a ∣ s) and a value vθ(s). At each move, the network is used inside a Monte‑Carlo Tree Search (MCTS) to guide simulations and evaluate states without any rollout policy. After the game finishes, the network is trained to predict both the MCTS‑computed policy (distillation) and the final game outcome (value learning). The process runs on self‑play and iteratively improves performance.7

Algorithm (AlphaZero, one iteration of self‑play and training):

  • Hyperparameters: number of MCTS simulations Nsim, number of self‑play games Ngames, replay buffer capacity, training epochs, mini‑batch size B, learning rate η, momentum, weight decay, temperature τ for exploration.

Initialization: neural network fθ with random parameters θ; empty replay buffer D.

For each iteration:

  1. Self‑play:
    • For each of Ngames games, play a complete game between the current player (using the latest fθ) and either a previous version or itself (both sides use the same network).
    • At each position s, run MCTS for Nsim simulations using the network to produce prior probabilities πθ(a∣s) and state evaluations vθ(s) at the leaf nodes.
    • MCTS returns a vector of action probabilities pMCTS(a∣s) derived from the root visit counts with temperature τ; an action is sampled from this distribution and executed.
    • Store the triplet (s, pMCTS, z) in the replay buffer D, where z ∈ {−1, +1} is the final game outcome from the perspective of the current player.
  2. Training:
    • Sample mini‑batches of B positions from the buffer.
    • Compute the combined loss:
      L(θ) = − pMCTS · log πθ(a∣s) − ( z − vθ(s) )2 + c ∥θ∥2,
      which is the cross‑entropy policy distillation loss plus the mean squared value error, with L2 weight regularization.
    • Update the network parameters θ by mini‑batch gradient descent on L(θ).
  3. Update: After a fixed number of training steps, the current network becomes the opponent for future self‑play iterations, and the loop repeats.
  • fθdeep neural network with parameters θ, outputting policy logits πθ(a∣s) and scalar value vθ(s).
  • πθ(a ∣ s)policy head: probability distribution over legal actions in state s.
  • vθ(s)value head: predicted game outcome from state s (range usually [−1, 1]).
  • pMCTS(a ∣ s)improved policy from MCTS, target for policy distillation.
  • zfinal game result (e.g., +1 for win, −1 for loss, or 0 for draw).
  • Nsimnumber of MCTS simulations per move.
  • τtemperature controlling the sharpness of MCTS policy (annealed over moves).
A13.218

MuZero

MuZero is a model‑based reinforcement learning algorithm that learns a model of the environment dynamics solely from observations, without access to a perfect simulator or knowledge of the game rules. It extends the AlphaZero framework by predicting, for a given state s and action a, three quantities: a policy π(a ∣ s), a value v(s), and a latent representation and dynamics that are used for planning via Monte‑Carlo Tree Search (MCTS).

The core of MuZero consists of three learned functions:

  • Representation function hθ(s) = s0 — maps raw observations into a latent state.
  • Dynamics function gθ(sk, ak) = (sk+1, rk) — predicts the next latent state and immediate reward from a latent state and action.
  • Prediction function fθ(sk) = (πk, vk) — predicts the policy and value for a latent state.

During MCTS, the learned dynamics and prediction are rolled forward inside the search tree, generating imaginary trajectories. The search produces an improved policy target pMCTS and a value target z (from the final game outcome or n‑step bootstrapped value). The loss is a combination of policy cross‑entropy, value mean squared error, and reward prediction error, summed over multiple unrolled steps:

L(θ) = ∑k=0K [ − pMCTSk · log πk + ( zk − vk )2 + ( rk − uk )2 ] + c ∥θ∥2,

where rk is the actually observed (or bootstrapped) reward. MuZero achieves state‑of‑the‑art results in Atari games and board games, learning the environment dynamics implicitly without explicit reconstruction of observations.

  • hθrepresentation function mapping observation s to latent state s0.
  • gθdynamics function: (sk+1, rk) = gθ(sk, ak).
  • fθprediction function: (πk, vk) = fθ(sk).
  • Knumber of unrolled dynamics steps used for training.
  • pMCTSkimproved policy target from MCTS at step k.
  • zkvalue target (n‑step return or final outcome).
  • ukobserved reward at step k (from real or reanalyzed data).
A13.219

Planning for Continuous Control – Direct Differentiation

In model‑based reinforcement learning with continuous actions, direct differentiation refers to the technique of computing the gradient of the expected return with respect to the policy parameters by backpropagating through the differentiable dynamics model. A learned (or given) forward model f(s, a) predicts the next state, and a reward function r(s, a) provides immediate rewards. The policy πθ(a|s) is unrolled for H steps using the model, forming a differentiable computational graph. The gradient θ J(θ) is then obtained by automatic differentiation through the entire trajectory, treating the model as a fixed differentiable block.

J(θ) = 𝔼s0[ ∑t=0H−1 γt r(st, at) ]
with   st+1 = f(st, at),  at ∼ πθ(·∣st).

The gradient θ J(θ) is computed by summing the contributions through time, using the chain rule through the model, policy sampling (often via the reparameterization trick), and reward functions. This approach is employed in algorithms such as PILCO (for Gaussian process models) and Dreamer (for learned latent dynamics). The key advantage is that it avoids the compounding error of sampling‑based planning; the disadvantage is the requirement of a differentiable model and the high variance of gradients in long horizons.

  • πθ(a∣s)parameterised stochastic policy (e.g., Gaussian with mean and variance).
  • f(s, a)differentiable forward dynamics model (e.g., neural network).
  • r(s, a)reward function (known or learned).
  • γdiscount factor.
  • Hplanning horizon (number of unrolled steps).
  • θ J(θ)policy gradient obtained via backpropagation through time (BPTT) through the model.
A13.220

Linear Quadratic Regulator (LQR)

Linear Quadratic Regulator (LQR) is a classical optimal control method for linear dynamical systems with a quadratic cost function. In its standard discrete‑time, infinite‑horizon formulation, the dynamics and cost are given by

xt+1 = A xt + B ut,
J(u) = ∑t=0 ( xtT Q xt + utT R ut ),

where xt ∈ ℝn is the state, ut ∈ ℝm is the control (action), Q ≽ 0 and R ≻ 0 are weight matrices, and (A, B) is assumed stabilisable. The objective is to minimise the total cost. The optimal policy is a linear feedback law

ut = −K xt,

where the constant gain matrix K is obtained by solving the discrete algebraic Riccati equation (DARE)

P = AT P A − AT P B (R + BT P B)−1 BT P A + Q,
K = (R + BT P B)−1 BT P A.

LQR assumes a known model and is a cornerstone of model‑based control, often used as a local approximation in iterative algorithms like iLQR for nonlinear systems.

  • xt, utstate and control (action) vectors at time t.
  • A, Bdynamics matrices: n×n and n×m.
  • Q, Rpositive semidefinite state cost matrix (n×n) and positive definite control cost matrix (m×m).
  • Psolution of the discrete algebraic Riccati equation (cost‑to‑go matrix).
  • Koptimal linear feedback gain matrix.
  • J(u)cumulative quadratic cost to be minimised.
A13.221

LQR – Quadratic Value Functions and Linear Policies

In the finite‑horizon Linear Quadratic Regulator (LQR) with dynamics xt+1 = A xt + B ut and cost ∑ (xtT Q xt + utT R ut), the optimal action‑value function Qt*(x, u) at each time step is a quadratic form in the state‑action pair, and the optimal policy is linear in the state.

Property (by backward induction):

  • Optimal action at the last time moment T: uT* = −KT xT is a linear function of the state xT.
  • Optimal state‑action value functions: For every t, the optimal Qt*(x, u) is a quadratic form in the stacked vector [x; u].
  • Optimal actions: For every t, the optimal action ut* is a linear function of the current state: ut* = −Kt xt.

Proof sketch (backward induction). At the final time step T, the cost‑to‑go is zero (or given by a terminal cost matrix Qf). The Q‑function at time T is QT*(x,u) = xT Q x + uT R u, which is quadratic in [x; u]. Minimising with respect to u yields the linear policy u* = −R−1 BT (…), which becomes linear after substituting the Riccati equation.

Assume that at time t+1 the value function Vt+1*(x) = xT Pt+1 x (quadratic). Then the state‑action value at time t is

Qt*(x,u) = xT Q x + uT R u + (A x + B u)T Pt+1 (A x + B u).

Expanding this expression gives a quadratic form in [x; u]. Taking the derivative with respect to u and setting to zero gives a linear relation u* = −Kt x, and substituting back yields a quadratic state‑value function Vt*(x), completing the induction. ∎

  • xt, utstate and control (action) vectors at time t.
  • Qt*(x,u)optimal action‑value function at time t.
  • Vt*(x)optimal state‑value function at time t.
  • Ktoptimal feedback gain matrix at time t.
  • Ptcost‑to‑go matrix (Riccati matrix) at time t.
A13.222

Backward Pass in LQR

The backward pass in LQR solves the finite‑horizon linear‑quadratic optimal control problem by dynamic programming. Given a time‑varying linear dynamics model and a quadratic cost, it recursively computes the optimal action‑value function Qt, the optimal linear policy πt(s) = Kt s + kt, and the value function Vt from the terminal time horizon down to the initial step.

Input:

  • Dynamics: for each t, linear approximation given by matrix Ft and vector ft, so that st+1 ≈ Ft st + ft at (here at is the action; depending on convention, the term may be Ft st + Bt at, but the notation uses Ft+1, ft+1 as the linear parameters of the dynamics at the next step).
  • Reward (cost) function: at time t, quadratic approximation given by matrix Rt and vector rt such that the instantaneous cost is c(s,a) = sT Rt,ss s + aT Rt,aa a + 2 sT Rt,sa a + …. The notation Rt and rt summarises the quadratic and linear coefficients.

Algorithm:

  1. Initialize the terminal value function: VT+1 = 0|S|×|S|, vT+1 = 0|S|.
  2. For t = T down to 1:
    1. Compute the quadratic coefficients of the Q‑function at time t by combining the instantaneous cost and the future value:
      Qt = Rt + Ft+1T Vt+1 Ft+1,
      qt = rt + Ft+1T Vt+1 ft+1 + Ft+1T vt+1.
      (Here Qt is a matrix representing the quadratic part of Qt(s,a), and qt the linear part.)
    2. Extract the sub‑blocks of Qt and qt related to actions and states: Qt,aa, Qt,as, Qt,sa, Qt,ss, qt,a, etc. Compute the optimal linear policy coefficients:
      Kt = − Qt,aa−1 Qt,as,
      kt = − Qt,aa−1 qt,a.
      The optimal action at time t is at* = Kt s + kt.
    3. Compute the updated value function Vt and vt by substituting the optimal policy back into the Q‑function:
      Vt = Qt,ss + KtT Qt,aa Kt + KtT Qt,as + Qt,sa Kt,
      vt = qt,s + Qt,sa kt + KtT qt,a + KtT Qt,aa kt.
      (Some terms may be simplified; the provided expressions are as in the input.)
  3. Output: the sequence of optimal linear policies πt(s) = Kt s + kt for t = 1, …, T, and the optimal value function V1, v1.

The backward pass is the core of the iterative Linear‑Quadratic Regulator (iLQR) algorithm when applied to locally linear approximations of nonlinear dynamics and quadratic approximations of the cost around a nominal trajectory.

  • Ft, ftlinear dynamics parameters: state transition matrix and affine term at time t (or for step t).
  • Rt, rtquadratic cost matrix and linear cost vector at time t.
  • Qt, qtquadratic and linear coefficients of the state‑action value function at time t.
  • Kt, ktoptimal policy coefficients: gain matrix and affine term (at* = Kt s + kt).
  • Vt, vtvalue function coefficients: quadratic matrix and linear vector for state value at time t.
  • Ttime horizon (number of steps).
A13.223

Forward Pass in LQR

The forward pass in LQR takes the sequence of optimal linear policies computed during the backward pass (A13.222) and applies them to the actual (or simulated) environment to produce a trajectory (plan) of states and actions. This rollout simulates the system under the optimal feedback law.

Input:

  • Kt, kt — policy parameters from the backward pass (t = 1, …, T).
  • f — dynamics function (exact or approximated) such that st+1 = f(st, at).
  • Initial state s1.

Algorithm:

  1. For t = 1, 2, …, T:
    1. Compute the action according to the optimal policy:
      at = Kt st + kt.
    2. Apply the action to obtain the next state:
      st+1 = f( st, at ).
  2. Output: the sequence of actions a1, a2, …, aT (the plan) and the corresponding states s1, …, sT+1.
  • ststate at time t (vector).
  • atoptimal action at time t (vector).
  • Ktfeedback gain matrix at time t.
  • ktaffine term (open‑loop component) of the optimal policy.
  • fdeterministic dynamics function (possibly nonlinear, but the policy is linear).
  • Ttime horizon.
A13.224

Noisy Transition in LQR

Claim. Under the standard assumption that the noise in the transition is additive, zero‑mean, and independent of the state and action (assumption (7.9)), the optimal linear‑quadratic regulator (LQR) scheme remains unchanged from the deterministic case. The backward pass that computes the optimal policy Kt, kt is identical, and the optimal action at* = Kt st + kt is still linear in the current state.

Reason. Let the noisy dynamics be st+1 = f(st, at) + εt, with 𝔼[εt] = 0 and εt independent of the history. The expected quadratic cost becomes

J = 𝔼[ ∑t ( stT Q st + atT R at ) ].

Because of the linear‑quadratic structure and the independence of the noise, the optimal value function remains quadratic, Vt*(s) = sT Pt s + constant. The additive constant is irrelevant for the minimisation over actions, and the Riccati equation for Pt is unchanged. Consequently, the feedback gain Kt and the affine term kt derived in the backward pass (A13.222) are exactly the same as in the noiseless case. The noise only increases the total expected cost by a constant that does not depend on the policy.

Thus, the LQR algorithm (both backward and forward passes) applies without modification to systems with additive process noise, a property known as certainty equivalence for linear systems with quadratic costs.

  • εtzero‑mean random noise vector added to the dynamics at time t.
  • Ptcost‑to‑go matrix (solution of Riccati equation), unchanged by noise.
  • constantadded cost due to noise variance, independent of actions.
A13.225

Iterative LQR (iLQR)

Iterative LQR (iLQR) extends the linear quadratic regulator to general nonlinear dynamics and non‑quadratic cost functions. It iteratively linearizes the dynamics and quadratically approximates the cost around a nominal trajectory, solves the resulting LQR subproblem to obtain a locally optimal linear policy, and then applies a line search along the generated trajectory to guarantee improvement.

Typical algorithm (iLQR):

  1. Initialize a nominal trajectory of states and actions (s̄1, ā1, …, s̄T, āT) (e.g., via random or a previous plan).
  2. Repeat:
    1. Linearize dynamics along the nominal: for each t, compute Jacobians Ft = ∇s f(s̄t, āt), Bt = ∇a f(s̄t, āt) (or in previous notation, Ft+1, ft+1 representing st+1 ≈ Ft st + Bt at + …).
    2. Approximate cost quadratically: expand the instantaneous cost c(s,a) to second order around the nominal, yielding matrices Qt,ss, Qt,aa, Qt,sa and vectors qt,s, qt,a.
    3. Run the LQR backward pass (A13.222) with these linearized dynamics and quadratic costs to obtain a sequence of optimal policy gains Kt and affine terms kt.
    4. Forward pass with line search: Starting from the initial state s1, simulate the new policy at = āt + Kt (st − s̄t) + α kt for a sequence of step sizes α ∈ (0,1]. Choose the largest α that decreases the total cost (or satisfies a sufficient decrease condition).
    5. If cost improves, update the nominal trajectory to the new one and continue; else stop or reduce α further.

iLQR is widely used in trajectory optimization and model‑based reinforcement learning for continuous control, as it efficiently handles complex dynamics while providing local convergence guarantees.

  • t, ātnominal state and action at time t around which linearization is performed.
  • Ft, BtJacobians of the dynamics with respect to state and action at the nominal point.
  • Kt, ktoptimal feedback gain and affine term from the LQR backward pass.
  • αstep size used in the forward pass line search (0 < α ≤ 1).
A13.226

Imitation Learning

Imitation learning (or learning from demonstration) is a paradigm where an agent learns a policy by mimicking a set of expert demonstrations rather than by maximising a reward signal through trial and error. The goal is to reproduce the expert's behaviour, often measured by the divergence between the learned policy and the expert policy or by the expected return relative to the expert.

Two major families of algorithms exist:

  • Behavioural cloning (BC): treats the problem as supervised learning over state‑action pairs from the expert, minimising a loss such as cross‑entropy for discrete actions or mean squared error for continuous actions. BC can suffer from compounding errors (distributional shift) because the agent may encounter states not present in the expert dataset.
  • Inverse reinforcement learning (IRL) and apprenticeship learning: infer a reward function under which the expert is optimal, then use RL to train a policy on that recovered reward. Modern approaches include adversarial imitation learning (e.g., GAIL), which frames the problem as a distribution matching game between the agent's and expert's state‑action occupancy measures, trained with a discriminator.
  • πEexpert policy (unknown, only demonstrations are available).
  • πθlearned policy (parameterised by θ).
  • D = { (si, ai) }dataset of expert state‑action pairs.
  • BC losssupervised loss (e.g., −log πθ(ai|si)).
  • IRLinverse reinforcement learning, recovers reward r(s,a) from demonstrations.
  • GAILgenerative adversarial imitation learning, a popular adversarial method.
A13.227

Behavioral Cloning

Behavioral cloning (BC) is an imitation learning technique that reduces policy learning to supervised learning. Given a dataset of expert demonstrations consisting of state‑action pairs D = { (si, ai) }, a parameterised policy πθ is trained to minimise a loss function that measures the discrepancy between the expert's actions and the policy's predictions. For continuous actions, the mean squared error is common; for discrete actions, the cross‑entropy loss is typical:

L(θ) = − 𝔼(s,a) ∼ D[ log πθ(a ∣ s) ].

BC is straightforward and often effective when the expert dataset is large and covers the state distribution well. However, it can suffer from compounding errors when the agent deviates from the expert's trajectory distribution during deployment.

  • Ddataset of expert state‑action pairs: {(si, ai)}.
  • πθ(a ∣ s)learned policy parameterised by θ.
  • L(θ)loss function (e.g., negative log‑likelihood for discrete actions).
A13.228

Inverse Reinforcement Learning (IRL)

The inverse reinforcement learning (inverse RL, IRL) problem consists of recovering, from a set of trajectories T generated by an optimal agent, the reward function r(s, a) that the agent is maximising. Instead of finding the optimal policy for a given reward, IRL aims to infer the underlying objective that explains the observed behaviour.

  • Tset of trajectories (sequences of states, actions, and optionally rewards) demonstrated by the expert.
  • r(s, a)unknown reward function to be recovered; often assumed to be a linear combination of features or a neural network.
A13.229

Guided Cost Learning

Guided Cost Learning is an inverse reinforcement learning algorithm that jointly learns a parametric reward function rψ(s,a) and a policy πθ(a|s) optimized for that reward. It alternates between updating the reward to make expert demonstrations appear high‑reward relative to the current policy’s trajectories, and updating the policy to match the reward distribution, using importance sampling to correct for distribution shift.

The reward parameters ψ are trained by maximizing the log‑likelihood of expert trajectories under a maximum entropy model, or equivalently by minimizing the loss

L(ψ) = − 𝔼τ ∼ Dexpert[ Σt rψ(st, at) ] + log Zψ,

where Zψ = ∫ exp( Σt rψ(st, at) ) dτ is the partition function. The gradient is estimated as

ψ L(ψ) = 𝔼τ ∼ Dexpert[ Σtψ rψ(st, at) ] − 𝔼τ ∼ πθ[ Σtψ rψ(st, at) ],

with the policy πθ trained via reinforcement learning on the current reward. Importance weights are often used to re‑weight samples from older policies, hence the term “guided”.

  • rψ(s, a)parameterised reward function with parameters ψ.
  • πθ(a ∣ s)policy parameterised by θ, optimised with respect to rψ.
  • Dexpertset of expert demonstration trajectories.
  • Zψpartition function (intractable integral over all trajectories).
  • 𝔼τ ∼ πθexpectation over trajectories generated by the current policy.
A13.230

Guided Cost Learning – Gradient

In Guided Cost Learning, the likelihood of the expert's trajectories under a maximum‑entropy model is maximised to recover the reward function. The gradient of the log‑likelihood with respect to the reward parameters ψ takes the simple form of a contrast between the expert and the learned policy:

ψ L(ψ) = 𝔼T ∼ πE[ ∇ψ Rψ(T) ] − 𝔼T ∼ πθ[ ∇ψ Rψ(T) ].

Here πE denotes the expert policy from which demonstrations are drawn, πθ is the current policy trained to maximize the reward Rψ, and Rψ(T) is the total cumulative (undiscounted or entropy‑regularised) reward of a trajectory. The gradient increases the reward of expert trajectories and decreases the reward of the agent's own trajectories, thereby steering the policy toward expert behaviour.

  • L(ψ)log‑likelihood of expert demonstrations under the maximum‑entropy model.
  • ψparameters of the reward function rψ(s, a).
  • πEexpert policy (demonstrations).
  • πθlearned policy parameterised by θ, optimal under the current reward rψ.
  • Rψ(T)total return of trajectory T under the reward function rψ (often sum of rewards).
  • ψ Rψ(T)gradient of the trajectory return with respect to the reward parameters.
A13.231

Generative Adversarial Imitation Learning (GAIL)

Generative Adversarial Imitation Learning (GAIL) is an adversarial framework for imitation learning. It trains a policy πθ (the generator) to mimic expert demonstrations by competing against a discriminator Dω(s, a) that learns to distinguish between expert state‑action pairs and those generated by the policy. The policy is optimized using on‑policy reinforcement learning with a reward signal derived from the discriminator, while the discriminator is trained to classify the origin of a sample. This formulation avoids the compounding error of behavioral cloning and does not require explicit reward engineering.

The optimization problem is a minimax game:

minθ maxω   𝔼(s,a) ∼ πE[ log Dω(s, a) ] + 𝔼(s,a) ∼ πθ[ log(1 − Dω(s, a)) ] − λ H(πθ),

where πE is the expert policy (from demonstrations), Dω(s, a) ∈ (0,1) is the discriminator output, H(πθ) is an optional policy entropy term, and λ is a hyperparameter. The policy is typically updated via trust‑region methods (e.g., TRPO) using a surrogate reward rt = −log(1 − Dω(st, at)) (or log Dω for some variants). Under mild assumptions, GAIL recovers the expert's occupancy measure and achieves superior sample efficiency compared to behavior cloning.

  • πθlearned policy (generator) with parameters θ.
  • πEexpert policy providing demonstration trajectories.
  • Dω(s, a)discriminator with parameters ω; estimates the probability that (s,a) comes from the expert.
  • λentropy regularization coefficient (optional).
  • H(πθ)policy entropy, encourages exploration.
A13.232

Derivation of GAIL Objective from Regularized IRL

Claim. Consider the inverse reinforcement learning problem with entropy‑regularized policy and the particular reward regularizer

ψ(r) = 𝔼ρπ*[ log(1 − e−r(s,a)) ],

where the penalty is taken to be infinite if r(s,a) ≤ 0. Then the IRL objective (8.15)

maxr ( minπ 𝔼ρπ[−r(s,a)] − H(π) ) + 𝔼ρπ*[ r(s,a) ] − ψ(r)

simplifies to the adversarial minimax problem

minD maxπ − 𝔼ρπ*[ log(1 − D(s,a)) ] − 𝔼ρπ[ log D(s,a) ] + H̃(ρπ),

where D(s,a) ∈ (0,1) is a discriminator that distinguishes between expert and policy state‑action pairs.

Proof. Let ρπ(s,a) be the discounted state‑action occupancy measure of policy π. The maximum‑entropy IRL objective is

L(r) = − minπ ( 𝔼ρπ[−r(s,a)] − H(π) ) + 𝔼ρπ*[ r(s,a) ] − ψ(r).

For a fixed reward, the inner minimization over π is the entropy‑regularized RL problem, whose optimal state‑action occupancy satisfies

ρπr(s,a) = exp( r(s,a) )Z(r),

up to a normalizing partition function Z(r) that depends on the transition dynamics. However, for a general occupancy, the solution yields the optimal reward as a function of the occupancy: rρ(s,a) = log ρ(s,a) + C, where C is a constant (or state‑dependent but not relevant). However, the regularizer ψ allows a closed‑form solution.

We can instead proceed by pointwise optimization over r(s,a). The objective L(r), using the fact that the minimum over π is achieved by the policy whose occupancy satisfies r(s,a) = log ρ(s,a) − log(…), but a more direct approach is to consider the dual formulation. By the Fenchel conjugate, the regularizer ψ(r) is chosen such that the overall objective transforms. As shown in Finn et al. (2016) and Ho & Ermon (2016), with ψ(r) = 𝔼ρπ*[ g(r) ] where g(r) = log(1 − e−r) for r>0 and otherwise, the conjugate of g(r) is g*(t) = −t log t − (1−t) log(1−t) for t ∈ (0,1).

We can rewrite the IRL objective as a saddle point. Let us define the discriminator output D(s,a) = er(s,a) / (1 + er(s,a)), or equivalently r(s,a) = log D(s,a) − log(1 − D(s,a)). The regularizer then becomes

ψ(r) = 𝔼ρπ*[ log(1 − e−r) ] = 𝔼ρπ*[ log(1 − D(s,a)) ].

Substituting into the objective and adding the entropy of the occupancy (or policy entropy) yields the expression

− 𝔼ρπ*[ log(1 − D) ] − 𝔼ρπ[ log D ] + H̃(ρπ).

The term H̃(ρπ) is related to the entropy of the policy (or the causal entropy). The resulting optimization is a min over discriminator D and a max over policy π, which is the Generative Adversarial Imitation Learning (GAIL) objective. ∎

  • ψ(r)regularizer penalizing reward functions that are too large or negative.
  • ρπ*expert state‑action occupancy measure (distribution induced by the expert policy).
  • ρπstate‑action occupancy measure of the learned policy π.
  • D(s, a)discriminator output: probability that (s,a) comes from expert.
  • H̃(ρπ)entropy term (causal entropy) of the occupancy, corresponding to policy entropy.
A13.233

Generative Adversarial Imitation from Observation (GAIfO)

Generative Adversarial Imitation from Observation (GAIfO) extends adversarial imitation learning to settings where the expert’s actions are unavailable; only sequences of observed states (without actions) are provided. The algorithm learns a policy by matching the distribution of state transitions produced by the agent to that of the expert, using a discriminator that distinguishes between expert state transitions (s, s′) and policy-generated transitions. The policy is trained to fool this discriminator, analogous to GAIL but using state‑only information.

  • πθlearned policy parameterised by θ.
  • Dω(s, s′)discriminator with parameters ω, classifying whether a state transition (s,s′) comes from expert or agent.
  • Expert dataset of expert state trajectories (no actions).
A13.234

Intrinsic Motivation

Intrinsic motivation in reinforcement learning refers to a family of techniques that generate internal reward signals to encourage exploration, novelty seeking, or skill acquisition, independent of the extrinsic task reward. A common example is the curiosity‑driven exploration bonus, where the intrinsic reward is proportional to the prediction error of a learned dynamics model.

rtint = ‖ f̂(st+1) − st+12,

where is a learned forward model. The total reward is then rt = rtext + β rtint, with β controlling the exploration–exploitation trade‑off.

  • rtintintrinsic reward at time t.
  • rtextextrinsic (task) reward.
  • βweighting coefficient balancing intrinsic and extrinsic rewards.
  • learned dynamics model predicting next state features.
A13.236

Search Problem and Auxiliary Task

A search problem is a special case of an MDP where the reward function is defined solely by reaching a set of terminal states. Formally,

r(s, a) = +1 const if s ∈ S+, otherwise (s ∉ S+),

where S+ is a designated set of terminal (goal) states, and const ≤ 0 is a penalty for each non‑terminal step, encouraging the agent to find a path to a goal as quickly as possible.

For a given environment (S, A, P), an auxiliary task is a reinforcement learning problem defined on the same transition dynamics but with an intrinsic reward function rintr(s, a) that is defined by the agent itself. That is, an auxiliary task corresponds to the MDP

(S, A, P, rintr),

where rintr is an intrinsic motivation signal, designed by the agent (or the algorithm) to encourage exploration, curiosity, or the acquisition of useful representations, independent of the external task reward.

  • S+set of terminal (goal) states in a search problem; arriving there yields +1 reward.
  • constconstant penalty (≤ 0) for each step that does not reach a goal; represents the cost of time.
  • r(s, a)reward function for the search problem (sparse, goal‑dependent).
  • rintr(s, a)intrinsic reward function, defined by the agent, used to form an auxiliary task.
  • (S, A, P, rintr)auxiliary MDP that shares the environment dynamics but uses the intrinsic reward.
A13.237

Procrastination Problem

The procrastination problem in reinforcement learning with intrinsic motivation occurs when, in some region of the environment, the intrinsic reward produces a high (and non‑decaying) signal that overpowers the agent’s extrinsic reward or other intrinsic objectives, causing the agent to remain in that region instead of making progress on the actual task.

  • intrinsic rewardinternally generated reward signal meant to encourage exploration or curiosity (A13.234).
  • extrinsic rewardtask‑defined reward from the environment.
A13.238

Exploration Bonuses

Exploration bonuses are supplementary rewards added to the environment’s true reward to encourage the agent to visit unfamiliar states. A classic form is the count‑based bonus, which gives a higher reward to states that have been visited less frequently. The total reward at time t becomes

rt+ = rt + β / √( N(st) )  (or similar decreasing function of visit count),

where rt is the extrinsic reward, N(s) is the number of visits to state s, and β is a weighting coefficient. In high‑dimensional spaces, pseudo‑counts derived from density models are used.

  • rt+augmented reward (extrinsic + exploration bonus).
  • rtextrinsic reward from the environment.
  • N(s)visit count (or pseudo‑count) for state s.
  • βweight of the exploration bonus.
A13.239

Hash‑Based and Novelty Bonuses

Two common intrinsic reward schemes that use a state‑visitation oracle or hash to encourage exploration are:

  • Non‑stationary hash‑based bonus: Let h(s) : S → {0, 1, …, N} be a hash function (oracle) mapping states to a finite set of bins, and let n(i) be the number of times a state with hash i has been encountered over the whole training. The intrinsic reward is then
    rintr(s, a) = 1√( n( h(s) ) ).
    As a state is visited more often, its bonus decreases, driving the agent to visit less‑frequented hash bins.
  • Novelty (first‑visit) bonus: The agent receives a reward of +1 the first time it enters a state, and zero thereafter:
    rintr(st, at) = 𝟙[ ∀ t′ < t : st ≠ st′ ],
    where 𝟙[·] is the indicator function. This gives a pure incentive to discover new states.
  • h(s)hash function mapping a state to an integer bin (oracle).
  • n(i)global counter of visits to all states with hash value i.
  • rintr(s, a)intrinsic reward added to the extrinsic reward to guide exploration.
  • 𝟙[·]indicator function (1 if condition is true, else 0).
A13.240

Random Network Distillation (RND)

Random Network Distillation (RND) is an exploration method that generates an intrinsic reward based on the novelty of a state. It uses two neural networks: a target network fθ̄ : S → ℝk with fixed, randomly initialized parameters, and a predictor network θ : S → ℝk trained to predict the output of the target network on the states visited by the agent. The intrinsic reward for visiting state st is the prediction error:

rtintr = ‖ f̂θ(st) − fθ̄(st) ‖2.

The target network acts as a fixed random distillation column; states that are similar to those frequently seen will have a low error (the predictor has learned them), while novel states yield a large error and thus higher intrinsic reward. The total reward is rttotal = rtext + β rtintr, where β controls the exploration–exploitation balance.

  • fθ̄fixed randomly‑initialized target network (never trained).
  • θpredictor network trained to mimic fθ̄ on observed states.
  • rtintrintrinsic reward; high when the predictor fails to match the target (novel state).
  • βweighting coefficient for the intrinsic reward.
A13.241

Curiosity

Curiosity is a form of intrinsic motivation where the agent generates an internal reward signal proportional to the error in predicting the consequences of its actions. A common formulation uses a learned forward dynamics model f̂(st, at) that predicts a feature representation of the next state ϕ(st+1). The intrinsic curiosity reward at time t is then the prediction error:

rtintr = ‖ f̂( st, at ) − ϕ( st+1 ) ‖2.

The feature mapping ϕ is often learned via an inverse dynamics model or self‑supervised learning to filter out uncontrollable aspects of the environment. Curiosity encourages the agent to seek states where its predictive model is still inaccurate, i.e., unfamiliar regions of the environment.

  • f̂(s, a)learned forward dynamics predictor (predicts next‑state features).
  • ϕ(s)feature representation of a state (e.g., output of a neural network encoder).
  • rtintrintrinsic curiosity reward; high prediction error implies novelty.
A13.242

Inverse Dynamics Model

An inverse dynamics model is a learned function that, given two consecutive states s and s′, predicts the action a that was taken to transition from s to s′. It is commonly used in curiosity‑driven exploration (A13.241) to extract a feature representation ϕ(s) that focuses on controllable elements of the environment.

â = gψ( s, s′ ),

where gψ is a parametric model (typically a neural network) trained by minimizing the cross‑entropy (for discrete actions) or mean squared error (for continuous actions) between the true action and the predicted action. By jointly training the feature encoder ϕ and the inverse model, the representation tends to ignore aspects of the state that the agent cannot influence, making the forward dynamics prediction more robust and the curiosity reward more meaningful.

  • gψinverse dynamics network with parameters ψ; outputs a predicted action â given states s and s′.
  • s, s′consecutive states (before and after the action).
  • atrue action that caused the transition from s to s′.
  • ϕ(s)feature representation of state s, often shared with forward dynamics and trained via the inverse model.
A13.243

Intrinsic Curiosity Module (ICM)

The Intrinsic Curiosity Module (ICM) generates an intrinsic reward signal to encourage exploration. It combines an inverse dynamics model (A13.242) that predicts the action at from the state transition (st, st+1), and a forward dynamics model that predicts a feature representation of the next state ϕ̂(st+1) from the current state features ϕ(st) and the action. The feature representation ϕ is trained via the inverse model to focus on controllable aspects of the environment. The intrinsic reward is the squared error between the predicted and the actual next‑state features:

rtintr = ‖ ϕ̂(st+1) − ϕ(st+1) ‖2.

States that surprise the forward model yield a high reward, pushing the agent to explore unfamiliar regions where its predictive model is inaccurate.

  • ϕ(s)feature representation of state s, learned by training the inverse dynamics model.
  • gψ(s, s′)inverse dynamics model predicting the action a given consecutive states (A13.242).
  • θ(ϕ(s), a)forward dynamics predictor: estimates ϕ(s′) from the current state features and action.
  • rtintrintrinsic curiosity reward; high prediction error indicates a novel or poorly‑understood state.
A13.244

Controllable Noisy TV

The controllable noisy TV is a thought experiment that illustrates a failure mode of curiosity‑driven exploration based on prediction error. In this scenario, the agent can control a television that displays random noise. Although the noise is completely unpredictable and cannot be influenced by the agent’s actions in any meaningful way, a naive curiosity module (e.g., ICM, A13.243) assigns a persistently high intrinsic reward because the prediction error remains large. As a result, the agent can become stuck observing the TV indefinitely, collecting intrinsic reward without making progress on the actual task. This demonstrates the need for exploration signals that distinguish between stochastic but uncontrollable dynamics and genuinely novel, learnable aspects of the environment.

  • noisy TVan environment element that emits unpredictable observations regardless of the agent’s actions.
  • prediction errorthe intrinsic reward produced by a forward model; high for random noise.
  • procrastinationthe agent’s tendency to exploit the noisy TV for intrinsic reward instead of exploring the real task (see A13.237).
A13.245

Multi‑tasking

Multi‑tasking in reinforcement learning refers to training a single agent to perform well on multiple related tasks simultaneously. The tasks typically share the same state and action spaces but may differ in their transition dynamics or reward functions. The policy is often conditioned on a task identifier i, i.e. πθ(a ∣ s, i), and the objective is to maximise the average expected return across all tasks. This approach leverages common structure to improve sample efficiency and can lead to generalisation to unseen tasks.

  • itask identifier (e.g., an integer index, a goal descriptor, or a one‑hot vector).
  • πθ(a ∣ s, i)task‑conditioned policy with shared parameters θ.
  • Ri(s, a)reward function specific to task i.
A13.246

Universal Value Function and Universal Policy

A universal value function is a model that approximates the value function for a set of subtasks (goals) simultaneously, typically conditioned on a goal descriptor g. It generalises the standard value function by taking the goal as an additional input:

V(s, g) ≈ Vgπ(s).

Analogously, a universal policy is a policy conditioned on both the state and a goal descriptor, allowing the same policy to act optimally for many different goals:

π(a ∣ s, g).

These concepts are central to multi‑task and goal‑conditioned reinforcement learning, enabling transfer and generalisation across tasks.

  • ggoal descriptor (e.g., a target state, a task identifier, or a feature vector) specifying the subtask.
  • V(s, g)universal value function: the expected return from state s when pursuing goal g.
  • π(a ∣ s, g)universal policy: probability of selecting action a in state s for goal g.
A13.247

Meta‑controllers

A meta‑controller (or high‑level controller) is a higher‑level policy in a hierarchical reinforcement learning framework. It operates at a slower time scale than a low‑level controller and selects abstract subgoals g ∈ G, which are then communicated to a lower‑level policy that executes primitive actions to achieve the subgoal. The meta‑controller is rewarded based on the environment's original reward, with subgoals often terminating after a fixed number of steps or when a subgoal is reached.

Formally, the meta‑controller is a policy πhigh(g ∣ s) that maps the current state to a probability distribution over subgoals. It works in tandem with a universal lower‑level policy πlow(a ∣ s, g) (A13.246). This two‑level structure is characteristic of algorithms such as h-DQN and Feudal Networks.

  • πhigh(g ∣ s)meta‑controller policy: selects a subgoal g given current state s.
  • g ∈ Gsubgoal in a (typically discrete) set of achievable subgoals.
  • πlow(a ∣ s, g)low‑level policy (controller) that acts to reach subgoal g.
  • hierarchical RLparadigm where multiple policies operate at different temporal scales.
A13.248

Trajectory Relabeling

Trajectory relabeling is a technique in goal‑conditioned reinforcement learning where a trajectory generated while pursuing an original goal g is later reinterpreted as if it had been generated for a different goal g′ that was actually achieved during the episode. By replacing the original goal with the achieved one and recomputing the rewards accordingly, failed trajectories can be turned into successful ones, dramatically improving sample efficiency in sparse‑reward settings.

Formally, given a trajectory τ = (s0, a0, r0, …, sT) originally intended for goal g, one selects a new goal g′ (often one of the states actually visited, e.g., sT) and replaces each reward rt with a recomputed reward based on g′:

rt = rg′(st, at),

where rg′ is the reward function for goal g′ (e.g., a sparse +1 for reaching g′). The relabeled transition (st, at, rt, st+1, g′) is then stored in the replay buffer and used for training. This is the core idea behind algorithms such as Hindsight Experience Replay (HER).

  • τoriginal trajectory collected under goal g.
  • goriginal (intended) goal descriptor.
  • g′new goal descriptor, typically an actually achieved state.
  • rg′reward function parameterised by goal g′.
  • rtrelabeled reward at time t using the new goal g′.
A13.249

Hindsight Experience Replay (HER)

Hindsight Experience Replay (HER) is a sample‑efficient algorithm for off‑policy goal‑conditioned reinforcement learning in sparse‑reward environments. It tackles the challenge of rarely achieving goals by storing transitions in a replay buffer not only with the original intended goal, but also with a set of additional goals that were actually achieved during the episode. This effectively turns failed episodes into successful ones, accelerating learning.

Algorithm (typical usage with DDPG or DQN):

  • Hyperparameters: k – number of additional goals to sample per episode, replay buffer D, standard off‑policy RL parameters.
  • Input: a goal‑conditioned policy πθ(a ∣ s, g) and an off‑policy RL algorithm (e.g., DDPG).

For each episode:

  1. Sample a goal g from the task distribution.
  2. Run the policy πθ(· ∣ s, g) in the environment, obtaining a trajectory τ = (s0, a0, r0, …, sT).
  3. Store every transition (st, at, rt, st+1, g) in the replay buffer D (original goal).
  4. Select a set of additional goals G′ that were actually achieved in the trajectory (e.g., the state at the final time step, or a random subset of visited states).
  5. For each additional goal g′ ∈ G′:
    • Recompute the rewards for every time step: rt = rg′(st, at), where rg′ is the reward function for goal g′.
    • Store the relabeled transition (st, at, rt, st+1, g′) in D.
  6. Update the policy and value function using mini‑batches sampled uniformly from D (including both original and relabeled transitions).

HER makes learning from sparse binary rewards feasible by guaranteeing that every episode contains some transitions with a positive reward (since the final state is always a "successful" goal). It is particularly effective in robotic manipulation and goal‑reaching tasks.

  • goriginal goal descriptor (e.g., desired position).
  • g′relabeled goal, usually a state actually reached during the episode.
  • rtrelabeled reward based on the new goal g′.
  • πθ(a ∣ s, g)goal‑conditioned policy.
  • Dreplay buffer containing both original and relabeled transitions.
  • knumber of relabeled goals per episode.
A13.250

Hindsight Relabeling

Hindsight relabeling is a data augmentation technique for goal‑conditioned reinforcement learning. For any trajectory collected while pursuing an original goal g, it retrospectively assigns a new goal g′ that was actually achieved (e.g., the state at the end of the episode) and recomputes the rewards under this new goal. This turns unsuccessful episodes into successful ones for some goal, thereby creating a more balanced training set with positive rewards even in sparse reward settings. The technique is the core innovation of Hindsight Experience Replay (HER) and has been applied to off‑policy RL algorithms such as DQN and DDPG.

Algorithm (relabeling procedure for one episode):

Input: a trajectory τ = (s0, a0, r0, …, sT) originally collected for goal g, a set of alternative goals G′ (e.g., {sT} or random visited states).

  1. Store the original transitions (st, at, rt, st+1, g) in the replay buffer.
  2. For each alternative goal g′ ∈ G′:
    • For each time step t = 0, …, T−1:
      rt = rg′(st, at),
      where rg′ is the binary or reward function for goal g′ (e.g., rg′(s,a) = 1 if s′ reaches g′, else 0).
    • Store the relabeled transition (st, at, rt, st+1, g′) in the replay buffer.

The buffer is then used to train the goal‑conditioned policy and value function as usual.

  • goriginal intended goal.
  • g′hindsight goal; an actually achieved state (or other alternative).
  • rg′reward function parameterised by goal g′.
  • rtrelabeled reward at time t for the new goal.
  • τcollected trajectory.
  • G′set of hindsight goals chosen from the trajectory (e.g., future states, final state).
A13.251

Feudal RL

Feudal Reinforcement Learning is a hierarchical reinforcement learning architecture that decomposes the decision‑making process into a high‑level Manager and a low‑level Worker. The Manager operates at a slow temporal abstraction and sets latent goals gt for the Worker. The Worker is trained to achieve these goals via an intrinsic reward that measures the alignment of its actions with the direction indicated by the Manager. Both levels learn simultaneously, but with separate update rules, enabling efficient long‑term credit assignment and transfer of sub‑skills.

  • Managerhigh‑level policy that outputs a latent goal gt at a slower timescale.
  • Workerlow‑level policy that receives the current state and the Manager's goal, and selects primitive actions.
  • gtlatent goal (e.g., a direction in a learned feature space) communicated from Manager to Worker.
  • intrinsic rewardreward for the Worker, typically based on the cosine similarity between a state transition feature and the Manager's goal.
A13.252

Feudal Networks (FuN)

Feudal Networks (FuN) is a specific implementation of the Feudal RL architecture that uses neural networks to learn a hierarchical policy. The Manager (high‑level) operates at a coarser temporal scale and outputs a latent goal gt ∈ ℝd that encodes a desired direction in a learned feature space. The Worker (low‑level) produces primitive actions and is intrinsically rewarded for moving the environment's state representation in the direction specified by the Manager.

The Manager's goal is updated every c steps via a recurrent network; the Worker receives the goal and the state, and uses a transition policy gradient to maximize the cosine similarity between the state transition (in feature space) and the goal. The overall architecture is trained end‑to‑end with separate loss functions for the Manager (using the environment's extrinsic reward) and the Worker (using the intrinsic directional reward).

  • gtlatent goal vector output by the Manager at time t (direction in a learned latent space).
  • stenvironment state (or its encoded feature) at time t.
  • ϕ(s)learned feature embedding of state s (shared between Manager and Worker).
  • ctemporal abstraction period: the Manager updates its goal every c steps.
  • intrinsic rewardfor the Worker: typically the cosine similarity between (ϕ(st+c) − ϕ(st)) and gt.
A13.253

HIRO (Hierarchical RL with Off‑Policy Correction)

HIRO is a hierarchical off‑policy reinforcement learning algorithm that uses a two‑level policy: a high‑level controller (meta‑controller) that selects goals gt every c steps, and a low‑level controller that acts at every step to reach the current goal. To combat the non‑stationarity caused by the changing low‑level policy when training the high‑level policy off‑policy, HIRO introduces an off‑policy correction mechanism. When a past transition is sampled from the replay buffer, the original high‑level action (goal) is replaced by the goal that would most likely have induced the same low‑level behaviour, i.e., the goal that maximises the log‑probability of the actually observed sequence of low‑level actions.

Formally, for a stored trajectory segment of length c with states st:t+c and actions at:t+c, the relabeled goal is

g̃ = arg maxgi=0c−1 log πlow( at+i ∣ st+i, g ),

where πlow is the current low‑level policy. The high‑level transition is then stored as (st, g̃, Σi rt+i, st+c) and used to train the high‑level policy with standard off‑policy methods (e.g., DDPG). The low‑level policy is trained on the original data, using a goal‑conditioned reward (e.g., the negative Euclidean distance to the goal).

  • ctemporal abstraction interval: the high‑level policy updates the goal every c steps.
  • gtgoal (subgoal) output by the high‑level policy at time t.
  • relabeled goal obtained by maximising the low‑level policy's log‑probability of the observed action sequence.
  • πlow(a ∣ s, g)low‑level goal‑conditioned policy.
  • πhigh(g ∣ s)high‑level policy (meta‑controller).
  • off‑policy correctionrelabeling the high‑level goal in past experience to mitigate non‑stationarity when training off‑policy.
A13.254

Partially Observable MDP (POMDP)

A Partially Observable Markov Decision Process (POMDP) generalizes the MDP to settings where the agent cannot directly observe the full environment state. It is defined by the tuple

(S, A, O, P, R, Z, γ),

where

  • S, A, P, R, γ are the state space, action space, transition function, reward function, and discount factor as in a standard MDP.
  • O is a finite set of observations.
  • Z : S × A → Δ(O) is the observation function. After the environment transitions to state s′ ∼ p(·∣s,a), the agent receives an observation o ∈ O with probability Z(o ∣ s′, a) (some definitions also condition on the previous state s).

Because the agent never sees the true state, it must maintain a belief state b ∈ Δ(S), a probability distribution over possible states. The belief is updated recursively using Bayes' rule after each action and observation. The resulting belief MDP is a fully observable MDP over the continuous belief space, preserving the Markov property and allowing the application of standard planning algorithms (at increased computational cost).

  • Sstate space (hidden from the agent).
  • Aaction space.
  • Oobservation space.
  • P(s′ ∣ s, a)transition probability.
  • R(s, a)expected immediate reward (may also depend on s′).
  • Z(o ∣ s′, a)probability of observing o after reaching state s′ via action a.
  • γdiscount factor.
  • b(s)belief state: the agent's posterior probability that the environment is in state s.
A13.255

Belief MDP

A Belief MDP is a fully observable Markov decision process defined over the belief state space of a POMDP (A13.254). It captures the exact same decision problem but with the agent maintaining a probability distribution over the hidden states. The belief state b ∈ Δ(S) is a sufficient statistic for the history of actions and observations.

The belief is updated recursively via Bayes' rule after taking action a and receiving observation o:

b′(s′) = η · Z(o ∣ s′, a) · ∑s ∈ S p(s′ ∣ s, a) · b(s),

where η is a normalisation constant ensuring b′ sums to 1.

Formally, the belief MDP is the tuple (B, A, τ, ρ, γ) where

  • B = Δ(S) is the continuous space of probability distributions over the original states.
  • τ(b′ ∣ b, a, o) is the deterministic belief transition function derived from the belief update (or stochastic if the observation o is marginalised).
  • ρ(b, a) = 𝔼s∼b[ R(s, a) ] is the expected immediate reward.
  • γ is the discount factor (unchanged from the POMDP).

Because the belief MDP is fully observable, conventional MDP algorithms (e.g., value iteration) can be applied, but the continuous state space makes exact solutions computationally expensive in all but the smallest POMDPs.

  • b(s)belief state: probability that the true state is s.
  • b′(s′)updated belief after executing action a and observing o.
  • Z(o ∣ s′, a)observation probability (from POMDP definition).
  • p(s′ ∣ s, a)transition probability of the original MDP.
  • ηnormalisation factor (1 / P(o ∣ b, a)).
  • Bbelief space: the (continuous) set of all probability distributions over S.
  • τbelief transition dynamics (deterministic given action and observation).
  • ρ(b, a)expected reward for taking action a in belief b.
A13.256

Recurrent Networks in Policy Gradient

In partially observable environments, a recurrent neural network (RNN) is used to approximate a history‑dependent policy πθ(at ∣ o≤t, a<t) by maintaining a latent state ht that summarises the past. The policy and the hidden state are defined as

ht = fθ( ot, ht−1 ),  at ∼ πθ( · ∣ ot, ht−1 ),

where fθ is the recurrent layer (e.g., LSTM or GRU) sharing parameters θ with the policy head. The policy gradient theorem generalises naturally; the gradient is estimated by backpropagation through time (BPTT) over truncated sequences, and the hidden state is treated as part of the internal state, not reset between consecutive updates unless explicitly required. This approach allows the agent to implicitly perform inference and memory, enabling end‑to‑end learning of reactive and memory‑based behaviours in POMDPs (A13.254).

  • otobservation at time t.
  • hthidden state of the recurrent network (memory).
  • πθ(a ∣ o, h)policy conditioned on the current observation and the previous hidden state.
  • fθrecurrent function updating the hidden state.
  • BPTTbackpropagation through time; algorithm to compute gradients over sequences.
A13.257

R2D2 (Recurrent Replay Distributed DQN)

R2D2 (Recurrent Replay Distributed DQN) is an off‑policy reinforcement learning agent designed for partially observable environments. It replaces the feed‑forward Q‑network of DQN with a recurrent neural network (typically an LSTM) that takes the current observation ot and the previous recurrent state ht−1 to produce the current action‑value estimates Q(o≤t, at) and the new hidden state ht. Training is performed off‑policy using stored sequences from a large distributed replay buffer, with two crucial techniques:

  • Stored sequences: Transitions are stored as fixed‑length overlapping sequences (ot, at, rt, …) of length L, along with the initial recurrent state.
  • Burn‑in: A short prefix of the sequence (e.g., B steps) is used to warm up the hidden state from the stored initial recurrent state before the actual training window of length T. During burn‑in, no loss is applied; only the internal state is updated.

The TD error is computed only on the training portion of the sequence, using the standard n‑step Q‑learning target with the target network. The recurrent network allows the agent to learn to integrate observations over time, compensating for partial observability without requiring a predefined belief space. R2D2 demonstrated state‑of‑the‑art results on the Atari-57 benchmark and challenging memory tasks.

  • otobservation (partial state) at time t.
  • htrecurrent hidden state at time t (LSTM output).
  • Q(o≤t, a; ht−1)action‑value estimate output by the recurrent network given observation history and previous hidden state.
  • Ltotal length of stored sequence (e.g., 80).
  • Bburn‑in length (number of initial steps used only to unroll the hidden state, without learning).
  • Ttraining window length (e.g., 40) where loss is applied.
  • θtarget network parameters (periodically updated).
  • n‑step returnmulti‑step Q‑learning target used for training.
A13.258

Neural Episodic Control (NEC)

Neural Episodic Control (NEC) is a model‑free reinforcement learning algorithm that augments a parametric deep Q‑network with a non‑parametric episodic memory. It stores past experiences in a Differentiable Neural Dictionary (DND), a key–value memory where keys are learned state embeddings and values are corresponding returns. For a query state, the memory is retrieved via an attention mechanism using a kernel function (e.g., Gaussian), and the retrieved value is combined with the network's estimate to form the final Q‑value.

The DND stores, for each action, a set of key–value pairs { (ki, vi) }. When a new state s is encountered, its embedding q = fθ(s) is computed by a neural network. The episodic read‑out for action a is a weighted sum of stored values:

Qep(s, a) = ∑i wi vi,  wi ∝ K( q, ki ),

where K is a kernel function (e.g., the Laplace kernel exp(−∥q − ki∥)). The parametric component Qθ(s, a) is a standard neural network. The final Q‑value is a linear combination Q(s, a) = Qθ(s, a) + Qep(s, a) (or sometimes the maximum). The network parameters θ are trained by minimising the Bellman error. The DND is populated during training by storing the embedding of experienced states as keys and the n‑step return as values, occasionally updating values with better estimates (e.g., Bellman target).

NEC provides rapid learning by leveraging exact recall of high‑value states, and the differentiable memory allows gradient‑based training of the embedding function. It was notably demonstrated on Atari games, where it achieved high sample efficiency compared to standard DQN variants.

  • fθ(s)state embedding network; maps a state s to a key vector q.
  • DNDDifferentiable Neural Dictionary; episodic memory storing key‑value pairs per action.
  • kithe i-th key in the DND (an embedding of a past state).
  • vivalue stored with key ki (e.g., n‑step return or updated target).
  • Qep(s, a)episodic read‑out for action a: weighted sum of values based on kernel similarity.
  • Qθ(s, a)parametric Q‑network with parameters θ.
  • K(q, k)kernel function measuring similarity between query and key (e.g., Gaussian, Laplace).
  • winormalised weight assigned to memory item i.
  • n‑step returncumulative discounted reward over n steps, stored as memory value.
A13.259

Multi‑Agent Reinforcement Learning

Multi‑Agent Reinforcement Learning (MARL) extends RL to systems where multiple agents interact within a shared environment. Formally, a Markov (or Stochastic) Game generalises the MDP: a tuple (N, S, A, P, R, γ) where N is the number of agents, S is the state space, A = A1 × … × AN is the joint action space, P(s′ ∣ s, a) is the transition probability given joint action a = (a1, …, aN), Ri(s, a) is agent i's reward function, and γ is the discount factor. Each agent i aims to maximise its own expected return Jii, π−i) under the influence of other agents' policies.

  • Nnumber of agents.
  • Aiaction space of agent i.
  • a = (a1, …, aN)joint action vector.
  • Ri(s, a)reward function for agent i.
  • πipolicy of agent i (possibly dependent on other agents' behaviour).
A13.260

Connection with Game Theory

Multi‑agent RL is deeply intertwined with game theory, the mathematical study of strategic interactions among rational decision‑makers. The Markov game framework directly inherits concepts such as Nash equilibrium: a tuple of policies 1*, …, πN*) where no agent can unilaterally improve its expected return. Formally, for all agents i and all alternative policies πi,

Ji( πi*, π−i* ) ≥ Ji( πi, π−i* ).

Other game‑theoretic solution concepts include Pareto optimality (for cooperative teams), Stackelberg equilibrium (leader‑follower), and correlated equilibrium. Algorithms for MARL often aim to converge to a Nash equilibrium in self‑play, while others explicitly model opponents. The field is divided into cooperative, competitive, and mixed settings depending on whether agents share, oppose, or have individual rewards.

  • πi*optimal (equilibrium) policy for agent i.
  • π−ijoint policy of all agents except i.
  • Nash equilibriuma strategy profile where no agent can benefit by unilaterally deviating.
  • Pareto optimalitya joint outcome where no agent can be made better off without making another worse off (relevant in cooperative MARL).
A13.261

Centralization of Training

In centralised training with decentralised execution (CTDE), agents are trained with access to global information (e.g., full state, joint actions, and rewards of all agents), but at test time each agent acts using only its own local observations. This paradigm is a cornerstone of many cooperative multi‑agent reinforcement learning algorithms, as it allows learning coordinated policies while respecting partial observability during execution.

Formally, during training an agent's policy or value function may condition on the true state s and the joint observation‑action history, but the execution policy uses only the agent's own history:

πi(ai ∣ τi),  τi = (oi,0, ai,0, …, oi,t),

while the critic (or training signal) may use s or all agents' histories to compute a more accurate gradient. Algorithms like QMIX, MADDPG, and COMA adopt this scheme.

  • sglobal state (unavailable to the agent during execution, but available during training).
  • oi,tlocal observation of agent i at time t.
  • τiaction‑observation history of agent i.
  • πi(ai ∣ τi)decentralised policy (used at both training and test time for action selection).
  • Centralised critica value function that takes global state and joint actions as input, used only during training.
A13.262

Self‑play in Antagonistic Games

Self‑play is a training paradigm for multi‑agent competitive (antagonistic) games where a single agent is pitted against copies of itself (or previous versions). The agent learns by repeatedly playing games from both sides, generating experience that covers a wide range of strategies. The objective is to find a policy that is robust against a near‑optimal opponent, often converging to a Nash equilibrium in symmetric zero‑sum games.

Formally, at iteration k, the agent's policy πk is trained to maximise its expected return against a mixture of past policies 1, …, πk−1} (or directly against πk itself). The training data are generated by pairing the current policy against itself or an older snapshot. This technique underpins landmark successes such as AlphaGo Zero and OpenAI Five.

  • πkpolicy at iteration k (may be a separate network or a single network for both players).
  • opponenta copy of the agent, often a previous version or the same version, providing adaptive difficulty.
  • Nash equilibriumtheoretical solution concept targeted by self‑play in two‑player zero‑sum games.
A13.263

Multi‑Agent DDPG (MADDPG) in Mixed Games

Multi‑Agent Deep Deterministic Policy Gradient (MADDPG) extends DDPG to multi‑agent environments where each agent i has its own deterministic policy μθi(oi). The training follows the centralised training with decentralised execution paradigm: during training, each agent’s critic Qθi(x, a1, …, aN) has access to the global state (or joint observations) and the joint actions of all agents; during execution, the actor uses only its local observation oi. This allows the agents to learn coordinated strategies while acting in a fully decentralised manner at test time. MADDPG is applicable to mixed games (cooperative–competitive, general‑sum Markov games).

Algorithm (MADDPG for N agents):

  • Hyperparameters: discount γ, soft update τ, mini‑batch size B, replay buffer D (shared or per‑agent).
  • Initialization: for each agent i, actor μθi, critic Qθi, target networks μθi, Qθi with copied parameters. Replay buffer D empty.

For each step t:

  1. Each agent i observes its local observation oi and selects action ai = μθi(oi) + εi (exploration noise).
  2. Execute joint action a = (a1, …, aN); observe next observations o′i, rewards ri, and global state s′. Store (x, a, r, x′) in D, where x = (o1, …, oN) (or global state s).
  3. Sample mini‑batch of B transitions from D. For each transition:
    • For each agent i, compute target action for next state: a′j = μθj(o′j) for all j.
    • Compute target Q‑value for agent i:
      yi = ri + γ Qθi( x′, a′1, …, a′N ).
  4. Update each critic Qθi by minimising the loss:
    L(θi) = (1/B) ∑ ( Qθi( x, a1, …, aN ) − yi )2.
  5. Update each actor μθi using the sampled policy gradient:
    θi J ≈ (1/B) ∑ ∇ai Qθi( x, a1, …, aN ) |ai = μθi(oi)θi μθi(oi).
  6. Soft‑update all target networks:
    θi ← τ θi + (1 − τ) θi,  μ‑parameters similarly.
  • Nnumber of agents.
  • oilocal observation of agent i.
  • μθi(oi)deterministic policy (actor) for agent i.
  • Qθi(x, a)centralised critic for agent i, taking joint observations/state x and joint action a.
  • x = (o1, …, oN) or sglobal information available to critics during training.
  • a = (a1, …, aN)joint action vector.
  • γdiscount factor.
  • τsoft update coefficient for target networks.
  • εiexploration noise added to actor output (e.g., Ornstein–Uhlenbeck or Gaussian).
  • Dreplay buffer storing experience tuples (x, a, r, x′).
A13.264

Communication Systems (DIAL)

Differentiable Inter‑Agent Learning (DIAL) is a multi‑agent reinforcement learning algorithm that enables agents to learn a discrete communication protocol through the backpropagation of gradients. During training, agents send continuous-valued messages, which are discretised by noise or a straight‑through estimator to compute gradients, allowing end‑to‑end learning of what, when, and to whom to communicate. At test time, agents use discrete messages, achieving effective communication in cooperative partially observable environments.

  • mti→jcontinuous message sent from agent i to agent j at time t during training (discretised later).
  • πθ(ai ∣ oi, min)policy conditioned on local observation and incoming messages.
  • straight‑through estimatortechnique to backpropagate through the discretisation step.