These are my notes on Shiyu Zhao’s Mathematical Foundations of Reinforcement Learning. The book’s main strength is that it presents reinforcement learning (RL) as one connected story: define the decision problem, express long-term value recursively, and then turn that recursion into algorithms that can plan or learn from experience.

The whole book in one sentence

An agent improves its behavior by repeatedly comparing its current prediction with a better target, then moving the prediction or policy a small step toward that target.

1. Describing sequential decisions

The agent–environment loop

At time :

  • is the state;
  • is the action selected by the agent;
  • is the reward received afterward; and
  • is the next state.

The loop is therefore

A policy tells the agent how to act. A stochastic policy is a conditional probability:

It can assign all probability to one action (a deterministic policy) or spread probability over several actions.

Markov decision process

A Markov decision process (MDP) supplies the mathematical model for the loop. Its main ingredients are:

where:

  • is the set of states;
  • is the set of actions;
  • describes the transition dynamics;
  • is the expected immediate reward; and
  • is the discount factor.

The Markov property means that the current state contains all information needed to predict the next step. Once and are known, earlier states do not add useful predictive information about .

Grid-world interpretation

A square is a state, moving up is an action, the chance of landing in a neighboring square is the transition probability, and reaching the goal may give reward . A sufficiently informative state must include anything from the past that still matters for the future.

Reward is immediate; return is long-term

The discounted return from time is

The discount factor controls how strongly the future matters:

  • a small makes the agent short-sighted;
  • a close to makes future rewards important; and
  • discounting keeps an infinite sum finite when rewards are bounded.

The useful recursive identity

is the seed from which the Bellman equations and most of the book’s algorithms grow.

2. Evaluating a policy with values

Before improving a policy, ask: How good is it?

The state-value function measures the expected return when the agent starts in state and then follows :

The action-value function also fixes the first action:

Their relationship is intuitive:

The state value is simply the policy-weighted average of the available action values.

Bellman expectation equation

Substitute into the value definition:

In words:

value now = expected immediate reward + discounted expected value later.

This is a system of self-consistency equations: every state’s value depends on the values of possible successor states. For a finite MDP it can be written as

and therefore, in principle,

The direct inverse explains the mathematical solution, but iterative and sample-based methods are usually more practical.

3. Optimal values and optimal policies

Policy evaluation asks how good a given policy is. Control asks for the best policy.

Define the optimal values by

The Bellman optimality equation replaces the policy’s average over actions with a maximum:

Similarly,

Once is known, acting optimally is easy:

The difficult part is estimating the values accurately enough to make this greedy choice.

Expectation versus optimality

A Bellman expectation equation evaluates the actions selected by a particular policy. A Bellman optimality equation selects the best action. This one change—from an average to a maximum—marks the move from prediction to control.

4. Planning when the model is known

If and are known, the agent can update values without interacting with the real environment. This is dynamic programming.

Value iteration

Repeatedly apply the Bellman optimality backup:

Each sweep pushes the value estimate toward . After convergence, extract a greedy policy.

Policy iteration

Alternate between two steps:

  1. Policy evaluation: compute or approximate for the current policy.
  2. Policy improvement: choose actions greedily with respect to that value.

The policy improvement theorem guarantees that the greedy policy is no worse than the old one. Repeating evaluation and improvement eventually produces an optimal policy in a finite discounted MDP.

5. Learning from complete episodes: Monte Carlo

When the model is unknown, the expectation in a Bellman equation cannot be calculated directly. One solution is to run the policy, observe full episodes, and use the actual return as a sample of value.

For a visited state:

For control, estimate action values in the same way:

Monte Carlo (MC) learning is conceptually simple and its target is based on real rewards, but it must wait until an episode ends. Its estimates can also have high variance because many random events affect a complete return.

Exploration is necessary

Always choosing the current best-looking action can prevent the agent from discovering better alternatives. A common compromise is an -greedy policy:

  • with probability , select a greedy action;
  • with probability , explore, usually by sampling an action uniformly.

The deeper tension is:

Exploitation uses what the agent currently knows; exploration gathers information that may improve future decisions.

6. Stochastic approximation: the common engine

Many RL updates have the same shape:

The term in parentheses is an error or innovation. Stochastic approximation explains why small, noisy corrections can converge to the desired solution.

For classical convergence in a stationary setting, a typical step-size requirement is

