Skip to content

A Future Worth Counting

Reinforcement Learning · One focused lesson

What is a situation worth under a strategy? Build the answer from the next reward and the value of what follows.

Reading tips and color key

Start with the explanation and experiment. Open the symbol cards when you want the details. Teal: probabilities; blue: states; orange: actions; green: rewards; purple: values; gray: parameters and settings; crimson: losses and errors. Written labels give every symbol its role.

06 · Put a number on a situation

Value: what happens if we keep following this strategy?

A tile beside the flag looks promising. But its usefulness also depends on your strategy. An explorer who keeps walking away from the flag gets a different future from one who heads toward it.

State value V asks about starting in a state. Action value Q asks about taking a particular first action there. Both then follow the specified policy. The value is an expected return, so it averages over possible futures.

\[ {\color{#7542b0}{V}}^{{\color{#006e78}{\pi}}}({\color{#1d4ed8}{s}})=\mathbb{E}_{{\color{#006e78}{\pi}}}[{\color{#087444}{G}}_{{\color{#525968}{t}}}\mid{\color{#1d4ed8}{S}}_{{\color{#525968}{t}}}={\color{#1d4ed8}{s}}],\qquad {\color{#7542b0}{Q}}^{{\color{#006e78}{\pi}}}({\color{#1d4ed8}{s}},{\color{#9a4700}{a}})=\mathbb{E}_{{\color{#006e78}{\pi}}}[{\color{#087444}{G}}_{{\color{#525968}{t}}}\mid{\color{#1d4ed8}{S}}_{{\color{#525968}{t}}}={\color{#1d4ed8}{s}},{\color{#9a4700}{A}}_{{\color{#525968}{t}}}={\color{#9a4700}{a}}]. \]
Equation anatomy · two questions about the same future · show / hide
Equation anatomy · two questions about the same future
SymbolMeaning and kindFormRandom?Possible valuesIn code
\({\color{#172337}{\color{#7542b0}{V}}^{\color{#006e78}{\pi}},{\color{#7542b0}{Q}}^{\color{#006e78}{\pi}}}\)State-value and action-value functionsState → scalar; (state, action) → scalarDeterministic for fixed model and policyReal expected returns, if finiteV[state], Q[state][action]
\({\color{#172337}{\color{#006e78}{\pi}}}\)Policy: rule for action probabilitiesState → action distributionFixed distribution; action samples can varyAction probabilities 0–1, summing to 1policy[state] = [0.1,0.7,0.1,0.1]
\({\color{#172337}{\color{#1d4ed8}{S}}_{\color{#525968}{t}},{\color{#1d4ed8}{s}}}\); \({\color{#172337}{\color{#9a4700}{A}}_{\color{#525968}{t}},{\color{#9a4700}{a}}}\)State/action variables and their specified valuesIDs in the gridUppercase variables random; conditioned values fixedValid states and actionsstate = 12; action = 1
\({\color{#172337}{\color{#087444}{G}}_{\color{#525968}{t}}}\); \({\color{#172337}{\color{#525968}{t}}}\); \({\color{#172337}{\mathbb{E}_{\color{#006e78}{\pi}},\mid}}\)Return; time; average under policy and environment, given conditionsScalar; index; operator/notationReturn generally random; expectation deterministicReal return; nonnegative timeAverage many futures from the specified start

The whole object is not one entry. On a grid with 36 possible state IDs and four actions, V can be a 36-number vector and Q a 36 × 4 matrix. Q[12][1] is just one number. A policy row [0.1,0.7,0.1,0.1] is a whole action distribution; its second entry, 0.7, is one probability. The dot in \({\color{#172337}{\color{#006e78}{\pi}}(\cdot\mid {\color{#1d4ed8}{s}})}\) means “include every action.”

An estimate stored after training is not automatically the true value. Different data produce different estimates. We use a hat for estimates when that distinction matters, and plain V or Q in updates to keep the writing readable.

07 · A big future, split into a small step

The Bellman equation

You do not have to list every possible journey at once. Ask what you earn on the next move, then add how promising the next tile is. Average that answer over the moves your strategy chooses and the outcomes the world allows.

The Bellman expectation equation applies the return’s one-step decomposition to a fixed policy’s value. It is a consistency relationship between true values; an algorithm can use it to improve estimates.

Turn “now + later” into an equation.
Reward now

2

Next tile’s value

0.9 × 10 = 9

Discount later points
Current value

11

The bar makes one certain future. With several possible futures, build this sum for each branch, multiply by its chance, and add. The expectation symbol below is shorthand for that weighted averaging.

\[ {\color{#7542b0}{V}}^{{\color{#006e78}{\pi}}}({\color{#1d4ed8}{s}})=\mathbb{E}_{{\color{#006e78}{\pi}}}\!\left[{\color{#087444}{R}}_{{\color{#525968}{t}}+1}+{\color{#525968}{\gamma}}{\color{#7542b0}{V}}^{{\color{#006e78}{\pi}}}({\color{#1d4ed8}{S}}_{{\color{#525968}{t}}+1})\mid{\color{#1d4ed8}{S}}_{{\color{#525968}{t}}}={\color{#1d4ed8}{s}}\right]. \]
Equation anatomy · reward now plus discounted next value, averaged · show / hide
Equation anatomy · reward now plus discounted next value, averaged
SymbolMeaning and kindFormRandom?Possible valuesIn code
\({\color{#172337}{\color{#7542b0}{V}}^{\color{#006e78}{\pi}}({\color{#1d4ed8}{s}}),{\color{#7542b0}{V}}^{\color{#006e78}{\pi}}({\color{#1d4ed8}{S}}_{{\color{#525968}{t}}+1})}\)Current value and value at the next stateScalar function evaluationsCurrent value fixed; next lookup varies with random inputReal expected returnsV[state], V[next]
\({\color{#172337}{\color{#087444}{R}}_{{\color{#525968}{t}}+1}}\); \({\color{#172337}{\color{#1d4ed8}{S}}_{\color{#525968}{t}},{\color{#1d4ed8}{S}}_{{\color{#525968}{t}}+1},{\color{#1d4ed8}{s}}}\)Next reward; current and next states; specified startScalar reward; state IDs hereReward and next state may be random; s fixedReal reward; valid state IDstransition = step(state,action)
\({\color{#172337}{\color{#006e78}{\pi}}}\); \({\color{#172337}{\mathbb{E}_{\color{#006e78}{\pi}},\mid}}\)Policy; average over action/outcome randomness, given the startFunction; expectation operator; notationPolicy and expectation fixed for the modelPolicy outputs a normalized distributionProbability-weight all allowed outcomes
\({\color{#172337}{\color{#525968}{\gamma}},{\color{#525968}{t}}}\)Discount and time indexScalar setting; integerFixed\({\color{#172337}{0\le{\color{#525968}{\gamma}}\lt 1;\ {\color{#525968}{t}}\ge0}}\) heregamma = 0.9

With one certain outcome, reward 2, discount 0.9, and next value 10, the current value is 11. With uncertain outcomes, average their reward-plus-next-value answers. A single observed transition is a sample of the Bellman right-hand side, not usually its exact average.

Open the expectation into probability sums

For a finite MDP, first consider every action. Then consider every next state for that action. Weight each possibility by the policy’s action probability and the environment’s transition probability.

\[ {\color{#7542b0}{V}}^{{\color{#006e78}{\pi}}}({\color{#1d4ed8}{s}})= \sum_{{\color{#9a4700}{a}}\in{\color{#9a4700}{\mathcal{A}}}}{\color{#006e78}{\pi}}({\color{#9a4700}{a}}\mid{\color{#1d4ed8}{s}}) \sum_{{\color{#1d4ed8}{s’}}\in{\color{#1d4ed8}{\mathcal{S}}}}{\color{#006e78}{P}}({\color{#1d4ed8}{s’}}\mid{\color{#1d4ed8}{s}},{\color{#9a4700}{a}}) \left[{\color{#087444}{r}}({\color{#1d4ed8}{s}},{\color{#9a4700}{a}},{\color{#1d4ed8}{s’}})+{\color{#525968}{\gamma}}{\color{#7542b0}{V}}^{{\color{#006e78}{\pi}}}({\color{#1d4ed8}{s’}})\right]. \]
Equation anatomy · two sources of chance · show / hide
Equation anatomy · two sources of chance
SymbolMeaning and kindFormRandom?Possible valuesIn code
\({\color{#172337}{\color{#1d4ed8}{s}},{\color{#1d4ed8}{s}}’,{\color{#1d4ed8}{\mathcal{S}}}}\); \({\color{#172337}{\color{#9a4700}{a}},{\color{#9a4700}{\mathcal{A}}}}\)Current/next state, state set; action, action setFixed labels and finite setsSummation candidates are fixedValid states/actionsfor (next of states)
\({\color{#172337}{\color{#006e78}{\pi}}({\color{#9a4700}{a}}\mid {\color{#1d4ed8}{s}}),{\color{#006e78}{P}}({\color{#1d4ed8}{s}}’\mid {\color{#1d4ed8}{s}},{\color{#9a4700}{a}})}\)Action-choice chance; next-state chanceScalar entries of separate distributionsDeterministic for fixed policy/model0–1; respective rows sum to 1policy[s][a]*P[s][a][next]
\({\color{#172337}{\color{#087444}{r}}({\color{#1d4ed8}{s}},{\color{#9a4700}{a}},{\color{#1d4ed8}{s}}’)}\)Expected immediate reward conditioned on this transitionFunction returning one scalarFixed conditional mean, even if rewards fluctuateReal numbersexpectedReward[s][a][next]
\({\color{#172337}{\color{#7542b0}{V}}^{\color{#006e78}{\pi}}({\color{#1d4ed8}{s}}),{\color{#7542b0}{V}}^{\color{#006e78}{\pi}}({\color{#1d4ed8}{s}}’)}\); \({\color{#172337}{\color{#525968}{\gamma}}}\)Current/next true values; discountScalar function outputs; settingFixedReal finite values; discount below 1 hererewardMean + gamma*V[next]
\({\color{#172337}{\sum,\in,\mid}}\)Add candidates, set membership, conditioningOperators/notationNoTwo finite weighted sumsAdd every probability-weighted term

Using the conditional mean reward makes this form valid even when reward and next state are related. For an impossible transition, its zero probability removes its contribution. Terminal states have value zero; their arriving reward is counted on entry.

Published inReinforcement Learning

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *