Description:
Levenberg-Marquardt method, attempting to reduce the
value of chi-squared of a fit between a set of data points X(1:NDATA), Y(1:NDATA), and a
non-linear function dependent on MA coefficients A(1:MA). The input array IA(1:MA)
indicates by non-zero components those components of A that should be fitted for, and by 0
entries those components that should be held fixed at their input values. The program
returns current best-fit values for the parameters A(1:MA), and chi-squared = CHISQ. The
arrays COVAR (1:NCA,1:NCA), ALPHA (1:NCA,1:NCA) with physical dimension NCA
(= the
number of fitted parameters) are used as working space during most iterations. Supply a subroutine FUNCS
(X, A, YFIT, DYDA, MA) that evaluates the fitting function YFIT, and its derivatives DYDA with respect to
the the fitting paramters A at X. On the first call provide an initial guess for the parameters A, and set
ALAMDA
0 for initialisation (which then sets ALAMDA = 0.001). If a step succeeds CHISQ becomes smaller and
ALAMDA decreases by a factor of 10. If a step fails ALAMDA grows by a factor of 10. You must call
this routine repeatedly until convergence is achieved. Then, make one final call with ALAMDA = 0, so
that COVAR (1:MA,1:MA) returns the covariance matrix, and ALPHA the curvature matrix.
Parameters held fixed will return zero covariance. Copied from MRQMIN on p.680 of Numerical
Recipes in Fortran, with STATUS added.
Invocation
CALL SCULIB_MRQMIN (X, Y, SIG, NDATA, A,
IA, MA, COVAR, ALPHA, NCA, CHISQ, FUNCS, ALAMDA, STATUS)
Arguments
X( NDATA ) = REAL
(Given)
X Data points
Y( NDATA ) = REAL (Given)
Y data points
SIG ( NDATA
) = REAL (Given)
NDATA = INTEGER (Given)
Number of data points in arrays
A( MA ) = REAL (Given & Returned)
The input parameter values. Contains the best-fit
values on exit.
IA( MA ) = INTEGER (Given)
Array specifying which components should
be fitted. A zero indicates the parameter should not be fitted – the parameters are kept
at their input values. Non-zero indicates the parameter is free to be modified.
MA =
INTEGER (Given)
Number of coefficients/parameters for function.
COVAR ( NCA, NCA ) =
REAL (Returned)
The covariance matrix. Fixed parameters will return zero covariance.
ALPHA ( NCA, NCA ) = REAL (Returned)
The curvature matrix.
NCA = INTEGER
(Given)
Size of output arrays. Must be greater than the number of fitted parameters
CHISQ = REAL (Returned)
ChiSq of fit.
FUNCS = REAL FUNCTION (Given)
The
function to be fitted. Must take arguments of X, A, YFIT, DYDA and MA, where YFIT is
the fitting function and DYDA the the derivatives with respect to parameters A at X.
ALAMDA = REAL (Given & Returned)
The stepping factor for the iteration. Should be set to
0
initially.
STATUS = INTEGER (Given & Returned)
Global Status
Copyright
Copyright
©1995,1996,1997,1998,1999 Particle Physics and Astronomy Research Council. All Rights Reserved.