Chapter 9 · Book pp. 197–241

On-policy Prediction with Approximation

The value function is no longer a table but a parameterised function $\hat v(s,\mathbf w)\approx v_\pi(s)$ with $d\ll|\mathcal S|$ weights. Updating one state now generalises to many others — more powerful, but harder to analyse. This chapter covers estimating $v_\pi$ from on-policy data.

$\overline{\mathrm{VE}}$ objective SGD vs semi-gradient Linear TD fixed point Polynomial · Fourier · Coarse · Tile · RBF Step-size rule ANNs LSTD Kernels Interest & emphasis
Exam focus for this chapter

Function approximation also makes RL applicable to partially observable problems: if $\hat v$ cannot depend on some aspect of the state, it is as if that aspect is unobservable. (It cannot, however, augment the state with memories of past observations.)

9.1 Value-function approximation

Every prediction method shifts the estimate at some state toward an update target $u$: write $s\mapsto u$.

MethodUpdate $s\mapsto u$
Monte Carlo$S_t\mapsto G_t$
TD(0)$S_t\mapsto R_{t+1}+\gamma\hat v(S_{t+1},\mathbf w_t)$
n-step TD$S_t\mapsto G_{t:t+n}$
DP policy evaluation$s\mapsto\E_\pi[R_{t+1}+\gamma\hat v(S_{t+1},\mathbf w_t)\mid S_t=s]$ (arbitrary $s$)

Each update is a supervised-learning training example (input $s$, desired output $u$) — "function approximation" when outputs are numbers. But not every supervised method suits RL; RL needs methods that:

9.2 The prediction objective $\overline{\mathrm{VE}}$

With approximation, making one state more accurate makes others less accurate — so we must say which states we care about, via a distribution $\mu(s)\ge0$, $\sum_s\mu(s)=1$:

$$\overline{\mathrm{VE}}(\mathbf w)\doteq\sum_{s\in\mathcal S}\mu(s)\Big[v_\pi(s)-\hat v(s,\mathbf w)\Big]^2$$
Mean square value error(9.1)

$\sqrt{\overline{\mathrm{VE}}}$ (root VE) is often plotted. Usually μ = fraction of time spent in $s$ — the on-policy distribution (stationary distribution under π for continuing tasks). For episodic tasks, with start distribution $h(s)$ and $\eta(s)$ = expected time steps in $s$ per episode:

$$\eta(s)=h(s)+\sum_{\bar s}\eta(\bar s)\sum_a\pi(a\mid\bar s)p(s\mid\bar s,a),\qquad \mu(s)=\frac{\eta(s)}{\sum_{s'}\eta(s')}$$
On-policy distribution (episodic)(9.2), (9.3)

With discounting, treat $1-\gamma$ as termination by putting a factor γ in the second term of (9.2).

9.3 Stochastic-gradient and semi-gradient methods

$\mathbf w=(w_1,\dots,w_d)^\top$; $\hat v(s,\mathbf w)$ differentiable in $\mathbf w$. Suppose each example gives the true value $S_t\mapsto v_\pi(S_t)$, with states drawn from μ. SGD takes a small step down the gradient of that example's squared error:

$$\mathbf w_{t+1}\doteq\mathbf w_t-\tfrac12\alpha\nabla\big[v_\pi(S_t)-\hat v(S_t,\mathbf w_t)\big]^2=\mathbf w_t+\alpha\big[v_\pi(S_t)-\hat v(S_t,\mathbf w_t)\big]\nabla\hat v(S_t,\mathbf w_t)$$
SGD on the squared value error(9.4), (9.5)

$\nabla f(\mathbf w)\doteq\big(\tfrac{\partial f}{\partial w_1},\dots,\tfrac{\partial f}{\partial w_d}\big)^\top$ (9.6). Why only a small step? We don't want zero error on one example — we want a balance of errors across states. Convergence results assume α decreases per (2.7) ⇒ SGD converges to a local optimum.

In practice $v_\pi(S_t)$ is unknown; substitute a target $U_t$:

$$\mathbf w_{t+1}\doteq\mathbf w_t+\alpha\big[U_t-\hat v(S_t,\mathbf w_t)\big]\nabla\hat v(S_t,\mathbf w_t)$$
General SGD for state-value prediction(9.7)

