5.1.13 · D5Reinforcement Learning Foundations

Question bank — Q-learning algorithm

2,522 words11 min readBack to topic

Before we start, some words must be crystal clear, because most traps hinge on confusing them.

Now the three words that most traps hinge on.

The picture below shows this split at a glance — one arrow is what the agent does, the other is what it learns about.

Figure — Q-learning algorithm

The figure shows all three schedules. The horizontal axis is the time step ; the vertical axis is the learning rate . The lavender curve decays gently (good), the dashed coral line stays flat at (keeps jittering), and the dotted mint curve plunges to near-zero almost immediately (stops learning too soon).

Figure — Q-learning algorithm

The figure below drives this home. The horizontal axis counts how many times we have applied ; the vertical axis (bar heights) is the worst-case gap between two Q-tables. Each bar is times the previous one, so the gap shrinks geometrically toward zero — both tables are pulled to the same unique fixed point , no matter where they started.

Figure — Q-learning algorithm

The single fact that generates most Q-learning traps: the update uses , not the value of the action you will actually take next. That is what makes the target policy greedy, and it is what separates Q-learning from SARSA.


True or false — justify

Q-learning cannot be used unless you know the transition probabilities .
False. Q-learning is model-free — it only needs sampled transitions from experience; the term replaces the expectation without ever writing down .
Q-learning learns the optimal Q-values even while the agent behaves badly (explores randomly).
True. The update bootstraps off (greedy target), so the estimate it converges to is regardless of the exploratory behaviour policy — that is exactly what "off-policy" means.
If we set the exploration rate from the very first episode, Q-learning still converges to .
False. With pure greedy behaviour many state-action pairs may never be visited, violating convergence condition 1 (every visited infinitely often); the agent can lock into a suboptimal loop.
A constant learning rate guarantees convergence to the exact .
False. Exact convergence needs and ; a constant makes , so Q keeps jittering. It gives a "good enough" estimate, useful when the environment is non-stationary.
Q-learning and SARSA produce identical updates whenever the agent happens to act greedily on that step.
True. If the next action actually taken is the greedy one, then SARSA's equals Q-learning's , so the two update rules coincide for that step — they only differ when exploration picks a non-greedy .
The discount factor can safely be set to in any Q-learning problem.
False in general. In continuing tasks lets the summed return diverge to infinity, and it also removes the contraction guarantee; it is only safe in episodic tasks where every path terminates so the sum stays finite.
Because the update uses only and one next state , Q-learning ignores long-term consequences.
False. The bootstrap term already carries the whole future value of ; long-term reward propagates backward one step per visit, so distant rewards eventually reach early states.
The in the target guarantees Q-values are always accurate estimates of true value.
False. Taking the max over noisy estimates systematically picks overestimated ones — this is maximization bias, the very reason Double Q-learning exists.

Spot the error

"Q-learning is on-policy because it updates the Q-value of the action the agent just took."
Error: the label. Updating for the taken action does not make it on-policy; the target uses (greedy), not the value of the next taken action, so it is off-policy.
"Set so the agent knows the goal is good."
Error. Terminal states must have — there is no future after termination. The goal's desirability enters through the reward on the transition into the terminal state, not through a nonzero terminal Q.
"To fix overestimation, just lower the learning rate ."
Error. Maximization bias comes from the over noisy estimates, not from step size; shrinking slows learning but the bias remains. The fix is decoupling selection and evaluation, i.e. Double Q-learning.
"With -greedy the agent explores of the time, so of updates are wrong."
Error. The one-step target depends only on the observed reward and next state and on the greedy value at — none of which cares which action the behaviour policy chose to reach . So an exploratory action still delivers a valid, unbiased sample of the greedy target; exploration changes which you update, never the correctness of the update.
"Since the Bellman operator is a contraction, Q-learning converges after one sweep."
Error. Contraction guarantees convergence in the limit of infinitely many applications/visits; each application of only shrinks the worst-case gap by a factor , so it takes many iterations, not one.
" close to means the agent is greedy; close to means it explores."
Error: confusing two knobs. controls how much future reward matters (far-sighted vs myopic); exploration vs exploitation is governed by (the behaviour policy), a completely separate parameter.
"Q-learning needs a neural network to handle large state spaces — that's what makes it Q-learning."
Error. Tabular Q-learning stores an explicit table and is the base algorithm; using a network is Function Approximation, which upgrades it to Deep Q-Networks (DQN) — a variant, not the definition.

