Write the Q-learning update. With α=0.1, γ=0.9, Q(s,a)=2, reward r=1 and max⁡a′Q(s′,a′)=5, compute the new Q(s,a). Why is Q-learning called off-policy?

Reinforcement learning, Temporal-difference learning
Level L2 Elementary. Length Short. Nature Th+Mat Both.

What's being asked

Whether you can write the TD target correctly, plug in numbers, and explain what off-policy means.

Key idea

Q(s,a)←Q(s,a)+α[r+γmax⁡a′Q(s′,a′)−Q(s,a)]. The target uses the greedy action at s′, whatever action the behaviour policy actually takes next, so the agent learns Q∗ while it explores.

Steps

  1. Write the update. Here α is the learning rate (how big a step to take) and γ is the discount factor. Name the TD target r+γmax⁡a′Q(s′,a′), which is a one-step guess of the true value, and the TD error δ=target−Q(s,a), which says how wrong the current estimate was.
  2. Target: 1+0.9×5=5.5.
  3. TD error: δ=5.5−2=3.5. New value: 2+0.1×3.5=2.35.
  4. Off-policy: the data can come from an ε-greedy (or any sufficiently exploratory) behaviour policy, while the target policy being learned is the greedy one. That is why Q-learning can reuse old transitions from a replay buffer.
  5. Contrast with SARSA in one line: its target r+γQ(s′,a′) uses the action actually taken next, so it is on-policy.

Common mistakes

How long your answer should be

The update rule, a two-line computation, and two sentences on off-policy.

Last checked on 4 December 2026.

Read this

Previous in Reinforcement learning: A deterministic MDP has two states, A and B, and γ=0.9. In A you can "stay" (reward 1, remain in A) or "go" (reward 0, move to B). In B the only action is "stay" (reward 2, remain in B). Starting from V0=0, what are the values after three iterations of value iteration, and what are V∗ and the optimal policy?
Next in Reinforcement learning: An episode gives rewards r1=1, r2=0, r3=2, r4=3 and then ends. With γ=0.5, compute the returns G0,G1,G2,G3. Which recursion lets you compute them quickly?