Skip to content

Value-Based Methods

Before policy-gradient methods, the classical approach to RL was to learn a value function and derive the policy from it. The idea: if you know how good every state (or every state–action pair) is, you can act greedily with respect to those values.

From the rewards and return page, recall:

Vπ(s)=Eπ[Gtst=s],Qπ(s,a)=Eπ[Gtst=s,at=a]V^\pi(s) = \mathbb{E}_\pi \left[ G_t \mid s_t = s \right], \quad Q^\pi(s, a) = \mathbb{E}_\pi \left[ G_t \mid s_t = s, a_t = a \right]

VπV^\pi measures state quality; QπQ^\pi measures state–action quality. The advantage is the difference:

Aπ(s,a)=Qπ(s,a)Vπ(s)A^\pi(s, a) = Q^\pi(s, a) - V^\pi(s)

If we have Q(s,a)Q^*(s, a) — the optimal Q-function — the optimal policy is simply:

π(s)=argmaxaQ(s,a)\pi^*(s) = \arg\max_{a} Q^*(s, a)

This is the appeal of value-based methods: no separate policy network is required. The policy falls out of the Q-function.

The Q-function obeys a recursive identity. Splitting the return Gt=rt+γGt+1G_t = r_t + \gamma G_{t+1}:

Qπ(s,a)=E[rt+γQπ(st+1,at+1)st=s,at=a]Q^\pi(s, a) = \mathbb{E}\big[ r_t + \gamma \, Q^\pi(s_{t+1}, a_{t+1}) \,\big|\, s_t = s, a_t = a \big]

For the optimal Q-function (acting greedily forever), the next action is the argmax:

Q(s,a)=Es[r+γmaxaQ(s,a)]\boxed{\, Q^*(s, a) = \mathbb{E}_{s'} \left[ r + \gamma \max_{a'} Q^*(s', a') \right] \,}

This is the Bellman optimality equation. It is the cornerstone of value-based RL — every method in this section is, at heart, a way of solving (or approximating) it.

EquationNameUsed by
Vπ(s)=E[r+γVπ(s)]V^\pi(s) = \mathbb{E}[r + \gamma V^\pi(s')]Bellman expectation (V)Policy evaluation
Qπ(s,a)=E[r+γQπ(s,a)]Q^\pi(s, a) = \mathbb{E}[r + \gamma Q^\pi(s', a')]Bellman expectation (Q)SARSA
Q(s,a)=E[r+γmaxaQ(s,a)]Q^*(s, a) = \mathbb{E}[r + \gamma \max_{a'} Q^*(s', a')]Bellman optimalityQ-learning, DQN

Interactive: Watch Value Iteration Propagate

Section titled “Interactive: Watch Value Iteration Propagate”

Five-state chain MDP. Only the rightmost state gives reward +1. Each backup of the Bellman equation updates VV one step. Drag the iteration slider and watch the reward signal flow leftward — exactly one cell per pass — and notice how lowering γ\gamma shortens its reach.

If we knew the transition probabilities P(ss,a)P(s' \mid s, a), we could solve the Bellman equation directly (dynamic programming). But we usually don’t. Two sample-based methods bridge that gap:

Monte Carlo (MC). Run a full episode, then for each visited (s,a)(s, a) set the target to the actual observed return GtG_t. Unbiased, but high variance and requires episode termination.

Temporal Difference (TD). Use the Bellman equation to bootstrap — update toward r+γQ(s,a)r + \gamma Q(s', a') using the current estimate of QQ. Biased (the bootstrap target is also an estimate), but lower variance and works online, before the episode ends.

The TD update for Q is:

Q(s,a)Q(s,a)+α[r+γmaxaQ(s,a)TD targetQ(s,a)]Q(s, a) \leftarrow Q(s, a) + \alpha \big[ \underbrace{r + \gamma \max_{a'} Q(s', a')}_{\text{TD target}} - Q(s, a) \big]

The quantity in brackets is the TD error δ\delta — the difference between what we believed Q(s,a)Q(s,a) was and what one step of bootstrap evidence suggests.

Both are TD methods, differing only in what they put in the target:

MethodTargetType
SARSAr+γQ(s,a)r + \gamma\, Q(s', a'), aπa' \sim \piOn-policy — learns the value of the policy actually being followed
Q-learningr+γmaxaQ(s,a)r + \gamma \max_{a'} Q(s', a')Off-policy — learns the value of the greedy policy regardless of what action was taken

The off-policy nature of Q-learning is what makes it work with replay buffers in DQN — old experience from a different policy is still useful.

The next pages cover tabular Q-learning with a worked gridworld example, and DQN — extending Q-learning to high-dimensional state spaces with neural networks.

  • Sutton & Barto. Reinforcement Learning: An Introduction (2nd ed., 2018), ch. 6 — TD learning, Sarsa, Q-learning. Free official PDF
  • Watkins & Dayan. Q-learning. Machine Learning 8, 1992 — the convergence proof. Springer