Why questions

Why does the update use rather than the value of the action actually taken next?
Because the target policy we want to learn is the greedy one; taking the max assumes optimal future behaviour, which is exactly what makes converge to the optimal instead of some exploratory policy's value.
Why must the learning rate satisfy ?
So that the noise from individual random samples averages out and dies down over time; if the squared steps summed to infinity, the estimate would never settle and would keep oscillating around .
Why does make the Bellman optimality operator a contraction?
Applying multiplies the worst-case gap (the -norm distance) between two Q-tables by ; since shrinks that gap every time, repeated application drives any two starting estimates to the same unique fixed point .
Why can Q-learning start with arbitrary initial Q-values and still converge?
The contraction property means all differences from shrink geometrically regardless of the starting point, so the initial table only affects speed, not the final answer (given enough visits).
Why does Double Q-learning use one estimator to select the action and a different one to evaluate it?
Because the estimator that picks the max is biased upward by its own noise; a statistically independent estimator evaluating that choice does not share the same noise, so the systematic overestimation cancels.
Why does a large reward at the goal take many episodes to influence the starting state?
Value propagates only one step backward per visit (through the bootstrap term), so the goal's value must be relayed state-by-state along the path across repeated episodes before it reaches the start.
Why is exploration a requirement for convergence and not just a nice-to-have?
Concretely, imagine a two-door room where door A gives and untried door B secretly gives ; a greedy-only agent that stumbles on A first will keep choosing A forever, never sampling B, so its Q-value for B stays at its wrong initial guess and the "optimal" policy it learns is actually suboptimal. Exploration guarantees every is sampled infinitely often, which is the only way the true best action can ever reveal its higher value.

Edge cases

What is the Q-learning target when is a terminal state?
Just the reward: , because — there is no future value to bootstrap from.
What happens to the update if ?
Nothing — never changes, so no learning occurs; the agent is frozen at its initial table forever.
What happens if in a deterministic environment?
is fully replaced by the target each step; in a deterministic world this is fine and often fast, but in a stochastic one it makes updates high-variance because a single lucky/unlucky sample overwrites the estimate.
Why is dangerous specifically in a continuing (non-episodic) task?
With no terminal state the return has infinitely many terms; if they do not shrink, so the sum can diverge to infinity and no finite exists — keeps the geometric sum finite.
In a purely deterministic environment, does maximization bias still hurt?
Much less — the overestimation of comes from noise in the estimates; with deterministic rewards and transitions the sampled targets are exact once visited, so the bias largely vanishes and plain Q-learning is usually fine.
If a state-action pair is visited only once and never again, what is its final Q-value?
Whatever it became after that single update — it is stuck; without repeated visits it cannot approach , which is why "infinitely often" appears in the convergence conditions.
What does Q-learning do in a non-stationary environment (rewards change over time)?
A decaying would freeze the old (now wrong) values; a small constant is preferred so the agent keeps re-adapting to the changed rewards — trading exact convergence for responsiveness.
If two actions in a state have exactly equal Q-values, which does the greedy target pick?
The value is identical either way, so the target is unaffected; only the tie-breaking rule of the behaviour policy decides which action is actually executed, and that choice does not change what is learned.
Recall Self-test: state the one fact that generates most Q-learning traps

The update bootstraps off (the greedy/target policy value), not the value of the next action actually taken — this is what makes Q-learning off-policy and what distinguishes it from SARSA.