5.1.9 · D1Reinforcement Learning Foundations

Foundations — Dynamic programming (value - policy iteration)

1,983 words9 min readBack to topic

This page builds every symbol the parent note uses, starting from a reader who has never seen an expectation, a policy, or a Greek letter in this context. Read it top to bottom: each brick rests on the one before it.


1. The world: states, actions, and the little robot

Picture a robot on a grid of tiles. Each tile it can stand on is a state. At each tile it can pick a move — up, down, left, right — and each move is an action.

Figure — Dynamic programming (value - policy iteration)

Why sets (the curly , )? Because later we count "at most policies" — the bars just mean "how many things are in this set". With 16 tiles and 4 moves that is , a huge number; DP beats brute force over all of them.


2. Reward and the discount

Why do we need at all — why not just add up rewards? Two reasons, one practical, one mathematical:

  • Practical: a cookie today beats a cookie in a year. encodes impatience.
  • Mathematical: if the robot could wander forever, a plain sum of 's would be for everyone and comparisons become meaningless. Multiplying by makes the total a finite number, so states become comparable.
Figure — Dynamic programming (value - policy iteration)

3. The return — what we actually want to maximise

The robot cares about its whole future, not one reward. Stack up the discounted rewards from time onward:

The single most important algebraic trick on the parent page pulls the first reward off this trail:

Why bother? Because the bracket is the same kind of object one step later. This "now-reward plus discounted next-return" shape is the seed of every Bellman equation. Recognise it — it is the whole topic.


4. Policy — the robot's rulebook

Two flavours, both used on the parent page:

  • Random / stochastic: e.g. for each of 4 moves — a full pie.
  • Greedy / deterministic: one arrow gets probability — a single confident arrow.

Why probabilities and not just one arrow? Because DP starts with a guess and improves it; early on the rulebook is a fuzzy pie, and we watch it sharpen into single arrows as the robot learns.


5. Expectation — averaging over uncertainty

The world may be uncertain: "move right" might slip and land elsewhere. When outcomes are random, we cannot say the return — only its average.

Why is this the right tool (and not, say, the best case or worst case)? Because a rational agent that repeats an episode many times cares about its long-run mean payoff. The expectation is the honest summary of "what you get on average" — no other single number captures that.

Concretely, for a value that occurs with probability : Every (capital sigma, "add these up") in the Bellman equations is one of these probability-weighted averages spelled out.


6. The dynamics

Notation care: (read "s-prime") just means "the next state" — the prime is a tick meaning "one step later", nothing more. DP needs because it is a model-based method: it looks up every possible next outcome and averages over them. (Later chapters like 5.1.11-Q-learning drop and sample instead — but that story starts here.)


7. The value functions and — the payoff of a shortcut

Now we can assemble the two starring symbols.

Why keep both and ? answers "how good is this tile?"; answers "how good is this move from this tile?". To choose, you need the per-move numbers — that is why the greedy policy is .

Figure — Dynamic programming (value - policy iteration)

8. The operators: , ,

Three symbol-machines finish the vocabulary.

Why does the optimal equation use while the policy equation uses ? Because an averaging policy blends all arrows (weighted sum), but an optimal agent never blends — it always grabs the single best arrow. Averaging vs. maximising is the one line that separates the two Bellman equations on the parent page.


9. Putting it together (preview of the parent's core line)

With every symbol earned, the parent's central equation is now readable left to right, in words:

That is Section 3's "" trick with the two averages ( and ) written out. Swap for and you have the optimality equation. Nothing else is new. These live formally in Bellman-equations and power 5.108-Markov-Decision-Process-(MDP).


Prerequisite map

States and set S

Value function V

Actions and set A

Action value Q

Reward r

Return Gt

Discount gamma

Policy pi

Expectation E

Dynamics p

max and argmax

Optimal V star and pi star

Bellman equations

Dynamic Programming: value and policy iteration

Each source arrow is a symbol you must own before the target makes sense; every path drains into the DP node the parent page is about.


Equipment checklist

Test yourself — cover the right side and answer each before revealing.

What does a state correspond to in the grid picture?
One highlighted tile — a complete snapshot of the situation.
What does the bar in mean?
"Given" — probability of action given we are in state .
Why must be strictly less than 1?
So infinite reward streams sum to a finite number and the updates converge (contraction).
Rewrite in terms of .
.
What does average over?
All random outcomes, assuming actions are chosen by policy .
What does output?
The probability of landing in next-state with reward , given state and action .
Difference between and ?
scores a tile under ; scores a specific action from that tile then follows .
Difference between and ?
returns the best value; returns the action achieving it.
What single change turns the expectation Bellman equation into the optimality one?
Replace (averaging over moves) with (picking the best move).
What does the star in signify?
Optimal — the value under the best possible policy.