📝 Reinforcement Learning — Quick Notes

GATE Cheatsheet

1. Key Definitions

TermDefinition
MDPTuple (S, A, P, R, γ) — States, Actions, Transition probability P(s′|s,a), Reward function R(s,a,s′), Discount factor γ ∈ [0,1)
Policy πMapping from states to actions. Deterministic: π(s) = a. Stochastic: π(a|s) = P(At=a | St=s)
Return GtGt = Rt+1 + γRt+2 + γ²Rt+3 + … = ∑k=0∞ γk Rt+k+1
State-Value Vπ(s)Expected return starting from s, following π: Vπ(s) = Eπ[Gt | St=s]
Action-Value Qπ(s,a)Expected return starting from s, taking a, then following π: Qπ(s,a) = Eπ[Gt | St=s, At=a]
Optimal V*(s)V*(s) = maxπ Vπ(s) for all s
Optimal Q*(s,a)Q*(s,a) = maxπ Qπ(s,a) for all s, a
Markov PropertyP(St+1|St) = P(St+1|S1,…,St) — future depends only on current state

2. All Bellman Equations

Bellman Expectation Equations (for policy π)

Vπ(s) = ∑a π(a|s) ∑s′ P(s′|s,a) [R(s,a,s′) + γ Vπ(s′)]

Qπ(s,a) = ∑s′ P(s′|s,a) [R(s,a,s′) + γ ∑a′ π(a′|s′) Qπ(s′,a′)]

V–Q link: Vπ(s) = ∑a π(a|s) Qπ(s,a)

Q–V link: Qπ(s,a) = ∑s′ P(s′|s,a) [R(s,a,s′) + γ Vπ(s′)]

Bellman Optimality Equations

V*(s) = maxa ∑s′ P(s′|s,a) [R(s,a,s′) + γ V*(s′)]

Q*(s,a) = ∑s′ P(s′|s,a) [R(s,a,s′) + γ maxa′ Q*(s′,a′)]

V*–Q* link: V*(s) = maxa Q*(s,a)

π*(s) = argmaxa Q*(s,a)

3. Algorithm Comparison Table

AlgorithmTypeModel?On/Off PolicyUpdate RuleKey Feature
Value Iteration DPYesN/A V(s) ← maxa ∑ P[R + γV(s′)] Combines eval + improve in one step
Policy Iteration DPYesN/A Eval: solve Vπ; Improve: π ← greedy(V) Exact evaluation, fewer iterations
TD(0) TDNoOn-policy V(s) ← V(s) + α[r + γV(s′) − V(s)] Bootstrap, step-by-step update
SARSA TDNoOn-policy Q(s,a) ← Q(s,a) + α[r + γQ(s′,a′) − Q(s,a)] Uses actual next action a′
Q-Learning TDNoOff-policy Q(s,a) ← Q(s,a) + α[r + γ maxa′ Q(s′,a′) − Q(s,a)] Uses max over next actions
DQN DeepNoOff-policy Minimize (y − Q(s,a;θ))² with replay Neural net, experience replay, target net

4. Model-Based vs Model-Free

AspectModel-BasedModel-Free
Needs P(s′|s,a)?YesNo
Needs R(s,a,s′)?YesNo
ExamplesValue Iteration, Policy IterationMC, TD(0), SARSA, Q-Learning, DQN
Sample EfficiencyHigher (uses model to plan)Lower (learns from experience only)
ApplicabilityWhen model is known or learnableWhen model is unknown or complex
ComputationCan be done offline (sweeps)Requires interaction with environment

5. On-Policy vs Off-Policy

AspectOn-PolicyOff-Policy
DefinitionEvaluates/improves the same policy used to generate dataEvaluates/improves a different (target) policy from the one generating data (behaviour policy)
ExamplesSARSA, A2C, REINFORCEQ-Learning, DQN
ExplorationMust balance explore/exploit in the learning policyCan learn optimal policy while exploring with a different policy
ConvergenceLearns value of the ε-greedy policy (safe but suboptimal)Learns value of the optimal policy directly
Data ReuseData from old policy is staleCan reuse data (experience replay)

6. Key Formulas & Update Rules

TD Error

δt = Rt+1 + γ V(St+1) − V(St)

TD(0) Update

V(St) ← V(St) + α δt

SARSA Update

Q(St,At) ← Q(St,At) + α [Rt+1 + γ Q(St+1,At+1) − Q(St,At)]

Q-Learning Update

Q(St,At) ← Q(St,At) + α [Rt+1 + γ maxa Q(St+1,a) − Q(St,At)]

Monte Carlo Update

V(St) ← V(St) + α [Gt − V(St)]

ε-Greedy Policy

a = argmaxa Q(s,a) with probability 1−ε, random action with probability ε

Value Iteration

Vk+1(s) = maxa ∑s′ P(s′|s,a) [R(s,a,s′) + γ Vk(s′)]

Policy Gradient (REINFORCE)

θ ← θ + α ∇θ log π(a|s;θ) · Gt

Q-Learning Convergence Conditions

∑ αt = ∞ and ∑ αt² < ∞ (e.g., αt = 1/t), plus all (s,a) pairs visited infinitely often.

7. Common GATE Question Patterns

  1. Compute V(s) or Q(s,a): Given an MDP (small grid, 2–3 states), apply Bellman equations iteratively. Expect 1–2 iterations of value iteration.
  2. Identify optimal policy: Given V* or Q* values, extract π*(s) = argmaxa Q*(s,a).
  3. One-step TD/Q-learning update: Given current Q-values, (s,a,r,s′), α, γ — compute the new Q-value. This is a very common numerical question.
  4. SARSA vs Q-learning: Explain why they differ (on-policy vs off-policy) or compute different updates for the same transition.
  5. Discount factor effect: What happens to V(s) as γ → 0 or γ → 1?
  6. Model-free vs model-based: Classify algorithms. Which ones need transition probabilities?
  7. MDP formulation: Given a word problem, define S, A, P, R, γ.
  8. Convergence: Under what conditions does Q-learning converge? (Robbins-Monro conditions on α)

8. Tips & Common Mistakes

⚠ Common Mistakes

  • Confusing V and Q: V(s) is over states only; Q(s,a) is over state-action pairs. V*(s) = maxa Q*(s,a).
  • Wrong subscript in returns: Gt starts with Rt+1, NOT Rt.
  • SARSA vs Q-Learning target: SARSA uses Q(s′,a′) where a′ is the actual next action. Q-Learning uses maxa′ Q(s′,a′).
  • Forgetting γ in updates: The discount factor multiplies the next-state value, not the reward.
  • Terminal states: V(sterminal) = 0 always. Don’t bootstrap from terminal states.
  • Policy iteration ≠ value iteration: PI does full evaluation then improves; VI does one sweep of Bellman optimality.

💡 Quick Tips

  • For numerical GATE problems, write out the full update equation with numbers before simplifying.
  • Draw the state transition diagram for small MDPs — it makes Bellman equations much clearer.
  • γ = 0 means the agent is completely myopic (only immediate reward matters).
  • γ close to 1 means the agent is far-sighted (future rewards are almost as important as immediate).
  • In a deterministic MDP, the ∑s′ P(s′|s,a) collapses to a single successor state, simplifying all equations.
  • Q-learning is off-policy because it updates toward maxa′ (greedy) regardless of the action actually taken.