5.1.4 · D1Reinforcement Learning Foundations

Foundations — State-value and action-value functions

2,714 words12 min readBack to topic

This page assumes you have seen NONE of the notation in the parent note. We build every symbol from the ground up, in the order they depend on each other. Nothing is used before it is drawn.

Parent topic: State-value and action-value functions · Hinglish version: 5.1.04 State-value and action-value functions (Hinglish)


The picture everything lives in: an agent walking through states

Before any symbol, here is the world we are describing.

Figure — State-value and action-value functions

An agent (the little dot) sits in a situation. It picks a move. The world responds: it hands the agent a small reward (a number) and drops it into a new situation. Then it repeats — until the game reaches an ending (a terminal state) or, in some games, forever.

Everything in this topic is just careful bookkeeping of that loop. Let us name each part.


Symbol 0 — random variables (the idea behind every capital letter)

Before naming anything, one background idea that everything rests on.

The picture: a die mid-roll. While it tumbles it is the random variable ; the moment it lands showing a , that landed value is .

Why the topic needs it: in reinforcement learning, states, actions, and rewards are all decided partly by chance. So each gets a capital-letter random variable (, , ) for "not yet decided" and a lowercase version (, , ) for "a specific value it might take".


Symbol 1 — the state and the state space

The picture: figure s01's grid. One highlighted square is a state . The whole grid of squares together is the state space ; every is one member, written (" is in ").

Why the topic needs it: value functions grade each state, so we need (a) a symbol for "this spot" () and (b) a symbol for "the collection of all spots" (), because a value function is really a rule assigning a number to every member of .

  • Lowercase ::: a particular, named state (like the center square)
  • Uppercase ::: a random variable — the state you end up in at step
  • Curly ::: the set of all possible states;

Symbol 2 — time steps and the subscript notation

The picture: frames of a filmstrip. Frame , frame , frame , laid left to right.

Why: rewards arrive at different times, and we will treat "now" and "later" differently. We need a clock to tell them apart.


Symbol 3 — the action and the action set

The picture: four arrows leaving the agent's square. Each arrow is one element of .

Why: an action-value function grades moves, so we need a name for a move.


Symbol 4 — the reward and the discount

Figure — State-value and action-value functions

Why a discount at all — why this tool and not just adding rewards up? Two reasons, both in figure s02:

  1. Infinity. If the game never ends and you just sum rewards, the total can blow up to infinity — then "which state is better" becomes meaningless. Multiplying by (with ) makes even an infinite sum settle to a finite number, because converges.
  2. Impatience. A reward now is worth more than the same reward in a hundred steps. encodes exactly how patient the agent is.
  • ::: totally short-sighted — only the very next reward matters
  • ::: far-sighted — a reward 50 steps away counts almost fully
  • Why keeps infinite sums finite ::: geometric series converges only for
  • When is allowed? ::: only when the game always terminates, so the sum has finitely many terms

Symbol 5 — terminal states and episodes

Before we add rewards up, we must know when the adding stops.

The picture: figure s01 — the goal square (top-right) is terminal; the little dot's whole path from start to that square is one episode. In an absorbing state, all arrows loop back to itself with reward , so it "absorbs" the agent.

How this fixes at the ending: once you reach a terminal state at some tick , every reward is . So the infinite sum in automatically truncates to a finite number of nonzero rewards. That is exactly why is safe for episodic (terminating) games.

  • What is a terminal state's value? ::: — there is no future reward left to collect
  • What is an episode? ::: one full run from a start state to a terminal state
  • Why can episodic games use ? ::: the reward stream ends, so the sum has finitely many terms

Symbol 6 — the return

Now we stack the discounted rewards into one grand total.

Reading the symbols one at a time:

  • — "add up the following for ". The big is Greek "S" for Sum. In an episode the sum stops naturally once you hit a terminal state (all later rewards are ).
  • — the shrink factor for a reward steps into the future.
  • — the reward received ticks after now.

