Value Functions and Q Functions
- 16Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is the definition of the Q function Qπ(s,a)?
16 questions
- 1
What is the definition of the Q function Qπ(s,a)?
Model answer
Qπ(s,a) is the expected sum of future rewards starting from state s, taking action a, and then following policy π thereafter.
Explanation
The Q function represents the expected return from state-action pair (s,a) under policy π.
- 2
How does policy improvement work when you have an accurate Q function?
Model answer
Define a new deterministic policy by taking the action that maximizes Q(s,a) at each state: π′(s)=argmaxaQπ(s,a). This new policy is at least as good as the original policy π.
Explanation
By choosing the action with highest Q-value, the expected return from each state is at least as large as under π, so π′ is a policy improvement.
- 3
In the 2D navigation example with a policy that always goes right, why is the new policy from argmaxQ better than the old policy but not optimal?
Model answer
The new policy goes up in the row where Q for 'up' is 1, but in the initial row, all Q-values are 0, so it defaults to right and never reaches the star. Thus it improves locally but not globally.
Explanation
The Q-function for the old policy only 'backs up' reward one step; iterating improvement would eventually yield optimality.
- 4
State the Bellman equation for the Q function of a policy π.
Model answer
Qπ(s,a)=r(s,a)+γEs′∼P,a′∼π[Qπ(s′,a′)].
Explanation
This recursive relationship expresses the Q-value in terms of immediate reward and discounted future Q-values under policy π.
- 5
State the Bellman optimality equation for the optimal Q function Q∗.
Model answer
Q∗(s,a)=r(s,a)+γEs′[maxa′Q∗(s′,a′)].
Explanation
For the optimal policy, the future Q-value is maximized over actions, leading to this equation that characterizes Q∗.
- 6
What is the Q-learning update rule for a transition (s,a,r,s′)?
Model answer
Q(s,a)←Q(s,a)+α[r+γmaxa′Q(s′,a′)−Q(s,a)].
Explanation
Q-learning uses the temporal difference target r+γmaxa′Q(s′,a′) to update the Q-value towards the optimal Q-function.
- 7
Explain why Q-learning is considered an off-policy algorithm.
Model answer
Q-learning updates the Q-function using transitions regardless of which policy generated them, and the target uses the max over actions, not the current policy's action.
Explanation
The update does not depend on the behavior policy; it directly approximates the optimal Q-function, making it off-policy.
- 8
Under what conditions is Q-learning guaranteed to converge to the optimal Q-function?
Model answer
When the state and action spaces are discrete and small enough to maintain a table, and all state-action pairs are visited infinitely often with sufficient exploration.
Explanation
In the tabular setting with full coverage, Q-learning converges to Q∗. With function approximation, it may diverge.
- 9
Why do we use a replay buffer in DQN?
Model answer
To store past transitions and sample them uniformly, breaking the temporal correlation in the data and making training more stable.
Explanation
Sampling i.i.d. from a replay buffer decorrelates the data, which is essential for neural network training.
- 10
Describe the epsilon-greedy exploration strategy.
Model answer
With probability ϵ take a random action, and with probability 1−ϵ take the greedy action (the one with highest Q-value).
Explanation
Epsilon-greedy ensures the agent explores occasionally while mostly exploiting its current knowledge.
- 11
What is Boltzmann exploration?
Model answer
Select actions with probability proportional to exp(Q(s,a)/τ), where τ is a temperature parameter controlling randomness.
Explanation
Higher Q-values get higher probability; as τ→0, it becomes greedy; as τ→∞, it becomes uniform.
- 12
Why does the target network in DQN help stabilize learning?
Model answer
It freezes the target Q-values for a fixed number of updates, making the learning target stationary and reducing harmful feedback loops.
Explanation
Without a target network, the target changes every step, causing a moving target problem that can lead to divergence.
- 13
What is the overestimation problem in Q-learning and how does double DQN address it?
Model answer
The max operator in the target can cause overestimation when Q-values are noisy. Double DQN uses one network to select the action and a second (target) network to evaluate it.
Explanation
By decoupling selection and evaluation, the noise is decorrelated, reducing overestimation bias.
- 14
What is the n-step return target for Q-learning and what is its main trade-off?
Model answer
The target is ∑i=0n−1γirt+i+γnmaxa′Q(st+n,a′). It has lower bias early in training (relying on actual rewards) but higher variance and off-policy bias.
Explanation
N-step returns accelerate learning but the reward sequence may come from a different policy, introducing bias.
- 15
Give two successful applications of DQN mentioned in the lecture.
Model answer
Playing Atari games at human-level or above, and training a robot grasping system with continuous actions.
Explanation
DQN achieved high performance on many Atari games and a 96% success rate on a robotic grasping task.
- 16
Compare PPO and DQN in terms of data efficiency and stability.
Model answer
PPO is stable and easy to tune but data-inefficient. DQN is more data-efficient but less stable and best for discrete or low-dimensional action spaces.
Explanation
PPO is on-policy and sample-inefficient; DQN is off-policy and can reuse data, but requires tricks like target networks for stability.

Ask anything
We've read this whole study set, so questions about it get the best answers.