Squint at a scatter of points from different angles and one angle always looks "most spread out." Can you find it exactly, not just by eye?
Drag the arrow around the cloud. The teal marks are each point's shadow cast straight onto the arrow's line — squeeze together when the arrow points across the cloud's short way, spread apart when it points along the long way.
That spread is variance — of the projections, not the raw points:
- — the unit direction being tested; only its angle matters since it's normalized to length 1.
- — one data point.
- — the mean of all the data points.
- — the number of points.
- Definition: the direction of maximum variance
The first principal component is whichever unit direction makes this as large as possible.
- Only the angle matters
It only depends on the direction's angle — stretching the arrow longer or flipping it to point the opposite way changes nothing, since is normalized before projecting.
Compare a horizontal arrow, a vertical one, and the angle in between. One of those is far closer to the true maximum than the other two — this cloud was built stretched along one specific diagonal, not along either axis.
This cloud was built by combining two independent directions: a wide spread along and a narrow one along the perpendicular .
- Project onto the wide direction
Projecting each of the 7 points onto the unit direction (dot product ):
The mean projection is , so the variance is just the mean of the squares: .
- Project onto the perpendicular
Projecting onto the perpendicular unit direction (dot product ):
Mean is again , so variance — seven times smaller.
- Confirm it's the maximum
No other direction beats : that's the maximum, and (about from the x-axis) is the first principal component.
Rotate the arrow to find the direction of maximum variance — within 0.05 of the best possible, 4.00.
PCA — short for Principal Component Analysis — doesn't invent new data — it just asks which direction the existing data is most spread along, then treats that direction as the one worth keeping if you had to keep only one. The next chapter turns to a different kind of tradeoff: how a model's complexity trades off two distinct sources of error.