Next: 5.3
Fitting functions linear Up: 5.
Least-Squares Methods of Previous: 5.1
General discussion and
5.2 Fitting a straight line to
observations
If the measurements all have the same uncertainty
,
if only uncertainties in y (and not in
)
are important, and if the functional representation of the measurements
is f(x;y0,b)=y0+bx,
then the best-fit values of y0 and b are those
that minimize
 |
(5.5) |
Then
 |
(5.6) |
or
 |
(5.7) |
where N is the number of observations. Then
 |
(5.8) |
Also,
 |
(5.9) |
or
 |
(5.10) |
The solution to the
simultaneous equations (5.8) and (5.10) is
 |
(5.11) |
 |
(5.12) |
If new variables
and
are used,
=0,
and the preceding formulas simplify to
 |
(5.13) |
 |
(5.14) |
When transformed back to the original variables, the fitted form
gives
 |
(5.15) |
or
 |
(5.16) |
and
 |
(5.17) |
Despite the apparent simplification in (5.13) and (5.14), these forms
are not usually used because two passes through the data are needed to
first remove the mean and then calculate the needed sums. Instead, it is
usually simplest to calculate the average values
,
,
,
and
in one pass through the data, calculate b from (5.11) and then calculate
y0 from (5.12).
The uncertainty in the fit parameters can be determined by using (5.3):
 |
(5.18) |
 |
(5.19) |
 |
(5.20) |
where the indices (1,2) represent respectively y0
and b.
Note that the variance in y0, V y0,y0,
is not equal to 1/H11. The error matrix is the inverse
of H, and in this case that is not obtained by taking the inverse
of each element. Instead, the full matrix H must be calculated and
inverted:
 |
(5.21) |
 |
(5.22) |
Then
 |
(5.23) |
 |
(5.24) |
 |
(5.25) |
If
=0,
the covariance between y0 and b is zero, and the parameters
become uncorrelated. This is an advantage to working with the transformed
variables
and
which
have the means removed.
If the uncertainty
is unknown, it may be estimated from the measurements:
 |
(5.26) |
The factor 1/(N-2) arises because two degrees of freedom have been lost
in this two-parameter fit to the data.
The extension to the case where the uncertainties
vary is straightforward. It will be presented as part of the more general
discussion of fitting to linear parameters.
Next: 5.3
Fitting functions linear ...Up: 5.
Least-Squares Methods ... Previous: 5.1
General discussion
NCAR Advanced Study Program
http://www.asp.ucar.edu