These basis functions are generally nonlinear functions of the state s, combined into a vector function β(s) or β(s,a). Even though the model is linear with respect to the basis functions, the resulting approximation can be nonlinear with respect to the underlying state s.
This is a great example of lifting features into a higher dimension (“升维”). In the left plot, the value is nonlinear with respect to the state s. However, in a higher-dimensional space formed by basis functions (s and s2), we can fit a flat plane to the data.
📁Example
Suppose the ground truth value function is U(s)=s2.
s
Ground Truth U(s)
0
0
1
1
2
4
3
9
From the table above, we see that the value function is nonlinear with respect to the state s. However, if we tailor our feature representation properly, say
β(s)=[1,s,s2]⊤.
Then the learnable parameter θ could be θ=[0,0,1]⊤. In this case, our model Uθ perfectly captures the ground truth U(s). For example, when s=2, we have
Uθ(2)=θ⊤[0,0,1]⋅β(2)124=0×1+0×2+1×4=4.
This exact fit can only be achieved when 2 conditions are met:
✅ we choose an appropriate feature representation. i.e., β(s)=[1,s,s2]⊤.
✅ we identify the right parameters. i.e., θ=[0,0,1]⊤
But what if we don’t choose an appropriate representation? Suppose our feature vector only includes linear terms:
β(s)=[1,s]⊤.
If we use the least squares method to fit the parameter, we get θ=[−1,3]⊤ (meaning Uθ(s)=−1+3s).. In this case, the true value can not be perfectly approximated.
s
ground truth U(s)
approximated Uθ(s)
error
0
0
−1
−1
1
1
2
+1
2
4
5
+1
3
9
8
−1
This is the most common case we encounter in real life.
⛳Objective
Now we know what θ and β are, let’s see how to use the least squares method to solve for θ. Given m states s1:m and their target utilities u1:m, our objective is to minimize the sum of squared errors between the predicted value U^θ(si) and the target value ui:
We construct a feature matrix X where each row i is the transposed feature vector for state si:
Xi=β(si)⊤,
where β(si) is a column vector and β(si)⊤ is a row vector.
Since the dot product of two vectors is symmetric (θ⊤β(si)=β(si)⊤θ), each prediction θ⊤β(si) is simply the i-th row (entry) of the matrix-vector product:
Xθ.
Let’s use a toy example to illustrate this:
we have m=3 samples of state
feature vector is β(s)=[1s]
weight vector is θ=[θ1θ2]
Sample i
State si
Target Utility ui
Feature Row Xi,:=β(si)⊤
1
0
1
[1,0]
2
1
2
[1,1]
3
2
5
[?,?]
Clearly, the last row is [1,2], so our feature matrix X is:
X=111012.
Multiplying X by θ gives all predictions at once:
Xθ=111012[θ1θ2]=θ1θ1+θ2θ1+2θ2.
Let’s verify with i=3. The prediction θ⊤β(si) becomes θ⊤β(s3):
θ⊤β(s3)=[θ1θ2][12]=θ1+2θ2.
This is the exact last entry of the product Xθ.
Look back at our objective function:
i=1∑m(θ⊤β(si)−ui)2.
If we define the error vector as e=Xθ−u, summing the squared entries of vector e is the same as taking its dot product with itself, e⊤e. Therefore, the equation above becomes:
J(θ)=(Xθ−u)⊤(Xθ−u).
✏Solution
Because this is a least squares problem, the minimum occurs where the derivative with respect to θ is 0. Too see this intuitively, let’s first look at the 1D scalar version:
1️⃣ when X⊤X is invertible (i.e., X has full column rank): the (X⊤X)−1X⊤ and the pseudoinverseX+ are mathematically identical. Case closed.
2️⃣ when X⊤X (e.g., we have fewer states than features, resulting in a wide matrix): (X⊤X)−1 does not exist. Instead, we find X+ directly using SVD, which gives the minimum norm least squares solution.