The picture: figure s02's staircase — each future reward is a bar, each bar squashed shorter than the last by the ladder, then all bars added.

Why the topic needs it: is the actual number we care about — total (discounted) reward from here on. But depends on the specific dice rolls of one episode. To get a stable grade for a state we must average many episodes — which is the next symbol.


Symbol 7 — the policy

The picture: figure s03 — from one square, arrows of different thickness leave; thickness = probability. A thick "right" arrow and a thin "up" arrow means "I usually go right".

Why the vertical bar ? It reads "given". = "chance of , given you're in ". The bar always separates what we're asking about (left) from what we already know (right).

  • A deterministic policy ::: one action gets probability , all others
  • A stochastic policy ::: probabilities split across several actions, summing to
Figure — State-value and action-value functions

Symbol 8 — trajectories and expectation

First, the object we will average over.

Tiny example (this is the whole idea): flip for $10 with 70% chance, lose $1 with 30% chance. You never actually get 6.7 — it's the long-run average.

Why the subscript ? The averaging is taken over trajectories the agent produces while following policy . Change the policy → the trajectories change → the average changes. The subscript reminds us "these trajectories were generated by strategy ".

Why this exact tool and not just ? is one lucky (or unlucky) trajectory. smooths over all trajectories to give one trustworthy grade. Value functions are defined as expectations for precisely this reason.


Putting the symbols together — the two value functions

Now every ingredient exists, we can read the parent's headline definitions with zero mystery.

The only difference: pins down the first action too; lets the policy pick it. Everything after step one is identical.

  • Superscript ::: "graded while following policy " — a different policy gives a different grade
  • Condition ::: "given we start in "
  • Extra condition ::: "and given the first move is forced to be "

How the foundations feed the topic

Random variables capitals

State s and space S

Action a and set A

Reward R and discount gamma

Policy pi(a given s)

Action-value Q(s,a)

Return G_t

Time step t

Terminal states and episodes

Trajectory and expectation E over pi

State-value V(s)

Bellman equations

Optimal policies next topic

Each arrow means "you must understand the source before the target makes sense". Notice value functions sit near the bottom because they need all the earlier pieces. Once you have them, the optimal value functions and the algorithms that estimate them — dynamic programming, Monte-Carlo prediction, and temporal-difference learning — become reachable.


A 30-second sanity check with all symbols live

Say from state the policy is "go right for sure": . That move pays and lands you in where , with .

Every symbol on this page appears here. If you can read that line, you are ready for the parent note.


Equipment checklist

Cover the right side and see if you can state each from memory.

  • What is a random variable, and how is it written? ::: a quantity not yet decided by chance; written as a capital letter, its realised value lowercase
  • What does a state represent? ::: a full snapshot of your current situation — all you need to choose a move
  • What is the state space ? ::: the set of all possible states;
  • Capital vs lowercase ? ::: is the random state-at-time-; is one specific named state
  • What is an action , and what is ? ::: a chosen move; is the full menu of legal moves
  • What is a terminal state and its value? ::: an ending square where the game stops; its value is
  • What is an episode? ::: one full run from a start state to a terminal state
  • When is allowed, and when must ? ::: only if the game always terminates; otherwise to keep the infinite sum finite
  • What does the subscript on tell you? ::: the reward for acting at tick is paid on the next tick,
  • Why do we multiply future rewards by ? ::: to keep infinite sums finite and to make the agent value sooner rewards more
  • Write the return from memory. :::
  • What is a trajectory? ::: the recorded sequence of states, actions, and rewards in one episode
  • What does mean? ::: probability of choosing action given you are in state
  • What does the vertical bar read as? ::: "given" — separates what we ask about from what we already know
  • What does compute? ::: the probability-weighted average over trajectories produced by policy
  • In one sentence, what is ? ::: expected total discounted reward from while following
  • How does differ from ? ::: forces the first action to be ; lets pick it