A7 · Lesson 25 · Projections
The closest point in a subspace
A sensor signal carries 60 Hz hum from the mains. You know the hum lives in a two-dimensional space, combinations of and , but you don't know its size or phase. Remove the part of the signal that lies in that space and the hum is gone, whatever its amplitude. Subtracting a signal's average to remove its DC offset is the same operation in one dimension. Both are projections: finding the closest point in a subspace, and the leftover is perpendicular to it.
- The dashed line is the direction of . The vector is fixed.
- The green arrow is the projection of onto the line, the closest point on it. The red arrow is the error .
- Turn the line. The error always meets the line at a right angle, and the readout of stays at zero.
Predict
You project onto the line through . What is the projection?
. The coefficient is . Projecting onto the constant vector gives the mean in every slot, and the error is the signal with its DC removed. Its entries add to zero: it's perpendicular to .
Name it
Onto a line
The projection of onto the line through is
The error is perpendicular to , which is what makes the closest point. The projection matrix does it in one multiplication: .
Onto a subspace
To project onto the column space of (independent columns), require the error to be perpendicular to every column: . That gives the normal equations
If the columns are orthonormal (), and everything simplifies: , and each coordinate is a dot product.
Properties
- : projecting twice changes nothing.
- : projection matrices are symmetric.
- projects onto the orthogonal complement, giving the error directly.
- Pythagoras: .
Hum removal
Sample a signal at times, making a vector . Put the samples of and in the two columns of . Then is the signal with every trace of removed, at any amplitude and phase. Over a whole number of cycles the two columns are orthogonal (A6, lesson 2), so the projection is just two dot products.
Worked example
Project onto , and check the error.
Show the solution
- The two dot products. and .
- The projection. the mean in every slot.
- The error.
- Check. .
Answer , and the error is perpendicular to .
Worked example
Find the projection matrix onto the line through , and check .
Show the solution
- The projection matrix.
- Square it.
Answer , and .
Worked example
Project onto the plane .
Show the solution
- Part along the normal. It's easiest to remove the part along the normal :
- What's left is the projection. Its entries sum to zero, so it's in the plane.
- Distance to the plane.
- Where this shows up. Removing the average from a signal is exactly this projection.
Answer , and is 0.577 from the plane.
Check
Project onto the line through . The projection is . What is ?
Check
What is the top-left entry of the matrix that projects onto the line through ?
Check
The samples are projected onto and the projection is subtracted. What is the first entry of what remains?
Check
Project onto the line through . How long is the error vector?
Check
is a projection matrix. What is ?
Check
A signal of 100 samples is projected onto a 2-dimensional hum subspace and the projection subtracted. In how many dimensions can what remains still vary?
Check
Project onto the line through .
(a)
What is the projection's coordinate?
(b)
How far is the point from the line?
Check
Project onto .
Step 1
What is the coefficient ?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
What is the first entry of the error ?
Explain why
Why is the projection the closest point in the subspace, and why is the error perpendicular to it?
Take any other point in the subspace. Then , where lies in the subspace. If the error is perpendicular to the subspace, Pythagoras gives , which is smallest when . So choosing to make the error perpendicular is exactly what makes it the closest point, and that condition is the normal equations.
Practice
Keep practicing
9 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.