Revised working edition

Lecture 20: Value Iteration and Q-learning

Lecturer: Jiantao Jiao
Scribes: Chinmay Maheshwari and Sandy Tanwisuth

EE290: Theory of Multi-armed Bandits and Reinforcement Learning
Original lecture: 1 April 2021
Editorial revision for author review: 9 October 2026

Contents

Can a learner estimate a good policy without storing an estimate of the entire transition model? This lecture compares plug-in value iteration with synchronous Q-learning in a finite-horizon problem. It then examines how a particular learning rate controls the accumulation of sampling error.

Editorial status. This source preserves the original setup, both algorithms, the theorem claim, the weight identities, the proof outline, the appendix lemma, and all four references. Review notes identify assumptions and gaps that remain unresolved. Routine index and function-domain corrections are made explicitly; the original theorem is not presented as independently verified.

1 Recap: plug-in estimates

The preceding lecture introduced estimates of transition and reward functions for offline learning. Its main comparison was between the value of a policy in the true model and in the estimated, or plug-in, model. Small transition and reward errors can yield small value-function errors under suitable bounds. Here the focus shifts to learning action values directly.

2 Introduction

We study a finite-horizon setting with time-dependent transitions and rewards. The data access in the algorithms below permits fresh samples for each state, action, and time step. This is stronger than access to an arbitrary fixed batch of trajectories: it is a generative-model sampling assumption. The source’s use of “offline” should be read in that specified sense. Additional discussion appears in the Princeton lecture notes [1].

3 Setting

