Say that we have two vector v∈R2 and u∈R2.
Now in space of v which vector is closest to w?
But let's first ask what is the space of v?
info
We are asking for the space of a single vector, a single vector can only give us a
space in R which is a line.
So the span of v is Cv;C∈R
Now we have to find a vector closest to w in the vector space of v.
Let's call this closest vector as p,
this p is the projection of w on v.
We know that p lives in the vector space of v.
So p=xv;x∈R. p is the closest vector to w then the vector joining
p to w is perpendicular to v.
Say the vector joining p to w be e, and e=w−p
So,
Say we have a vector v∈Rn now we want a matrix that gives us projection
of any vector onto this vector v, we call this matrix a projection matrix.
Say this projected vector on v be p.
As we discussed above, p=vx ⇒p=vvTvvTw ⇒p=vTvvvTw
Projection matrix(P) of a vector v is
danger
P=vTvvvT
Columns of P is the linear combinations of v, so
info
Column space of P is the vector space of v.
We have our Projection matrix(P) we can take projection of any vector w on v by evaluating Pw
info
In Pw we are taking the linear combination of v so the resultant
projection of w on v lives in the vector space of v.
What about the rank of P?
info
Rank of P is 1.
Because all the columns of P is the linear combination of a single vectorv.
Is Psymmetric?
P=vTvvvT
⇒PT=vTv(vvT)T
⇒PT=vTvvTTvT
⇒PT=vTvvvT
So P is symmetric.
info
P=PT
What if we apply the projection of a vector w on vtwice?
When we apply the projection first time, we land in the vector space of v. Let's say the projected vector be p1. If we again apply the projection on p1 then it project the p1
into the vector space of v. But p1 is already in vector space of v, so the second projection did nothing. So we can say that
Ok we can find the projection of a vector on another vector, but why are we projecting the
vector in the first place? What is the benefit of projecting a vector?
Say a function f=x1a+x2b+x3c is governed by 3 variables (say a,b,c) and we have 5noisy
observation of f now we want to predict f for some set of (a,b,c).
Because our 5 observations are noisy so we can not perfectly predict the outcome.
Our observation is something like, f1=x1a1+x2b1+x3c1 f2=x1a2+x2b2+x3c2 f3=x1a3+x2b3+x3c3 f4=x1a4+x2b4+x3c4 f5=x1a5+x2b5+x3c5
We can write it as,
So there are high chance that Y does not lives in column space of A.
So instead we find the solution for AX=Y.
Where Y lives in the column space of AandY
is closest to Y
info
We can get this Y by taking the projection of Y
onto the column space of A
Say that we have a m×n matrix A∈Rm×n and a vector
v∈Rn.
Then projection of a vector v on a matrix A generally means projection
of v on the column space of matrix A.
We can also take the projection of a vector v on the null space of matrix AT.
And as we know that null space of AT is perpendicular to the column space of A.
Then,
Recall our above example,
here we have a system of equation AX=Y where there is no solution.
Here problem was that there are high chance that Y does not lives in column space of A,
So it does not have a solution.
So we go for the closest solution. AX=Y
where, Y lives in the column space of A, so.
info
Y is the linear combinations of the columns of A.
(vector)Y lives in the column space Aand
(vector)Y is at some angle to the column space of A, So
info
The vector Y−Y is perpendicular to the column space of A
⇒Y−Y is also perpendicular to the column vectors of A
⇒aT(Y−Y)=0,
bT(Y−Y)=0 and
cT(Y−Y)=0
where a,b and c are the column vector of A.
We can write it as,
Our projection of Y on the columnn space of A is Y .
Y=AX and X=(ATA)−1ATY, so
Projection(Y) of Y on the column space of A:
danger
Y=A(ATA)−1ATY
So our Projection Matrix is,
danger
P=A(ATA)−1AT
Is Psymmetric?
P=A(ATA)−1AT ⇒PT=(A(ATA)−1AT)T ⇒PT=ATT((ATA)−1)TAT ⇒PT=ATT((ATA)T)−1AT ⇒PT=ATT(ATATT)−1AT ⇒PT=A(ATA)−1AT So P is symmetric.
info
P=PT
What if we project vectorY on the column space of a matrix A of a matrix Atwice?
When we apply the projection first time, we land in the column space of A. Let's say the projected vector be Y. If we again project the Y on the column space of A
then the resultant vector will be Y. Because Y is already in column space of A, so the second projection did nothing. So we can say that
info
P2=P
Let's look at the extreme cases,
Suppose we want to take projection of a vector b in the column space of a matrix A.
1.What If the vector b is perpendicular to the column space of matrix A?
note
First let's think about the space of vectors who are perpendicular to the column space of matrix A.
Space perpendicular to the column space is Null space of AT.
So b lives in the Null space of AT.
So,
ATb=0
projection matrix(P) of the column space of a matrix A is,
And projectionP of b in the column space of a matrix A is Pb
Pb=A(ATA)−1=0ATb=0
2.What If the vector b is in the column space of m×n matrix A?
note
Vectors in the column space of A is the linear combinations of the column vectors of matrixA.
We can write the all the linear combinations of matrix all as Ax;x∈Rn.
And we are saying that b is in the column space of matrix A, so,
b=Ax;x∈Rn
So projectionP of b in the column space of a matrix A is Pb Pb=A(ATA)−1ATb. Pb=AI(identity)(ATA)−1ATAx. Pb=Ax. Pb=b.
So projecting b(which is already in the column space of A) on the the column space of A
changes nothing.