Studio · From Linear
The nearest line
Measure the errors vertically or at right angles: is the nearest line the same?
Composing the first frame…
Drag the five coral points. Measured vertically, each point misses the line by a vertical gap: the short ice-blue segment is the error, with a pale gold square standing on it. The solid line is the one that makes the total area of those squares least, the least-squares line, solved from the two equations AᵀA x = Aᵀb (the columns of A are a column of ones and the points' x-coordinates, b holds their heights, and x is the line's intercept and slope), and in the corner the area drawn and the least value worked out from the matrix stay the same. Measure at right angles to the line instead, and the error is each point's perpendicular distance: the best line passes through the centroid of the points (the ivory dot) along the direction in which they spread furthest, and the least total area is the smaller eigenvalue of the symmetric matrix S. The line for the other way of measuring stays on screen, dashed in ice blue. Both lines pass through the centroid. When the five points lie on one sloping line the two coincide; the further the points stray from a single line, the wider, as a rule, the angle between them, though spreading all five out evenly leaves it unchanged. The line measured vertically is always the flatter of the two. Drag the third point, the middle one across, up and down: the line measured vertically barely tilts, it mostly slides, while the one measured at right angles turns.