Let 𝒮\mathcal S and 𝒜\mathcal A be finite state and action spaces, with cardinalities SS and AA, and let HH be the horizon. At time h∈[H]h\in[H], transitions follow Ph(s′∣s,a),∑s′∈𝒮Ph(s′∣s,a)=1.P_h(s'\mid s,a),\qquad \sum_{s'\in\mathcal S}P_h(s'\mid s,a)=1. The augmented state space 𝒮aug={(s,h):s∈𝒮,h∈[H]}\mathcal S_{\mathrm{aug}}=\{(s,h):s\in\mathcal S,\ h\in[H]\} separates different times into disjoint layers 𝒮h\mathcal S_h. A time-dependent process can then be represented by P((s′,h′)∣(s,h),a)=Ph(s′∣s,a)𝟏{h′=h+1}.P((s',h')\mid(s,h),a)=P_h(s'\mid s,a)\mathbf{1}\{h'=h+1\}. At the final layer, a terminal layer or absorbing terminal state is required; the displayed formula describes transitions between nonterminal layers. We use zero terminal values at H+1H+1.

4 Algorithms for time-dependent finite-horizon problems

4.1 Plug-in value iteration

For clarity, assume rewards are known and deterministic, rh(s,a)∈[0,Rmax].r_h(s,a)\in[0,R_{\max}]. The original motivation is that estimating an entire transition distribution can be more demanding than estimating a scalar mean reward. Uniform coverage is implemented here by drawing NN independent samples from every Ph(⋅∣s,a)P_h(\cdot\mid s,a).

For each (s,h,a)(s,h,a), let s1′,…,sN′s'_1,\ldots,s'_N be those samples and define P̂h(s′∣s,a)=1N∑i=1N𝟏{s′=si′}.\widehat P_h(s'\mid s,a)=\frac1N\sum_{i=1}^N\mathbf{1}\{s'=s'_i\}. Starting from V̂H+1=0\widehat V_{H+1}=0, compute backward in time: Q̂h(s,a)=rh(s,a)+∑s′P̂h(s′∣s,a)V̂h+1(s′),V̂h(s)=maxa∈𝒜Q̂h(s,a).\begin{align} \widehat Q_h(s,a)&=r_h(s,a)+\sum_{s'}\widehat P_h(s'\mid s,a)\widehat V_{h+1}(s'),\\ \widehat V_h(s)&=\max_{a\in\mathcal A}\widehat Q_h(s,a). \end{align} This is finite-horizon dynamic programming in the estimated model [2]. If the transition model is known exactly, the same recursion recovers the optimal action values. Performance guarantees for the estimated-model procedure are discussed in [3].

4.2 Q-learning

Q-learning stores action values instead of a transition table. At each iteration, it samples a successor state for every state-action-time triple and updates its value estimate. This reduces the storage associated with explicitly representing PhP_h; it does not eliminate the need for adequate sampling.

Initialize Qh(0)(s,a)=0Q_h^{(0)}(s,a)=0 for h∈[H+1]h\in[H+1] and keep VH+1(t)=0V_{H+1}^{(t)}=0 for all tt. For each iteration t=1,…,Nt=1,\ldots,N and each (s,h,a)(s,h,a):

  1. Draw a fresh st′∼Ph(⋅∣s,a)s'_t\sim P_h(\cdot\mid s,a).

  2. Update Equation (1)Qh(t)(s,a)=(1−αt)Qh(t−1)(s,a)+αt(rh(s,a)+Vh+1(t−1)(st′)).\begin{equation} \label{eq:update} Q_h^{(t)}(s,a)=(1-\alpha_t)Q_h^{(t-1)}(s,a) +\alpha_t\bigl(r_h(s,a)+V_{h+1}^{(t-1)}(s'_t)\bigr). \end{equation}

  3. Set Vh(t)(s)=max⁡aQh(t)(s,a)V_h^{(t)}(s)=\max_aQ_h^{(t)}(s,a).

The source loops through h=H,H−1,…,1h=H,H-1,\ldots,1. Because the right-hand side uses iteration t−1t-1, this is a synchronous update even when implemented in that order. The value function has argument ss, not (s,a)(s,a); the latter was a notation error in the original pseudocode.

4.3 Expanding the recursion

Define γt(i)=αi∏j=i+1t(1−αj),γt(0)=∏j=1t(1−αj).\gamma_t^{(i)}=\alpha_i\prod_{j=i+1}^t(1-\alpha_j),\qquad \gamma_t^{(0)}=\prod_{j=1}^t(1-\alpha_j). Unrolling equation (1) gives Qh(t)(s,a)=γt(0)Qh(0)(s,a)+∑i=1tγt(i)(rh(s,a)+Vh+1(i−1)(si′)).Q_h^{(t)}(s,a)=\gamma_t^{(0)}Q_h^{(0)}(s,a) +\sum_{i=1}^t\gamma_t^{(i)}\bigl(r_h(s,a)+V_{h+1}^{(i-1)}(s'_i)\bigr). In general, ∑i=1tγt(i)=1−γt(0)\sum_{i=1}^t\gamma_t^{(i)}=1-\gamma_t^{(0)}. The source’s identity ∑iγt(i)=1\sum_i\gamma_t^{(i)}=1 holds when α1=1\alpha_1=1, as it does for both learning-rate choices considered below. With that condition, Equation (2)Qh(t)(s,a)=rh(s,a)+∑i=1tγt(i)Vh+1(i−1)(si′).\begin{equation} \label{eq:expanded} Q_h^{(t)}(s,a)=r_h(s,a)+\sum_{i=1}^t\gamma_t^{(i)}V_{h+1}^{(i-1)}(s'_i). \end{equation} For αt=1/t\alpha_t=1/t, every weight is γt(i)=1/t\gamma_t^{(i)}=1/t. Other schedules change the relative contribution of early and recent iterates. The analysis studies αt=H+1H+t,\alpha_t=\frac{H+1}{H+t}, which equals 1/t1/t at t=1t=1 and exceeds it for t>1t>1 when H>0H>0.

4.4 The theorem as stated in the original notes

For the learning rate above, the source claims that, with probability at least 1−δ1-\delta, Equation (3)∥1t∑i=1tQh(i)−Qh*∥∞≤H5log⁡(HSA/δ)t.\begin{equation} \label{eq:original-claim} \left\lVert \frac 1t\sum_{i=1}^t Q_h^{(i)}-Q_h^*\right\rVert_\infty \leq\sqrt{\frac{H^5\log(HSA/\delta)}{t}}. \end{equation} Here Qh*Q_h^* is the optimal action-value function of the actual system.

Mathematical review note. The statement does not specify whether it holds for a fixed tt or simultaneously over all t≤Nt\leq N, suppresses the dependence on RmaxR_{\max}, and states a unit constant although the proof uses unspecified constants. Its averaging argument also needs to account for the initial iterate and time-uniform concentration. Equation equation (3) is retained as the original lecture claim, not adopted here as a corrected theorem. A rigorous revision requires an explicit probability event and a completed finite-sample argument.

4.5 Weight identities

The following bounds are taken from Lemma 4.1 of [4], as cited in the original lecture:

Lemma 1 (Weight bounds used in the proof outline). For αt=(H+1)/(H+t)\alpha_t=(H+1)/(H+t), ∑i=1t(γt(i))2≤2Ht,∑t=i∞γt(i)≤1+1H.\sum_{i=1}^t(\gamma_t^{(i)})^2\leq\frac{2H}{t}, \qquad \sum_{t=i}^{\infty}\gamma_t^{(i)}\leq1+\frac1H.

The first controls the squared weights in a concentration bound. The second limits the total contribution of one historical iterate to later updates. These are different roles; neither is simply an unqualified statement that all individual weights decay rapidly.

4.6 Proof outline and its remaining obligations

Subtracting the Bellman equation for Qh*Q_h^* from equation (2), and inserting Vh+1*(si′)V_{h+1}^*(s'_i), gives Qh(j)(s,a)−Qh*(s,a)=∑i=1jγj(i)(Vh+1(i−1)(si′)−Vh+1*(si′))+∑i=1jγj(i)(Vh+1*(si′)−(PhVh+1*)(s,a)).\begin{align} Q_h^{(j)}(s,a)-Q_h^*(s,a) ={}&\sum_{i=1}^j\gamma_j^{(i)} \bigl(V_{h+1}^{(i-1)}(s'_i)-V_{h+1}^*(s'_i)\bigr)\nonumber\\ &+\sum_{i=1}^j\gamma_j^{(i)} \bigl(V_{h+1}^*(s'_i)-(P_hV_{h+1}^*)(s,a)\bigr). \end{align} Let Δj,h(s,a)\Delta_{j,h}(s,a) denote the second sum. For fixed (j,h,s,a)(j,h,s,a), it is a weighted sum of centered independent random variables under the stated sampling model. Since 0≤Vh+1*≤HRmax0\leq V_{h+1}^*\leq HR_{\max}, a Hoeffding bound has scale HRmaxlog⁡(1/ε)∑i=1j(γj(i))2≲RmaxH3log⁡(1/ε)j.HR_{\max}\sqrt{ \log(1/\varepsilon)\sum_{i=1}^j(\gamma_j^{(i)})^2} \lesssim R_{\max}\sqrt{\frac{H^3\log(1/\varepsilon)}{j}}. Universal factors are suppressed in this display. A union bound over the state-action-time triples gives a factor involving HSAHSA; controlling every iterate used by the subsequent sum also requires a justified allocation of the failure probability across jj.

Write ej,h=∥Qh(j)−Qh*∥∞e_{j,h}=\left\lVert Q_h^{(j)}-Q_h^*\right\rVert_\infty and let dj,hd_{j,h} be a nonnegative uniform bound on |Δj,h(s,a)||\Delta_{j,h}(s,a)|. The appendix lemma yields ej,h≤∑i=1jγj(i)ei−1,h+1+dj,h.e_{j,h}\leq\sum_{i=1}^j\gamma_j^{(i)}e_{i-1,h+1}+d_{j,h}. Summing over jj and interchanging the finite sums gives ∑j=1tej,h≤∑i=1t(∑j=itγj(i))ei−1,h+1+βt,h≤(1+1H)∑i=0t−1ei,h+1+βt,h,βt,h=∑j=1tdj,h.\begin{align} \sum_{j=1}^t e_{j,h} &\leq\sum_{i=1}^t\left(\sum_{j=i}^t\gamma_j^{(i)}\right)e_{i-1,h+1} +\beta_{t,h}\\ &\leq\left(1+\frac1H\right)\sum_{i=0}^{t-1}e_{i,h+1}+\beta_{t,h}, \qquad \beta_{t,h}=\sum_{j=1}^t d_{j,h}. \end{align} This repairs the source’s mixed i,j,ti,j,t indices without changing the intended summation. The sum of j−1/2j^{-1/2} terms has order t\sqrt t, so the intended sampling contribution is of order RmaxH3tR_{\max}\sqrt{H^3t}, up to logarithms.

The original notes then propagate the recursion through HH layers and write ∑i=1tei,h≲C[1+(1+1H)+⋯+(1+1H)H]H3t≲CH5t.\sum_{i=1}^t e_{i,h} \lesssim C\left[1+\left(1+\frac1H\right)+\cdots+ \left(1+\frac1H\right)^H\right]\sqrt{H^3t} \lesssim C\sqrt{H^5t}. This is the source’s scaling argument, with rewards implicitly normalized and logarithms omitted. The i=0i=0 terms require separate accounting when the sums are compared across layers. Finally, convexity of the norm gives ∥1t∑i=1tQh(i)−Qh*∥∞≤1t∑i=1tei,h.\left\lVert \frac 1t\sum_{i=1}^tQ_h^{(i)}-Q_h^*\right\rVert_\infty \leq\frac1t\sum_{i=1}^te_{i,h}. Thus an appropriate bound on the sum of errors would imply a bound for the averaged iterate. The argument explains the intended H5/2/tH^{5/2}/\sqrt t scale; it leaves the exact statement in equation (3) unresolved.

5 The maximum operator is nonexpansive

Lemma 2. Let Q,Q′Q,Q' be real-valued functions on a finite state-action space. Define V(s)=max⁡aQ(s,a)V(s)=\max_aQ(s,a) and V′(s)=max⁡aQ′(s,a)V'(s)=\max_aQ'(s,a). Then ∥V−V′∥∞≤∥Q−Q′∥∞.\left\lVert V-V'\right\rVert_\infty\leq\left\lVert Q-Q'\right\rVert_\infty.

Proof. For every s,as,a, Q(s,a)=Q(s,a)−Q′(s,a)+Q′(s,a)≤|Q(s,a)−Q′(s,a)|+Q′(s,a).Q(s,a)=Q(s,a)-Q'(s,a)+Q'(s,a) \leq|Q(s,a)-Q'(s,a)|+Q'(s,a). Taking maxima yields maxaQ(s,a)−maxaQ′(s,a)≤maxa|Q(s,a)−Q′(s,a)|.\max_aQ(s,a)-\max_aQ'(s,a) \leq\max_a|Q(s,a)-Q'(s,a)|. Swap QQ and Q′Q' to obtain the same inequality with the opposite difference. Hence |V(s)−V′(s)|≤maxa|Q(s,a)−Q′(s,a)|.|V(s)-V'(s)|\leq\max_a|Q(s,a)-Q'(s,a)|. Taking the maximum over ss proves the claim. ◻

The original notes impose nonnegative QQ-values. The proof does not use that restriction; it is valid for arbitrary real values. This observation is an explicit correction of an unnecessary assumption, not a new claim about Q-learning convergence.

References

[1]

C. Jin, B. Wang, Y. Yan, and Z. Li. ELE524: Foundations of Reinforcement Learning, Lecture 6. Princeton University, Spring 2020.

[2]

M. L. Puterman. Markov Decision Processes: Discrete Stochastic Dynamic Programming. John Wiley & Sons, 2014.

[3]

C. Jin, B. Wang, Y. Yan, and Z. Li. ELE524: Foundations of Reinforcement Learning, Lecture 5. Princeton University, Spring 2020.

[4]

C. Jin, Z. Allen-Zhu, S. Bubeck, and M. I. Jordan. Is Q-Learning Provably Efficient? Advances in Neural Information Processing Systems, 31, 2018.