vπ(s)=EπImmediate RewardRt+1+γDiscounted Future Valuevπ(St+1)Starting at state sSt=s
Fundamental concept in RL using a recursive equation to express a way to compute the value of a state based on the values of its successor states.
v(s)=E[Rt+1+γRt+2+γ2Rt+3+…St=s]=ERt+1+γGt+1(Rt+2+γRt+3+…)St=s=E[Rt+1+γGt+1∣St=s]=E[Rt+1+γv(St+1)∣St=s]=Immediate Reward R(s)E[Rt+1∣St=s]+γExpected Next State ValueE[v(St+1)∣St=s]=R(s)+γTransition Dynamicss′∑P(s′∣s)v(s′)(∵E[X+γY]=E[X]+γE[Y])(∵E[g(X)]=x∑P(x)g(x))
V of a particular statev(s1)⋮v(sn)=Immediate RewardR(s1)⋮R(sn)+γTransition MatrixP11⋮Pn1⋯⋱⋯P1n⋮PnnV of future statev(s1)⋮v(sn)
Action-Value of (s,a)qπ(s,a)=Follows policy πEπImmediate RewardRt+1+γDiscounted Next Action-Valueqπ(St+1,At+1)Starting at s taking action aSt=s,At=a
Evaluates the expected return of taking an arbitrary action a in state s, and subsequently following policy π from step t+1 onward.
How good is it to take action a in state s?
qπ(s,a): Value of taking action a in state s under policy π (Q-value).
Eπ: Expectation over the next transition (St+1∼P) and the subsequent action (At+1∼π).
Rt+1: Immediate reward resulting from the state-action pair (s,a).
γqπ(St+1,At+1): Discounted expected value of the successor state-action pair (St+1,At+1).
St=s,At=a: Condition that both the initial state and the initial action are fixed at time t.
vπ(s)=a∈A∑π(a∣s)(Rsa+γs′∈S∑Pss′avπ(s′))
Evaluates state s directly by averaging over all possible action branches (π) and their subsequent environmental transitions (P).
Rsa: Immediate reward resulting from the state-action pair (s,a).
γ∑s′∈SPss′avπ(s′): Discounted expected value of the successor state s′ resulting from the state-action pair (s,a).
Pss′a: Probability of transitioning from state s to state s′ when action a is taken.
S: Set of all possible states.
A: Set of all possible actions.
π(a∣s): Probability of taking action a in state s under policy π.
Evaluates the state-action pair (s,a) by summing immediate reward and the expected value of future action pairs (s′,a′), averaged across transition dynamics P and next-step policy choices π.
Rsa: Immediate reward resulting from the state-action pair (s,a).
γ∑s′∈SPss′a∑a′∈Aπ(a′∣s′)qπ(s′,a′): Discounted expected value of the successor state-action pair (s′,a′) resulting from the state-action pair (s,a).
Pss′a: Probability of transitioning from state s to state s′ when action a is taken.
S: Set of all possible states.
A: Set of all possible actions.
π(a′∣s′): Probability of taking action a′ in state s′ under policy π.
Maximum value function over all policies, or maximum possible reward that can be achieved from state s.
q∗(s,a)=maxπqπ(s,a)
The Optimal Action-Value Function q∗(s,a)
Maximum action-value function over all policies, or given state s and action taken a, what is the maximum reward that can be achieved from there onwards.
Existence of an Optimal Policy: There always exists at least one optimal policy π∗ that is better than or equal to all other policies across all states (π∗≥π,∀π).
Uniqueness of the Optimal State-Value Function: Although multiple distinct optimal policies may exist (e.g., when two different paths yield the exact same maximum expected return), all optimal policies achieve the exact same unique optimal state-value function (vπ∗(s)=v∗(s)).
Uniqueness of the Optimal Action-Value Function: Similarly, all optimal policies achieve the exact same unique optimal action-value function (qπ∗(s,a)=q∗(s,a)).
Once the action a is committed, the outcome is governed by the environment dynamics Pss′a, requiring an expectation (average) over possible successor states s′.
Optimal Value of State sv∗(s)=a∈AmaxImmediate RewardRsa+γExpected Optimal Future Values′∈S∑Pss′av∗(s′)
Bellman Optimality Equation for v∗ (s→a→s′)
Combines the agent's deterministic maximization (maxa) with the environment's stochastic transition (∑s′Pss′a).
It means a structure where the best choice I can make (max) embeds the probabilistic outcomes of the world (∑) in its calculation.
Non-Linear System: Because of the max operator, this system of equations cannot be solved directly via matrix inversion (I−γP)−1
it must be solved iteratively via Dynamic Programming (Value Iteration) or Reinforcement Learning.
Optimal Action-Valueq∗(s,a)=Immediate RewardRsa+γTransition Dynamicss′∈S∑Pss′aOptimal Successor Actiona′∈Amaxq∗(s′,a′)
Bellman Optimality Equation for q∗ ((s,a)→s′→a′)
Action Commitment: The initial state s and action a are fixed, receiving immediate reward Rsa.
Stochastic Transition: The agent transitions to successor state s′ according to the environment's transition probability Pss′a.
Greedy Successor Action (maxa′): Upon landing in state s′, the agent greedily selects the action a′ that yields the maximum possible optimal action-value q∗(s′,a′).
Core Foundation of Q-Learning: This equation directly forms the update target for off-policy algorithms like Q-Learning and DQN
Q(St,At)←Q(St,At)+αOff-policy Target from q∗Rt+1+γamaxQ(St+1,a)−Q(St,At)
Q-Learning (Off-Policy TD Control): Learns optimal action-values q∗ directly from experience tuples (St,At,Rt+1,St+1) by approximating the Bellman Optimality Equation via bootstrapping.
Q(St,At)←Q(St,At)+αOn-policy Target from qπRt+1+γQ(St+1,At+1)−Q(St,At)
SARSA (On-Policy TD Control): Learns action-values qπ for the current policy from experience transitions (St,At,Rt+1,St+1,At+1), steadily improving the policy toward optimality.
Evaluate a given policy π is a prediction problem.
Iterative application of Bellman Expectation backup.
Input:π:Policy to be evaluatedParameters:θ>0:Small threshold determining estimation accuracyγ∈[0,1]:Discount factorInitialize:V(s)∈R,∀s∈SV(terminal)=0Repeat:Δ←0For each s∈S:v←V(s)V(s)←a∈A∑π(a∣s)(Rsa+γs′∈S∑Pss′aV(s′))Δ←max(Δ,∣v−V(s)∣)Until Δ<θOutput:V≈vπ
π: Target policy being evaluated (π(a∣s) is the action selection probability).
θ: Small threshold (θ>0) defining the stopping criterion for convergence.
γ: Discount factor (γ∈[0,1]) for future rewards.
V(s): Current estimated value of state s (with V(terminal)=0).
Δ: Maximum absolute value change across all states during the current sweep (max∣v−V(s)∣).
Rsa: Expected immediate reward from taking action a in state s.
Pss′a: Transition probability to successor state s′ from state s via action a.
vπ: True state-value function under policy π that V(s) converges to.
1. InitializationV(s)∈R and π(s)∈A(s) arbitrarily for all s∈S2. Policy EvaluationLoop:Δ←0Loop for each s∈S:v←V(s)V(s)←s′,r∑p(s′,r∣s,π(s))[r+γV(s′)]Δ←max(Δ,∣v−V(s)∣)until Δ<θ(θ>0, small positive threshold)3. Policy Improvementpolicy-stable←trueFor each s∈S:old-action←π(s)π(s)←arga∈A(s)maxs′,r∑p(s′,r∣s,a)[r+γV(s′)]if old-action=π(s) then policy-stable←falseif policy-stable then stop and return V≈v∗ and π≈π∗else go to 2
Policy Evaluation (Prediction): What happens if I follow this policy?