Least Squares
Summary
Linear least squares chooses parameters of a model that is linear in those parameters by minimizing the sum of squared residuals. For a straight line, the normal equations give a unique solution when the
Prerequisites
- Summation notation and
linear systems - Curve Fitting
- Optional: matrix form
Problem Type
Given data
Method Definition
Set
Matrix form: with design matrix
Prefer solving
Assumptions / Requirements
- Model linear in parameters
-
full column rank (for a unique minimizer) - Squared error criterion (sensitive to outliers)
Algorithm
- Compute sums
, , , , . - Solve the
normal system for . - Report residuals
and .
Worked Example 1 — three points
Data:
Multiply the first equation by 2:
Fitted line:
(Intercept
Worked Example 2 — four points
Data:
From the first equation,
Then
Error / Accuracy
Minimizing
Common Failure Modes
- Swapping slope and intercept in the normal system
- Using
for the three-point example (correct value is ) - Solving overdetermined systems as if they were square interpolants
Connections
- Curve Fitting
- Numerical Methods/Linear Systems/Solving Linear Systems
- Polynomial Interpolation (exact fit when
and degree )
References
Burden & Faires, Numerical Analysis, least squares; Golub & Van Loan, Matrix Computations; NIST/SEMATECH e-Handbook, https://www.itl.nist.gov/div898/handbook/ ↩︎