Method of least squares

Database › Mathematics › Applied mathematics › Statistics

STAT-0003MethodUndergraduateEntrance exam

The best-fitting parameters of a model minimize the sum of squared residuals weighted by the measurement variances; for a model linear in its parameters the minimum follows from the normal equations.

$$\chi^2=\sum_i\frac{(y_i-a-bx_i)^2}{\sigma_i^2};\quad b=\frac{n\sum xy-\sum x\sum y}{n\sum x^2-(\sum x)^2},\ \ a=\bar y-b\bar x;\qquad\hat{\boldsymbol\theta}=(A^{\rm T}A)^{-1}A^{\rm T}\mathbf y$$

Explanation

Setting $\partial\chi^2/\partial a=\partial\chi^2/\partial b=0$ gives two linear equations; the straight-line formulas above are for equal errors. For any model $y=\sum_k\theta_kf_k(x)$ the design matrix $A_{ik}=f_k(x_i)/\sigma_i$ gives the normal equations $A^{\rm T}A\boldsymbol\theta=A^{\rm T}\mathbf y$, and $(A^{\rm T}A)^{-1}$ is the covariance matrix of the parameters.

With Gaussian errors this is maximum likelihood. Nonlinear models are linearized and iterated; ill-conditioned $A^{\rm T}A$ is better handled by the singular value decomposition. After the fit, $\chi^2$ per degree of freedom $\approx1$ indicates a consistent model.

Example 1

Fit a straight line $y=a+bx$ to the points (0, 1), (1, 3), (2, 4), (3, 6).

Solution

$n=4$, $\sum x=6$, $\sum y=14$, $\sum xy=29$, $\sum x^2=14$: $b=\frac{116-84}{56-36}=1.6$, $a=\frac{14-9.6}{4}=1.1$.

Example 2

Repeated measurements $x_i$ of one quantity: show that least squares gives the mean, and find its error if each has standard deviation $\sigma$.

Solution

$\frac{d}{dX}\sum(x_i-X)^2=-2\sum(x_i-X)=0$ gives $X=\bar x$; its standard deviation is $\sigma/\sqrt N$ (estimate $\sigma$ by $s$).

In graduate entrance exams

  • University of Tokyo, Graduate School of Science, Physics (MSc entrance exam), FY2003 (H15), Problem 5

Related entries