Least Squares
From Tauwiki
Contents |
[edit] Least Squares
[edit] Overview
A program to calculate the best fit slope and offset for a linear fit to data. This program should inherit much of its look and feel from Interpolate.
[edit] Algorithm
[edit] Math
y = ax + b
we have to minimize the χ2 where
To do this we take the partial derivatives with respect to a and to b and are left with
[edit] Programming
- Read x, y, and sigma from a file.
- Note that the file may have an arbitrary structure. The input format should make use of the methods developed for interpolate.
- Calculate a, b as outlined above.
- Print a, b, and χ2.
