Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

The main hypothesis is that there exists a linear relationship between data y∈Rmy \in \mathbb{R}^m and variables x∈Rnx \in \mathbb{R}^n.

illustration of the linear model y = Ax + b in the overdetermined case (m \geq n)

Figure 1:illustration of the linear model y=Ax+by = Ax + b in the overdetermined case (m≥nm \geq n)

Definitions and Notations

For simplicity, we assume that AA has full rank, i.e., rank⁡A=min⁡(m,n)\operatorname{rank} A = \min(m, n): there are no redundant observations or unknowns. The problem (1) is said to be

The over/under determination property play an important role regarding the uniqueness of solutions to the least squares problem, as we will see later on.

Interpretation as an unconstrained quadratic program (QP)

The objective function f0(x)=∥y−Ax∥22f_0(x) = \Vert y - Ax\Vert_2^2 can be rewritten as

f0(x)=(y−Ax)⊤(y−Ax)=y⊤y−x⊤A⊤y−y⊤Ax+x⊤A⊤Ax\begin{align*} f_0(x)&= (y - Ax)^\top ( y - Ax)\\ &=y^\top y - x^\top A^\top y - y^\top Ax + x^\top A^\top A x \end{align*}

such that the least-squares optimization problem can be equivalently reformulated as the unconstrained quadratic program

minimize⁡12x⊤Qx−p⊤xsubject to⁡x∈Rn\begin{array}{ll} \minimize& \frac{1}{2}x^\top Q x - p^\top x\\ \st & x \in \mathbb{R}^n \end{array}

where Q:=A⊤A∈Rn×nQ:= A^\top A \in \mathbb{R}^{n\times n} and p:=A⊤y∈Rnp := A^\top y \in \mathbb{R}^n.

Examples

Polynomial regression

Assume we are given some data y1,…,ymy_1, \ldots, y_m as a function of time tt, as shown below:

Source
<Figure size 640x480 with 1 Axes>

The trend clearly looks polynomial. If we assume the degree dd of the polynomial is known (here d=3d=3), we can write a linear model to fit the data yy. The approach very classical: hence it is implemented in many libraries, such as scikit-learn (see PolynomialFeatures and LinearRegression).

<Figure size 640x480 with 1 Axes>
Estimated coefficients (in increasing powers of t):
 [ 0.61187122 -1.2593056   4.15376347  1.05475994]

In TP1, we will see what’s under the hood of such tools and implement the solution from scratch.

2D image deconvolution

Assume we observe a blurred image Y∈RH×WY \in \mathbb{R}^{H \times W}, which is the result of convolving a true image X∈RnH×nWX \in \mathbb{R}^{n_H \times n_W} with a known kernel K∈RkH×kWK \in \mathbb{R}^{k_H \times k_W}, plus noise BB:

Y=K∗X+BY = K * X + B

where ∗* denotes 2D convolution.

Example

<Figure size 800x400 with 2 Axes>

We can rewrite the convolution as a linear operation (see also below) using the vectorization operator vec⁡()\operatorname{vec}(). Define y=vec⁡(Y)∈RHWy = \operatorname{vec}(Y) \in \mathbb{R}^{HW}, x=vec⁡(X)∈RHWx = \operatorname{vec}(X) \in \mathbb{R}^{HW} and b=vec⁡(B)∈RHWb = \operatorname{vec}(B) \in \mathbb{R}^{HW}, the above observation model is rewritten as

y=Ax+by = Ax +b

where AA is the matrix representing convolution with KK. The least squares problem is then:

min⁡x∈RHW∥y−Ax∥22\min_{x\in \mathbb{R}^{HW}} \left\| y - Ax \right\|_2^2

For the above example, AA is a huge structured matrix of size HW×HWHW \times HW. To simplify the presentation, assume H=W=10H = W = 10 (the matrix AA is already 100×100100 \times 100!)

Source
<Figure size 800x800 with 2 Axes>

In practice, due to the large size of the matrix AA, we do not use direct solutions based on pseudo-inverse calculations (see later on). In this case, the least squares problem is solved through the use of FFTs.

<Figure size 1000x300 with 3 Axes>

With circular boundary conditions, AA is diagonalized by the 2D Fourier transform, so the (slightly regularized) least squares solution is obtained by dividing in the Fourier domain: X^=F−1(K^‾ Y^∣K^∣2+ε)\hat{X} = \mathcal{F}^{-1}\left(\dfrac{\overline{\hat K}\,\hat Y}{|\hat K|^2+\varepsilon}\right). This example demonstrates how 2D deconvolution can be formulated and solved as a linear least squares problem.