Mo logo [home] [lexicon] [problems] [tests] [courses] [auxiliaries] [notes] [staff] german flag

Mathematics-Online course: Linear Algebra - Linear Systems of Equations - Approximation Problems

Best Fitting Line


[previous page] [next page] [table of contents][page overview]

A best fitting line,

$\displaystyle p(t) = u + vt\,
,
$

to a set of points $ (t_i,f_i)$, $ i=1,\ldots,n$, can be determined by minimizing the sum of the squares of the errors

$\displaystyle \sum_{i=1}^n (f_i - p(t_i))^2\, .
$

\includegraphics[width=.7\moimagesize]{a_ausgleichsgerade}

If we have at least two different $ t$-coordinates, we obtain the following formulas for the axis intercept $ u$ and the slope $ v$:

$\displaystyle u$ $\displaystyle =
 \frac{(\sum t_i^2)(\sum f_i)-(\sum t_i)(\sum t_if_i)}
 {n(\sum t_i^2)-(\sum t_i)^2}$    
$\displaystyle v$ $\displaystyle =\frac{n(\sum t_i f_i)-(\sum t_i)(\sum f_i)}
 {n(\sum t_i^2)-(\sum t_i)^2}\,
 .$    


A necessary condition for a minimum is that the derivatives of the sum of the squared errors with respect to both $ u$ and $ v$ equal zero:

0 $\displaystyle = 2\sum_i (u+vt_i-f_i)$    
0 $\displaystyle = 2\sum_i t_i(u+vt_i-f_i)\,
 .$    

The matrix form of these two equations is

$\displaystyle \left(\begin{array}{cc}
n & \sum t_i \\ \sum t_i & \sum t_i^2
\...
...)
=
\left(\begin{array}{c}
\sum f_i \\ \sum t_i f_i
\end{array}\right)\,.
$

If at least two of the $ t_i$ are different, then the determinant is

$\displaystyle (\underbrace{1+\cdots+1}_{n\,\text{times}})
\vert\left(t_1,\ldot...
...\right)^{\operatorname t}\vert _2^2 - \left(\sum_i 1\cdot t_i\right)^2 > 0\,,
$

and we obtain the given solution by Cramer's rule.
  automatically generated 4/21/2005