A matrix that flattens the plane can’t be undone. Watch the best attempt: it brings back everything that wasn’t crushed.
Undoing a flattening matrix
B = [1 1; 2 2] flattens the plane; its pseudo-inverse brings back what it can.
B = [1 1; 2 2] is about to act on the plane.
Describe this picture
One panel and the matrix . After a short rest, over 4 s the grid is flattened onto the line through . After a 1 s pause, over the next 4 s the pseudo-inverse carries that line back onto the line through , and crushes the perpendicular line through to the origin. Dashed lines mark the three lines. One control after the clip: drag a target , or move it with the arrow keys; the answer appears, with the gap between and what that answer actually reaches. The clip ends on , whose answer is , missing by .
Undo what can be undone
The matrix in the picture, , sends every point onto the line of . Points that differ along the null direction, , land in the same place, so no matrix can tell them apart afterwards. There is no inverse, as The inverse matrix showed for every flattening map.
But some of the information survives. The SVD of The singular value decomposition says exactly what: takes the direction , stretches it by , and lays it along . Everything along the other direction is multiplied by and lost. The best undo reverses the part that survived and leaves the lost part at zero.
Build it from the SVD
In , swap the two turns and replace each nonzero singular value by its reciprocal, leaving the zeros as zeros. That gives the pseudo-inverse, in full the Moore–Penrose pseudo-inverse:
Here holds where and 0 elsewhere, transposed to fit. When is invertible nothing is zero, and .
For there is one piece:
What it does and doesn’t undo
Multiply both ways. , the projection onto the line of from Projections. And , the projection onto the line of . Neither is .
Watch out
The pseudo-inverse does not undo . It can’t bring back what crushed. projects onto the row space, keeping the part that survived, and projects onto the column space. Only for an invertible matrix are both equal to .
The shortest least-squares answer
Ask with , which lies on the line of outputs. Every with solves it: a whole line of answers, as in The complete solution. The pseudo-inverse picks one:
Its length is 2.121, shorter than or any other answer. It lies in the row space, with no part along the null direction, and adding a null part can only make an answer longer.
Now a target off the line, . No reaches it. The best that can be done is to reach the closest output, the foot of on the line of , which is , as in Least squares. The pseudo-inverse gives , and indeed .
So in every case is the shortest of all the least-squares answers. When the columns of are independent there is only one, and , the formula of the least-squares page.
Ridge: damping the weak directions
Trouble starts when a singular value is not zero but tiny. Say . The pseudo-inverse multiplies the two directions by : 0.5 and 100. Any noise in the weak direction is magnified a hundred times.
Ridge regularisation adds a small number before inverting:
Where is large, is close to . Where is small, it stays small instead of exploding.
Ridge damping
How the pseudo-inverse and ridge treat a strong and a weak direction.
Two singular values: a strong direction, σ = 2, and a weak one, σ = 0.01.
Describe this picture
Three rows of bars for two directions, one with singular value 2 and one with 0.01, appearing row by row. The top row shows the singular values themselves. The middle row shows the pseudo-inverse’s factors, : 0.5, and 100, a bar that runs off the top of the scale and is marked with an arrow. The bottom row shows the ridge factors with , : 0.499 and 0.990. There is no control.
Compare the bars. The strong direction is barely touched, 0.5 against 0.499. The weak one drops from 100 to under 1.
In signal processing · equalising a channel
Channels and equalisation, in the signal processing course, undoes a channel that smears a signal. Where the channel is weak, an exact inverse would amplify the noise enormously, so equalisers use a damped inverse, the same idea as ridge. Signal samples count from , while vector entries count from 1.
Worked example
1. Build it. has , and , so , and .
2. Shortest answer. For : , length 2.121. For : , which reaches .
3. Ridge with . , with inverse , and . So , which is of : the factor . As shrinks to 0, tends to .
4. Full column rank. For the matrix , , and : the least-squares answer of Projections.
Try these before you read the answers.
- of an invertible ? .
- Is ? No: it projects onto the line of .
- What does a larger do to the answer’s length? It shrinks it, by in each direction.
- has singular values 3 and 0. The matching entries of ? and 0.
Where you’ll meet this
Least-squares software. Library routines for least squares and the pseudo-inverse work through the SVD, so a fit with redundant or nearly redundant columns still returns a sensible answer, the shortest one.
Redundant sensors. Calibrating a set of sensors that measure overlapping things gives a system with dependent columns; the pseudo-inverse picks one consistent answer.
Rebuilding a signal from its spectrogram. Inverting the STFT finds the signal whose overlapping frames best match a set of edited frames: a least-squares inverse.
Statistics. Ridge regression fits a model with many inputs by the formula above, trading a little bias for much less noise.
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| Pseudo-inverse | invert the nonzero , keep zeros | |
| As pieces | ||
| Invertible | ||
| Independent columns | the least-squares formula | |
| Projections | onto , onto | not in general |
| Shortest answer | the least-squares answer in the row space | |
| Ridge | factor per direction |