next up previous
Next: About this document

Least Squares Method

Suppose we have a set of data, that is a set of points tex2html_wrap_inline32 , which come from an experiment. See below tex2html_wrap80

If we wish to compute the ``error'' in fitting a straight line, we could compute the shortest distance to a line (see below) tex2html_wrap82

It is, however, more convenient to let the error be measured by the vertical deviation from the straight line, as shown below.

tex2html_wrap87

The vertical distance from a point tex2html_wrap_inline32 to the line y=mx+b is given by

displaymath38

And the total distance is

displaymath40

In order to obtain the ``best'' line, we want to make this error as small as possible. Minimizing the distance is the same as minimizing the distance squared, we define the error to be minimized as

displaymath42

Clearly, the error is a function of two variables, the slope (m) and the intercept (b). Since the error is a quadratic function of two variables, and is always positive, it must have a unique minimum! The minimum is achieved at the point tex2html_wrap_inline44 and tex2html_wrap_inline46 which satisfy

displaymath48

displaymath50

The quantities tex2html_wrap_inline52 , tex2html_wrap_inline54 , tex2html_wrap_inline56 and tex2html_wrap_inline58 are crucial to calculate. In terms of A, B, C, D, we have

displaymath60

displaymath62

We can solve these equations by substitution or by cross multiplication and subtraction:

displaymath64

displaymath66

therefore,

displaymath68

and

displaymath70

Dividing numerator and denominator by tex2html_wrap_inline72 we have

displaymath74

Solving for tex2html_wrap_inline46 from the first equation, we get

displaymath78

These general formulas are valid for an arbitrary amount of data, and can easily be programmed in maple or any other computer language.




Michael Pilant
Wed Oct 15 09:42:46 CDT 1997