Linear Algebra
Math · Advanced · Lesson 6 of 7

Least Squares

The best line through messy data

An interactive lesson with 6 steps, about 5 minutes: you predict, drag and solve, with instant feedback on every answer. It runs in your browser and needs JavaScript.

What you’ll learn

  • Least squares finds the best approximate solution of an overdetermined system.
  • Geometrically it’s a perpendicular projection, giving the normal equations AᵀAx = Aᵀb.
  • The mean is the least-squares constant; the regression line passes through the mean point.

Steps

  1. Too many equations
  2. Fit the line
  3. Least squares is a projection
  4. A shadow
  5. The simplest fit
  6. Slope by formula