next up previous index
Next: E255 Least-Squares Fit Up: CERNLIB Previous: E230 Constrained and

E250 Least-Squares Fit to Straight Line

Routine ID: E250
Author(s): M. MetcalfLibrary: MATHLIB
Submitter: Submitted: 01.05.1977
Language: FortranRevised: 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)
= 0: indicates that any points where Y=0 are to be skipped,
= 1: 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 (L-2 ) indicating the badness of fit.

References:

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

E255


Janne Saarela
Mon Apr 3 15:06:23 METDST 1995