Linear Methods in RL
Linear methods score a state as a weighted sum of hand picked features, so the error surface is one clean bowl with a single best setting.
Why Does This Exist?
Tables fail when states are many or continuous. A robot arm never sees the exact same joint angles twice, so a table entry per state wastes memory and shares nothing between near identical states. You need generalization across states.
Value function approximation replaces the table with a parameterized guess. Deep nets generalize well but bring a rugged loss with local dips, saddle points, and divergence when combined with bootstrapping and off policy data. Linear methods keep the generalization and drop the ruggedness. The value is a dot product, the error is a quadratic bowl, and on policy TD converges to a bounded fixed point. This page covers the dot product form, the gradient identity, and the TD bound. Feature construction covers where good features come from. Semi-gradient TD covers the bootstrapped update in full.
The one idea you need first
A feature vector in is a short numeric summary of state , one number per property. The weight vector in holds one tunable number per property. Their dot product is the sum of pairwise products. That sum is the whole model.
Think of It Like This
A grading rubric
Your final course score is not a mystery model. Homework counts 20 percent, midterm 30, final 40, attendance 10. With scores 0.95, 0.82, 0.88, 1.00 you multiply and add and get the total.
Features are the assignment scores. Weights are the syllabus percentages. The predicted value is the final score. To raise the total you push each weight in proportion to its score, which is exactly the linear update.
Where it stops: a rubric is fixed by a teacher. Here weights start as guesses and move after every transition until error sits at the bottom of the bowl.
How It Actually Works
Map state to features . Call the weights. The estimate is:
The gradient with respect to is just the features:
In words: to raise the estimate fastest, push weights along the feature direction. No chain rule, no backward pass.
Why the bowl has one bottom
Mean squared error under state weighting is:
Here is the feature covariance, mixes features with true values, is constant. Because is positive semi definite, the surface is a paraboloid. One bottom, no traps. Monte Carlo SGD with target is:
Semi-gradient TD with reward and discount uses the bootstrapped error:
On policy this converges to the TD fixed point with error bounded by times the best linear error.
Worked example
Features , weights , rate , target .
Prediction:
Error:
Update along features:
New prediction:
Shift is , which equals . The diagram draws this exact move from to on the bowl.
Code
This snippet replays the worked numbers and one TD step. It uses only the standard library.
from typing import List
def predict(w: List[float], x: List[float]) -> float: """Dot product wT x.""" return sum(wi * xi for wi, xi in zip(w, x))
if __name__ == "__main__": x = [1.0, 0.5] w = [2.0, 1.0] v0 = predict(w, x) print(f"v0 = {v0:.3f}") # -> v0 = 2.500 delta = 4.0 - v0 alpha = 0.2 w = [wi + alpha * delta * xi for wi, xi in zip(w, x)] print(f"w1 = {w}") # -> w1 = [2.3, 1.15] v1 = predict(w, x) print(f"v1 = {v1:.3f}") # -> v1 = 2.875Watch Out For
Features on wildly different scales
Mixing a velocity in 0 to 100 with a distance in 0 to 0.01 stretches the bowl into a narrow canyon. One global rate either explodes along the large feature or crawls along the small one. Symptom: oscillating loss that never settles even though the model is linear.
Standardize each feature to zero mean and unit variance or to the range minus 1 to 1. If you cannot rescale, give each dimension its own rate scaled by inverse mean square. Tile coding and radial bases help because their norms stay bounded.
Off policy TD without correction
Linear TD carries a convergence proof for on policy sampling. Under off policy sampling with bootstrapping the same update can diverge, the classic deadly triad. Symptom: weights grow slowly then blow up while on policy runs stay calm.
Stay on policy for plain semi-gradient TD, or switch to gradient TD methods that correct the sampling mismatch. Do not fix divergence by shrinking the rate alone. The sampling is the bug.
The Quick Version
- Linear methods predict value as , a weighted sum of features with learnable weights.
- The gradient equals the features, so each update is with no backprop.
- Squared error is a quadratic bowl with one global bottom, so there are no local minima.
- In the worked check features and weights give , then move to and after one step toward .
- On policy semi-gradient TD converges to a fixed point within of the best linear fit, but off policy use needs correction.