If $U_t$ is unbiased ($\E[U_t|S_t=s]=v_\pi(s)$) — e.g. the MC return $G_t$ — convergence to a local optimum is guaranteed (decreasing α).

Gradient Monte Carlo Algorithm for Estimating v̂ ≈ vπon-policytrue gradientno bootstrap
Input: the policy π to be evaluated
Input: a differentiable function v̂ : S × ℝᵈ → ℝ
Algorithm parameter: step size α > 0
Initialize value-function weights w ∈ ℝᵈ arbitrarily (e.g., w = 0)
Loop forever (for each episode):
    Generate an episode S₀, A₀, R₁, S₁, A₁, …, R_T, S_T using π
    Loop for each step of episode, t = 0, 1, …, T − 1:
        w ← w + α [G_t − v̂(S_t, w)] ∇v̂(S_t, w)
Semi-gradient methods

Bootstrapping targets ($G_{t:t+n}$, the DP target, $R+\gamma\hat v(S',\mathbf w)$) depend on $\mathbf w_t$, so they're biased and the step (9.4)→(9.5), which assumes the target is independent of $\mathbf w$, is invalid. Bootstrapping methods account for the effect of $\mathbf w$ on the estimate but ignore its effect on the target — they include only part of the gradient: semi-gradient methods.

Semi-gradient TD(0) for estimating v̂ ≈ vπon-policybootstrapssemi-gradient
Input: the policy π to be evaluated
Input: a differentiable function v̂ : S⁺ × ℝᵈ → ℝ such that v̂(terminal,·) = 0
Algorithm parameter: step size α > 0
Initialize value-function weights w ∈ ℝᵈ arbitrarily (e.g., w = 0)
Loop for each episode:
    Initialize S
    Loop for each step of episode:
        Choose A ∼ π(·|S)
        Take action A, observe R, S'
        w ← w + α [R + γ v̂(S', w) − v̂(S, w)] ∇v̂(S, w)
        S ← S'
    until S is terminal

State aggregation: group states, one weight per group; $\nabla\hat v$ is 1 for the state's group component and 0 elsewhere — a special case of SGD (9.7).

Example 9.1 — the 1000-state random walk

States 1–1000, start at 500. Each step jumps to one of the 100 neighbours on the left or 100 on the right, uniformly; jumps past an edge terminate (−1 on the left, +1 on the right; e.g. state 1 terminates left w.p. ½). True $v_\pi$ is nearly a straight line, flattening slightly in the last 100 states at each end. State aggregation: 10 groups of 100 states.

Try it: Figures 9.1 and 9.2 (left) — state aggregation with gradient MC and semi-gradient TD(0)

On-policy state distribution μ(s)

9.4 Linear methods

$$\hat v(s,\mathbf w)\doteq\mathbf w^\top\mathbf x(s)\doteq\sum_{i=1}^dw_ix_i(s),\qquad \nabla\hat v(s,\mathbf w)=\mathbf x(s)$$
Linear value function; its gradient is the feature vector(9.8)

$\mathbf x(s)$ is the feature vector; each $x_i:\mathcal S\to\mathbb R$ is a feature (a basis function). The SGD update becomes $\mathbf w_{t+1}\doteq\mathbf w_t+\alpha\big[U_t-\hat v(S_t,\mathbf w_t)\big]\mathbf x(S_t)$.

The TD fixed point

$$\mathbf w_{t+1}\doteq\mathbf w_t+\alpha\big(R_{t+1}+\gamma\mathbf w_t^\top\mathbf x_{t+1}-\mathbf w_t^\top\mathbf x_t\big)\mathbf x_t = \mathbf w_t+\alpha\Big(R_{t+1}\mathbf x_t-\mathbf x_t(\mathbf x_t-\gamma\mathbf x_{t+1})^\top\mathbf w_t\Big)$$
Linear semi-gradient TD(0)(9.9)
$$\E[\mathbf w_{t+1}\mid\mathbf w_t]=\mathbf w_t+\alpha(\mathbf b-\mathbf A\mathbf w_t),\qquad \mathbf b\doteq\E[R_{t+1}\mathbf x_t]\in\mathbb R^d,\quad \mathbf A\doteq\E\big[\mathbf x_t(\mathbf x_t-\gamma\mathbf x_{t+1})^\top\big]\in\mathbb R^{d\times d}$$
Expected update(9.10), (9.11)
$$\mathbf b-\mathbf A\mathbf w_{TD}=\mathbf 0\;\Rightarrow\;\mathbf w_{TD}\doteq\mathbf A^{-1}\mathbf b$$
TD fixed point — where linear semi-gradient TD(0) converges(9.12)
Why it converges: A is positive definite (proof sketch)

Write $\E[\mathbf w_{t+1}|\mathbf w_t]=(\mathbf I-\alpha\mathbf A)\mathbf w_t+\alpha\mathbf b$ (9.13): only $\mathbf A$ matters for stability. If $\mathbf A$ is positive definite ($\mathbf y^\top\mathbf A\mathbf y>0$ for $\mathbf y\ne0$), $\mathbf w$ is shrunk toward the fixed point for small α, and $\mathbf A^{-1}$ exists. For continuing tasks, $\mathbf A=\mathbf X^\top\mathbf D(\mathbf I-\gamma\mathbf P)\mathbf X$ (D = diag(μ), P = transition matrix under π, X = feature matrix). The key matrix $\mathbf D(\mathbf I-\gamma\mathbf P)$ has positive diagonal, negative off-diagonal; row sums are positive (P stochastic, γ < 1) and column sums are $\mathbf 1^\top\mathbf D(\mathbf I-\gamma\mathbf P)=\boldsymbol\mu^\top-\gamma\boldsymbol\mu^\top\mathbf P=(1-\gamma)\boldsymbol\mu^\top>0$ because μ is stationary ($\boldsymbol\mu=\mathbf P^\top\boldsymbol\mu$). Hence positive definite ⇒ on-policy TD(0) is stable. This crucially uses the on-policy distribution; with other update distributions bootstrapping + FA can diverge (Ch 11).

$$\overline{\mathrm{VE}}(\mathbf w_{TD})\le\frac{1}{1-\gamma}\min_{\mathbf w}\overline{\mathrm{VE}}(\mathbf w)$$
Error bound at the TD fixed point (continuing case)(9.14)
TD vs MC with function approximation

TD's asymptotic error can be up to $\frac{1}{1-\gamma}$ times the best possible (which MC attains) — large when γ ≈ 1. But TD has much lower variance and learns faster. Which wins depends on the problem, the approximation, and how long learning continues. Analogous bounds hold for linear semi-gradient DP and (next chapter) semi-gradient Sarsa(0); for n-step methods the bound tightens as n grows, approaching 0 as n → ∞.

n-step semi-gradient TD

$$\begin{aligned}\mathbf w_{t+n}&\doteq\mathbf w_{t+n-1}+\alpha\big[G_{t:t+n}-\hat v(S_t,\mathbf w_{t+n-1})\big]\nabla\hat v(S_t,\mathbf w_{t+n-1})\\ G_{t:t+n}&\doteq R_{t+1}+\gamma R_{t+2}+\dots+\gamma^{n-1}R_{t+n}+\gamma^n\hat v(S_{t+n},\mathbf w_{t+n-1})\end{aligned}$$
n-step semi-gradient TD update and return(9.15), (9.16)
n-step semi-gradient TD for estimating v̂ ≈ vπon-policybootstrapssemi-gradient
Input: the policy π to be evaluated
Input: a differentiable function v̂ : S⁺ × ℝᵈ → ℝ such that v̂(terminal,·) = 0
Algorithm parameters: step size α > 0, a positive integer n
Initialize value-function weights w arbitrarily (e.g., w = 0)
All store and access operations (S_t and R_t) can take their index mod n + 1
Loop for each episode:
    Initialize and store S₀ ≠ terminal
    T ← ∞
    Loop for t = 0, 1, 2, …:
        If t < T, then:
            Take an action according to π(·|S_t)
            Observe and store the next reward as R_{t+1} and the next state as S_{t+1}
            If S_{t+1} is terminal, then T ← t + 1
        τ ← t − n + 1
        If τ ≥ 0:
            G ← Σ_{i=τ+1}^{min(τ+n,T)} γ^{i−τ−1} R_i
            If τ + n < T, then: G ← G + γⁿ v̂(S_{τ+n}, w)          (G_{τ:τ+n})
            w ← w + α [G − v̂(S_τ, w)] ∇v̂(S_τ, w)
    Until τ = T − 1
Try it: Figure 9.2 (right) — n-step semi-gradient TD with 20 groups of 50 states

Unweighted RMS error over all 1000 states at the end of each of the first 10 episodes, averaged over runs — the same measure as Figure 7.2, and strikingly similar results.

9.5 Feature construction for linear methods

Features are how we add prior domain knowledge: they should correspond to aspects of the state along which generalisation is appropriate. Limitation of linear forms: no interactions between features (e.g. pole balancing: high angular velocity is good or bad depending on the angle) unless we add features for combinations.

9.5.1 Polynomials

$$x_i(s)=\prod_{j=1}^{k}s_j^{\,c_{i,j}},\qquad c_{i,j}\in\{0,1,\dots,n\}\;\Rightarrow\;(n+1)^k\text{ features}$$
Order-n polynomial basis for k state dimensions(9.17)

E.g. $\mathbf x(s)=(1,s_1,s_2,s_1s_2)^\top$: the constant allows affine functions, the product captures interaction. Ex 9.2: each of the $k$ exponents independently takes $n+1$ values ⇒ $(n+1)^k$. Ex 9.3: $(1,s_1,s_2,s_1s_2,s_1^2,s_2^2,s_1s_2^2,s_1^2s_2,s_1^2s_2^2)$ is $n=2$, $k=2$ with $\mathbf c_i$ ranging over all of $\{0,1,2\}^2$. Exponential growth in $k$ ⇒ select subsets. Not recommended for online learning.

9.5.2 Fourier basis

$$x_i(s)=\cos(i\pi s),\ s\in[0,1],\ i=0,\dots,n \qquad\qquad x_i(\mathbf s)=\cos\big(\pi\,\mathbf s^\top\mathbf c^i\big),\ c^i_j\in\{0,\dots,n\}$$
Fourier cosine basis (1-D and k-D, order n)(9.18)
Try it: Figures 9.5 and 9.10 — feature choice on the 1000-state walk (gradient MC)

9.5.3 Coarse coding

Features = overlapping receptive fields (e.g. circles); a binary feature is 1 ("present") if the state is inside. Training at one state changes the weights of all circles containing it, so the value changes over the union of those circles, more where more circles are shared (Fig 9.6).

Try it: Example 9.3 / Figure 9.8 — coarseness of coarse coding

Learning a 1-D square wave with interval features (≈50 per unit length), α = 0.2/m where m is the number of features present. Width matters a lot early, very little at the end.

9.5.4 Tile coding

Coarse coding for multi-dimensional continuous spaces, flexible and computationally efficient — "may be the most practical feature representation for modern sequential digital computers". Receptive fields are grouped into partitions (tilings) of tiles. One tiling = state aggregation; several offset tilings give true coarse coding (Fig 9.9: 4 tilings of 4×4 ⇒ 64 features, exactly 4 active).

PropertyConsequence
Exactly one active tile per tiling ⇒ number of active features = number of tilings $n$, for every stateEasy step-size setting: $\alpha=\frac1n$ gives exact one-trial learning ($\hat v(s,\mathbf w_{t+1})=v$); $\alpha=\frac1{10n}$ moves one-tenth of the way (neighbours less, ∝ shared tiles).
Binary features$\hat v$ = sum of $n$ weights at the active indices — no multiplications.
Generalisation ∝ number of shared tilesOffsets matter: uniform offsets ((1,1) displacement) cause diagonal artifacts; asymmetric offsets give more spherical, homogeneous generalisation (Fig 9.11).
Resolution unit $w/n$ (tile width / tilings)Within a $w/n$ cell all states share a representation; moving by $w/n$ changes exactly one tile.
Recommended offsets (Miller & Glanz)

Displacement vector = first odd integers $(1,3,5,7,\dots,2k-1)$, with the number of tilings $n$ an integer power of 2 with $n\ge4k$. E.g. $k=2$: $n=2^3=8\ge4k$, displacement (1, 3). In 3-D, the first four tilings are offset by (0,0,0), (1,3,5), (2,6,10), (3,9,15).

9.5.5 Radial basis functions

$$x_i(s)\doteq\exp\left(-\frac{\|s-c_i\|^2}{2\sigma_i^2}\right)$$
Gaussian RBF feature (centre ci, width σi)§9.5.5

Continuous-valued generalisation of coarse coding. Advantage: smooth, differentiable approximations — but rarely of practical significance; more computation than tile coding and often worse beyond 2 dimensions. An RBF network is linear; adapting centres/widths makes it nonlinear (more precise, but more computation and tuning).

FeaturesTypeStrengthsWeaknesses
State aggregationbinary, one per groupSimple; special case of SGDStaircase; no generalisation across groups
PolynomialsglobalFamiliar; interactions via productsGeneralise poorly online; $(n+1)^k$ blow-up
Fourierglobal, continuousEasy, good performance; easy feature selectionRinging at discontinuities; poor local detail; exponential in $k$
Coarse codinglocal, binary, overlappingControllable breadth/shape of generalisationDesign of fields by hand
Tile codinglocal, binary, partitionsFast; fixed active count ⇒ easy α; hashingMust choose tilings/offsets
RBFlocal, continuousSmooth, differentiableMore computation; worse in high dimensions
ANNnonlinear, learnedLearns features automatically; deep RLFew guarantees; tuning, overfitting, instability

9.6 Selecting step-size parameters manually

$$\alpha\doteq\big(\tau\,\E[\mathbf x^\top\mathbf x]\big)^{-1}$$
Rule of thumb: learn in about τ experiences with substantially the same feature vector(9.19)

Works best when feature vectors have similar length (ideally $\mathbf x^\top\mathbf x$ constant — as in tile coding, where it equals the number of tilings).

Exercises 9.5 and 9.6

9.5 7-D tile coding: 8 stripe tilings per dimension (56) + 2 conjunctive tilings for each of the $\binom72=21$ pairs (42) = 98 tilings ⇒ $\mathbf x^\top\mathbf x=98$ always. With τ = 10: $\alpha=\frac{1}{10\times98}=\frac1{980}\approx0.00102$.

9.6 With τ = 1 and $\mathbf x_t^\top\mathbf x_t=\E[\mathbf x^\top\mathbf x]$, $\alpha=1/\mathbf x_t^\top\mathbf x_t$. After the linear update, $\mathbf w_{t+1}^\top\mathbf x_t=\mathbf w_t^\top\mathbf x_t+\alpha[U_t-\mathbf w_t^\top\mathbf x_t]\mathbf x_t^\top\mathbf x_t=U_t$ — the error is zero after one update.

9.7 Nonlinear function approximation: artificial neural networks

Exercises 9.7 and 9.8 — a single logistic unit

$\hat v(s,\mathbf w)=\sigma(\mathbf w^\top\mathbf x)$ with $\sigma(z)=1/(1+e^{-z})$, so $\nabla\hat v=\hat v(1-\hat v)\mathbf x$. Squared error (9.7): $\mathbf w\leftarrow\mathbf w+\alpha[U_t-\hat v]\,\hat v(1-\hat v)\,\mathbf x$. Cross-entropy loss $-[U\ln\hat v+(1-U)\ln(1-\hat v)]$ has gradient $-(U-\hat v)\mathbf x$, giving $\mathbf w\leftarrow\mathbf w+\alpha[U_t-\hat v]\,\mathbf x$ — simpler (the $\hat v(1-\hat v)$ factor, which vanishes when the unit saturates, cancels).

9.8 Least-squares TD

Why iterate toward $\mathbf w_{TD}=\mathbf A^{-1}\mathbf b$? Estimate $\mathbf A$ and $\mathbf b$ and solve directly:

$$\hat{\mathbf A}_t\doteq\sum_{k=0}^{t-1}\mathbf x_k(\mathbf x_k-\gamma\mathbf x_{k+1})^\top+\varepsilon\mathbf I,\qquad \hat{\mathbf b}_t\doteq\sum_{k=0}^{t-1}R_{k+1}\mathbf x_k,\qquad \mathbf w_t\doteq\hat{\mathbf A}_t^{-1}\hat{\mathbf b}_t$$
LSTD estimates and solution (the factors of t cancel)(9.20), (9.21)
$$\hat{\mathbf A}_t^{-1}=\hat{\mathbf A}_{t-1}^{-1}-\frac{\hat{\mathbf A}_{t-1}^{-1}\mathbf x_{t-1}(\mathbf x_{t-1}-\gamma\mathbf x_t)^\top\hat{\mathbf A}_{t-1}^{-1}}{1+(\mathbf x_{t-1}-\gamma\mathbf x_t)^\top\hat{\mathbf A}_{t-1}^{-1}\mathbf x_{t-1}},\qquad\hat{\mathbf A}_0\doteq\varepsilon\mathbf I$$
Sherman–Morrison incremental inverse — O(d²) per step(9.22)
LSTD for estimating v̂ = wᵀx(·) ≈ vπ (O(d²) version)on-policylinearno step size
Input: feature representation x : S⁺ → ℝᵈ such that x(terminal) = 0
Algorithm parameter: small ε > 0
Â⁻¹ ← ε⁻¹ I                      A d × d matrix
b̂ ← 0                            A d-dimensional vector
Loop for each episode:
    Initialize S; x ← x(S)
    Loop for each step of episode:
        Choose and take action A ∼ π(·|S), observe R, S'; x' ← x(S')
        v ← Â⁻¹ᵀ (x − γx')
        Â⁻¹ ← Â⁻¹ − (Â⁻¹x) vᵀ / (1 + vᵀx)
        b̂ ← b̂ + R x
        w ← Â⁻¹ b̂
        S ← S'; x ← x'
    until S' is terminal
Semi-gradient TD(0)LSTD
Converges toTD fixed point (iteratively)TD fixed point (directly)
Data efficiencyLowerHighest for linear TD(0)
Memory / computation per step$O(d)$$O(d^2)$ (naive inverse $O(d^3)$)
ParametersStep size αε (too small ⇒ inverses vary wildly; too large ⇒ slow)
ForgettingConstant α forgets old dataNever forgets — problematic when π changes (GPI/control)

9.9–9.10 Memory-based and kernel-based function approximation

$$\hat v(s,\mathcal D)=\sum_{s'\in\mathcal D}k(s,s')\,g(s') \qquad\qquad k(s,s')=\mathbf x(s)^\top\mathbf x(s')$$
Kernel regression; any linear method is kernel regression with the inner-product kernel(9.23), (9.24)

The kernel trick: construct kernels directly (no explicit features); many have compact forms that avoid computing in the high-dimensional feature space. Tile coding implicitly generalises according to a kernel (Fig 9.11). An RBF kernel differs from RBF features by being memory-based (centred on stored states) and nonparametric.

9.11 Interest and emphasis

Treating all states equally (the on-policy distribution) gives the strongest theory, but we may care more about some states (e.g. early states in discounted episodes). Interest $I_t\ge0$: how much we care about accurately valuing $S_t$ (any causal choice); it reweights μ. Emphasis $M_t\ge0$ multiplies the update:

$$\mathbf w_{t+n}\doteq\mathbf w_{t+n-1}+\alpha M_t\big[G_{t:t+n}-\hat v(S_t,\mathbf w_{t+n-1})\big]\nabla\hat v(S_t,\mathbf w_{t+n-1}),\qquad M_t=I_t+\gamma^nM_{t-n},\ M_{t\lt0}\doteq0$$
Emphatic n-step update and emphasis recursion(9.25), (9.26)

Example 9.4: 4-state chain, reward +1 per step, true values 4, 3, 2, 1; parameters $w_1$ (states 1, 2) and $w_2$ (states 3, 4); interest 1 only on the first state.

MethodWithout interest/emphasisWith interest/emphasis
Gradient MC$\mathbf w_\infty=(3.5,1.5)$: first state valued 3.5$w_1\to4$ (exact); $w_2$ never updated
2-step semi-gradient TD$(3.5,1.5)$$(4,2)$ — exact for state 1 and for state 3, which it bootstraps from

9.12 Summary

Hyperparameters in this chapter

ParameterGuidance from the book
α (linear SGD)$\alpha=(\tau\E[\mathbf x^\top\mathbf x])^{-1}$ to learn in ≈ τ experiences. Tile coding with $n$ tilings: $\alpha=1/n$ = one-shot, $1/(10n)$ typical. Book examples: α = 2×10⁻⁵ (gradient MC, aggregation, 100k episodes); 10⁻⁴ polynomial, 5×10⁻⁵ Fourier; 10⁻⁴ single tiling vs 10⁻⁴/50 for 50 tilings (same initial rate).
αi (Fourier)$\alpha/\|\mathbf c^i\|$ — smaller steps for higher frequencies.
Number of features / order nControls resolution; polynomial/Fourier grow as $(n+1)^k$.
Receptive-field widthStrong effect on early generalisation, weak on final accuracy (Fig 9.8).
Tilings, tile width, offsetsResolution unit $w/n$; asymmetric offsets (1,3,5,…); $n=2^m\ge4k$.
RBF width σBreadth of the smooth generalisation.
n (n-step)Intermediate n best for learning speed (Fig 9.2); larger n tightens the asymptotic bound.
ε (LSTD)Regulariser making $\hat{\mathbf A}$ invertible; too small ⇒ unstable, too large ⇒ slow.
Interest $I_t$Which states' accuracy matters; drives emphasis $M_t$.

Self-test

Why must we specify μ in the objective once we use function approximation?

With fewer weights than states we can't get every state right; improving some states worsens others, so we must say how much we care about each — μ.

Why is gradient MC a true SGD method but semi-gradient TD(0) is not?

MC's target $G_t$ doesn't depend on $\mathbf w$ and is unbiased, so the update is a stochastic gradient of the squared error. TD's target $R+\gamma\hat v(S',\mathbf w)$ depends on $\mathbf w$, but the update ignores that dependence — it uses only part of the gradient.

What is the gradient of a linear value function, and what is the linear SGD update?

$\nabla\hat v(s,\mathbf w)=\mathbf x(s)$; $\mathbf w\leftarrow\mathbf w+\alpha[U_t-\mathbf w^\top\mathbf x(S_t)]\mathbf x(S_t)$.

Define the TD fixed point, and bound its error.

$\mathbf w_{TD}=\mathbf A^{-1}\mathbf b$ with $\mathbf A=\E[\mathbf x_t(\mathbf x_t-\gamma\mathbf x_{t+1})^\top]$, $\mathbf b=\E[R_{t+1}\mathbf x_t]$. $\overline{\mathrm{VE}}(\mathbf w_{TD})\le\frac1{1-\gamma}\min_\mathbf w\overline{\mathrm{VE}}(\mathbf w)$.

Why is it crucial that updates follow the on-policy distribution?

The positive-definiteness of $\mathbf A$ (hence stability of linear TD) relies on μ being the stationary distribution of π. With other distributions, bootstrapping + function approximation can diverge.

In state aggregation on the 1000-state walk, why is the leftmost group's value higher than the average of its true values?

μ is very asymmetric inside that group: states near 100 are visited >3× as often as state 1, so the $\overline{\mathrm{VE}}$-optimal value is pulled toward $v_\pi(100)$, which is higher.

In tile coding with 8 tilings, what α gives exact one-trial learning?

$\alpha=1/8$ (= $1/n$), because exactly 8 binary features are active, so $\mathbf x^\top\mathbf x=8$.

What determines generalisation and what determines acuity in coarse coding?

Size and shape of receptive fields determine (initial) generalisation; the total number (density) of features determines acuity — the finest discrimination possible.

Why prefer asymmetric tile offsets?

Uniform (1,1)-type offsets create diagonal artifacts and uneven generalisation; asymmetric offsets (first odd integers) give homogeneous, well-centred generalisation.

Give two pros and two cons of LSTD.

Pros: most data-efficient linear TD; no step size. Cons: $O(d^2)$ memory and computation; never forgets (bad when the policy changes); needs ε tuning.

What is the "kernel trick"?

Since a linear method equals kernel regression with $k(s,s')=\mathbf x(s)^\top\mathbf x(s')$, you can design kernels directly — often computable compactly — and effectively work in a huge feature space using only stored examples.

In Example 9.4, why does emphatic 2-step TD get $w_2=2$?

The only emphasised update is for state 1, whose 2-step target is $1+1+\hat v(\text{state }3)$. For that to be correct (4), state 3's value $w_2$ must be 2 — the emphasis $M_t=I_t+\gamma^nM_{t-n}$ ensures state 3 (two steps later) is also updated, so it is learned exactly.

Chapter quiz — check your understanding

Scored quiz: pick an answer (or type a number) to get instant feedback and an explanation. Questions marked Exam-style give you values to interpret (sweeps, logs, returns, learning curves), the way exam problems do. Your best score is saved in this browser and shown on the home page. "Shuffle & restart" re-orders the questions.