The first condition prevents learning from stopping too soon; the second prevents noise from dominating forever. A small constant step size may not converge exactly, but it can adapt better when the environment changes.

Stochastic gradient descent (SGD) follows the same principle, replacing an exact gradient with a sample-based estimate.

7. Learning one step at a time: temporal difference

Temporal-difference (TD) learning combines two ideas:

  • like MC, it learns from sampled experience without a model;
  • like dynamic programming, it bootstraps from an existing value estimate.

The one-step TD error is

and TD(0) updates

Unlike MC, TD can learn before an episode finishes. The price is that its target contains an estimate, so errors can temporarily reinforce other errors.

The major TD control algorithms

AlgorithmOne-step targetLearns the value ofType
SarsaThe policy actually taking On-policy
Expected SarsaThe current policy in expectationOn-policy
Q-learningA greedy target policyOff-policy

All three use

The labels on-policy and off-policy distinguish two policies:

  • the behavior policy generates experience;
  • the target policy is the policy being evaluated or improved.

Sarsa learns about the same exploratory policy that generates its data. Q-learning may behave exploratorily while learning about the greedy policy.

Multi-step methods sit between one-step TD and full-return MC. A longer target uses more observed rewards and less bootstrapping, trading lower bias for higher variance.

8. Scaling with value-function approximation

A table needs one entry per state or state–action pair. That becomes impossible for large or continuous spaces. Instead, represent values with parameters:

The same parameters are shared across many states, allowing the model to generalize from visited states to similar unseen ones. For a target , a semi-gradient update is

The approximator can be linear or nonlinear. A neural network that approximates action values gives the basic idea behind a deep Q-network (DQN).

DQN adds two important stabilizers:

  • experience replay: store transitions and train on randomly sampled past experience, reducing temporal correlation and reusing data;
  • target network: hold a separate, slowly updated network fixed while constructing TD targets, preventing the target from moving at every gradient step.

9. Optimizing the policy directly

Value-based methods learn values and then obtain a policy by acting greedily. A policy-gradient method instead defines a differentiable policy and adjusts its parameters to increase expected performance .

The policy-gradient theorem leads to the central form

Interpretation:

  • if an action produces a better-than-usual result, increase its probability;
  • if it produces a worse result, decrease its probability.

REINFORCE replaces the unknown action value with a sampled return:

This estimate is unbiased under standard assumptions, but often noisy. Subtracting a state-dependent baseline does not change the expected gradient and can reduce variance. A common choice is , producing the advantage

The advantage asks a more useful question than raw return: Was this action better or worse than what is normally expected in this state?

10. Actor–critic: putting both views together

Actor-critic methods combine:

  • an actor, which represents and improves the policy; and
  • a critic, which estimates values and judges the actor’s choices.

A simple discounted actor-critic method can use the TD error as an estimate of advantage:

Then update both parts:

The critic learns how good states are; the actor makes actions judged positively by the critic more likely. This pairing usually learns more frequently and with lower variance than waiting for a complete REINFORCE return.

The chapter extends this idea through advantage actor-critic, off-policy correction with importance sampling, and deterministic actor-critic methods.

My main takeaways

  1. The Bellman equation is the organizing principle. It turns a long-term objective into a local relationship between the present and the future.
  2. Most algorithms differ mainly in how they construct a target. The update pattern itself changes very little.
  3. Policy evaluation and policy improvement form a reusable loop. This loop appears in dynamic programming, MC control, TD control, and actor-critic.
  4. Learning methods trade bias, variance, data efficiency, and stability. There is no universally best target or representation.
  5. Actor-critic is a natural endpoint of the progression. It combines value learning’s feedback signal with direct policy optimization.

Glossary

TermPlain-language meaning
AgentThe learner and decision-maker
EnvironmentEverything the agent interacts with
StateInformation used to describe the current situation
ActionA choice available to the agent
RewardImmediate feedback after an action
ReturnAccumulated discounted future reward
PolicyA rule or distribution for choosing actions
Value functionExpected return from a state or state–action pair
ModelTransition and reward dynamics of the environment
Bellman backupAn update using immediate reward and successor value
BootstrappingUpdating an estimate using another current estimate
On-policyLearning about the policy that generates the experience
Off-policyLearning about a policy different from the one generating experience

Source and further study