Lably
Skip to content

Linear least squares

Least squares approximation of linear functions to data

  • 14 min read
  • 7 chapters
  • 1 lab on Lably

Learn it on Lably

Basic formulation

Consider the linear equation

where A∈Rm×n and b∈Rm are given and x∈Rn is a variable to be computed. When m>n, it is generally the case that (1) has no solution. For example, there is no value of x that satisfies [100111]x=[110], because the first two rows require that x=(1,1), but then the third row is not satisfied. Thus, for m>n, the goal of solving (1) exactly is typically replaced by finding the value of x that minimizes some error. There are many ways that the error can be defined, but one of the most common is to define it as ‖Ax−b‖2. This produces a minimization problem, called a least squares problem

The solution to the least squares problem (1) is computed by solving the normal equation

where A⊤ denotes the transpose of A.

Continuing the example, above, with A=[100111]andb=[110], we find A⊤A=[101011][100111]=[2112] and A⊤b=[101011][110]=[11]. Solving the normal equation gives x=(1/3,1/3).

Sign in to keep reading

6 more chapters are free with a Lably account.

More in Statistics