E250: Least-Squares Fit to Straight Line

Author(s): M. Metcalf Library: MATHLIB
Submitter: Submitted: 01.05.1977
Language: Fortran Revised: 27.11.1984

Given a vector of values Y measured at the points X, LFIT and LFITW find the best least-squares fit to the linear relationship Y=aX+b. LFIT performs an unweighted fit and LFITW takes account of a given vector of weights. Both subroutines have an option for skipping missing points without shifting the points of the vector X.

Structure:

SUBROUTINE subprogram
User Entry Names: LFIT, LFITW

Usage:

CALL LFIT(X,Y,L,KEY,A,B,VAR) or
CALL LFITW(X,Y,W,L,KEY,A,B,VAR)
X
(REAL) Vector of abscissae.
Y
(REAL) Vector of values corresponding to points X.
W
(REAL) Vector of weights (for LFITW only).
L
(INTEGER) Length of vectors X, Y and W.
KEY
(INTEGER)
tex2html_wrap_inline88 indicates that any points where tex2html_wrap_inline90 are to be skipped,
tex2html_wrap_inline92 indicates that all L points are to be used.
A
(REAL) Fitted slope a.
B
(REAL) Fitted constant term b.
VAR
(REAL) Residual sum of squares divided by ( tex2html_wrap_inline98 ) indicating the badness of fit.

References:

  1. D.H. Menzel, Fundamental Formulas of Physics, Dover Publ., New York (1960) 116.
tex2html_wrap_inline100

Michel Goossens Wed Jun 5 03:34:07 METDST 1996