Transformation and Projection
Transformation and Projection
Projections and least squares approximations What a matrix transformation cannot possibly do:
Transformation: x Ax (RnRm if A is m by n) (ii) If A transforms x to x’, then cx can be only transformed to cx’ since
Reflection: transforms every vector into its mirror image. For all numbers c and d and all vectors x and y, matrix multiplication
1 2
Linear Transformation Example - Polynomials Basis and Linear Transformation
Let x1, x2,…,xn be the basis, then any other vector in the space is a
combination of the vectors in the basis:
Polynomial space Pn: p=a0+a1t+…+antn with space dimension = n+1
if x c1 x1 cn xn then Ax c1 ( Ax1 ) cn ( Axn )
Example: is differentiation operation on a polynomial: A=d/dt
Crucial property:
d
Ap (a0 a1t ant n ) a1 nant n 1 a linear transformation?
dt Once Axi’s are determined, Ax of any x is known
3 4
Linear Transformation in Matrix Form Differentiation/Integration of Polynomials in Matrix Form
Question: how to find matrix A? Example: Differentiation for the polynomials of degree 3: Ap1=0=(0, 0, 0,
Suppose the vectors x1, …, xn are a basis for the space V and y1, …, ym are a 0)T, Ap2=1= p1=(1, 0, 0, 0)T, Ap3=2t=2p2=(0, 2, 0, 0)T, Ap4=3t2=(0, 0, 3, 0)T
5 6
Rotation Matrix Q Projection Matrix P
c -s c cos
Q
s c s sin
To construct A and B, we need bases for V & W and U & V. If the basis
for V is kept the same, then the product matrix goes directly from the
basis in U to basis in W.
7 8
Reflection Matrix H Basis for Constructing Transformation Matrix A
Let the basis be (c, s) and (-s, c): one is on the -line and the other is on -
1 0
Projection matrix: P
0 0
1 0
Reflection matrix: H
0 1
Check H=2PI
Two reflections bring back the original: H2=I H-1=H
c s
-1 Rotation matrix: Q
Can you guess H simply from the matrix form? But it’s easy if you know s c
the meaning of the what transformation the matrix represents.
The sum of a vector and its mirror image equals twice the projection of
Choosing the best basis is very important!!
the vector Hx+x=2Px H=2PI
Idea: make the transformation matrix diagonal, as P and H here using (c,
H =(2PI) =4P 4P+I=I since P =P
2 2 2 2
9 10
Projection of b onto Vector a Schwarz Inequality
The projection point p must be some multiple of a ( p x̂a )
The line from b to the closest point p x̂a is perpendicular to the vector a Schwarz Inequality: any two vectors satisfy
| a T b | || a || || b ||
2
2 aT b (bT b)( a T a ) ( a T b) 2
Reason 1: || b p || b a 0
aT a aT a
(bT b)( a T a ) ( a T b) 2 0 | a T b | || a || || b ||
aT b
T Reason 2: 1 cos 1 | cos | 1 1 | a T b | || a || || b ||
a b || a || || b ||
(b xˆa ) a , or aT (b-xˆa ) 0 , or xˆ
aT a
Equality holds if and only if b is a multiple of a =0o or 180o and
The projection of b onto the line through O and a is
cosine=1 or –1 b=p
aT b
p xˆa T a
a a Example: Project b=(1, 2, 3) onto the line through
aT b 6
a=(1, 1, 1): xˆ 2
aT a 3
|| p || 12
The projection point p=2a=(2, 2, 2) cos
|| b || 14
11 12
Projections of Rank One New Definition of Transpose
aT b aaT
p xˆa p axˆ a T T b Pb
a a a a
Old definition: ( AT )ij ( A) ji
T
aa
Projection matrix P T to project b onto a
a a New definition: The inner product of Ax with y equals the inner product
Example: The matrix that projects any vector onto the line through a=(1, 1, of x with ATy: (Ax)T y = xT(ATy)
Projection onto the “-direction” line, i.e. the line through a=(cos , sin
c
s c s c 2 cs
): P
c cs s2
c s
s
13 14
Least Squares Approximate of Solution Projection onto Column Space
Ax=b is solvable b is in the column space This is a problem analogy to find an approximate solution for an
When there are more equations than unknowns, b is hardly in the column unsolvable Ax=b system, especially when the no. (n) of unknowns is less
space Find x such that Ax is as close as possible to b least square than the no. (m) of equations
If (b1, b2, b3) is not on the same line as (2, 3, 4) find x that minimizes the
E 2 ( 2 x b1 ) 2 (3 x b2 ) 2 ( 4 x b3 ) 2
15 16
Normal Equations, Least Squares Approximation and Projection Matrix P
Projection onto a Subspace p A( AT A) 1 AT b Pb P= A( AT A) 1 AT = Projection Matrix to
The normal equations for an inconsistent system Ax=b of m equations and project b onto the column space of A
n unknowns: AT Axˆ AT b which is always solvable. b is split into Pb component (in the column space) and bPb component in
The least squares approximation of x exists uniquely: the orthogonal complement (left nullspace)
xˆ ( AT A) 1 AT b IP is also a projection matrix that project b to the left null space:
if ATA is invertible, i.e., the columns of A are linearly independent (r=n). (IP)b=bPb
The projection of b onto the column space is: Two properties for P
p Axˆ A( AT A) 1 AT b 1. P2=P
p A( AT A) 1 AT b A( AT A) 1 AT Ax AIx Ax b Proof:
p A( AT A) 1 AT b AA1 ( AT ) 1 AT b IIb b
17 18
More on Projection Matrix ATA and Left-Inverse of A
It is known now if P is a projection matrix then P2=P and PT=P (ATA)T=ATATT=ATA ATA is symmetric
Is any symmetric matrix with P2=P a projection matrix? YES! ATA has the same nullspace as A since if Ax=0 then ATAx=0 and if ATAx=0
To prove P is a projection matrix, we have to prove that the error vector Normal equation AT Axˆ AT b is always solvable but may have many
bPb is perpendicular to the component of any vector c projected onto that solutions when A has linearly dependent columns, i.e., A or ATA has non-
A Projection matrix P P2=P and PT=P space, then ATA is an nn square with zero dimension of null space, i.e.,
If A is square and invertible, any vector b projects to itself r=n (nm) A has linearly independent columns
AT Axˆ AT b is still solvable with many solutions (+xnull). A new matrix, say
of (A’TA’)-1
19 20
Projection onto Row Space and AAT AAT and Pseudo-inverse
Row space of A=column space of AT Recall pseudoinverse A+ is to invert Ax back to the row-space part of x:
Recall projection matrix to project onto A column space = xr is projection of x onto the row space
= A( AT A) 1 AT = AT ( AAT ) 1 Ax A Ax
If A has linearly independent rows(r=m), then AAT is square, symmetric, A+ is a right inverse of A when A has independent rows
and invertible What if AAT is not invertible? Removing zero rows in U and deal with
(AAT)-1 exists
21 22
Least Squares Fitting of Data Two Explanations of Least Squares
C Dt1 b1
C Dt 2 b2
C Dt m bm
We obtain observations (t1, b1), …, (tm, bm) from experiments.
1 t1 b1 Right: b=(1, 1, 3) is not on the plane spanned by (1, 1, 1) and (1, 1, 2); least
1 t C
2 b2
Ax=b squares replace b by p which lies on the plane.
D
1 t b
m m Left: (1, 1), (1, 1) and (2, 3) are not one a line. Least squares replace them
5 13 17 2 6 4
e b Axˆ b p (1, 1, 3) ( , , ) ( , , ) is orthogonal to the
7 7 7 7 7 7
23 24
Multiple Regression Weighted Least Square
Values Sometimes observations are not trusted to the same degree because they
Observatio Y X1 X2 … Xp
n are obtained from different accurate scales. Then, different weights can
1 y1 x11 x12 x1p
2 y2 x21 x22 x2p be applied to different observations when calculating the sum of squared
…
n yn xn1 xn2 xnp
errors:
Values
Weight Observation Y X1 X2 … Xp
Model: Y 0 1 X 1 2 X 2 p X p e W1 1 y1 x11 x12 x1p
W2 2 y2 x21 x22 x2p
Goal: given n sets of observation, estimate 0, 1, …, p …
Wn N yn xn1 xn2 xnp
This is a problem of Ax=b, where Weighted sum of squared errors:
this is again how mathematics can help you to solve problems that no closed as possible to Wb .
( AT W T WA) xˆW AT W T Wb
25 26