Next: NEXT
Up: SIC Language Internal Help
Previous: LET /FILE
MFIT
[SIC\]MFIT Yvar=Func(Xvar,&A,&B,...) [/START A1,B1,...]
[/STEP A2,B2,...] [/EPSILON e] [/WEIGHTS w] [/METHOD m]
or
[SIC\]MFIT Filename [/START A1,B1,...] [/STEP A2,B2,...]
[/EPSILON e] [/WEIGHTS w] [/METHOD m]
Performs a least squares fit using the SIMPLEX (default) or POWELL
algorithm (if option /METHOD P is selected) from Numerical Recipes, see
Press et al. for details. The least square fit tries to adjust function
Func of variable Xvar and parameters &A, &B, ... to match variable Yvar.
Any function or combination of functions known by SIC may be used.
Blanks are supported in the formula. The '=' sign is required.
/START A1,B1,... (comma-separated list WITHOUT BLANKS) is used to pass
starting guesses for the parameters &A &B (defaulted to 0.1),
/STEP A2,B2,...(comma-separated list WITHOUT BLANKS) is used to pass the
unity vectors (steps) for the iteration on parameters &A &B (defaulted
to 1.0).
Fit parameter DUMMY names are &A...&Z . Already defined SIC variables
may be used in the formula as long as they don't match the variables
used by MFIT. The resulting parameters will be stored in the real
variable MFIT. Option /EPSILON can be used to specify the desired
precision, which means the deviation of the mean squared difference of
two fit iterations. This might NOT be the absolute error of the fit
parameters. An array with weights may be given by option /WEIGHT. It
must match the dimension of the formula result (defaulted to uniform
weight).
The formula can also be provided by a disk file (default extension
.GRF), where lines beginning with an exclamation mark are treated as
comments. Inside the file, blanks can be used in the formula, which may
be spread over several lines.
The command MFIT uses the following global SIC variables:
MFIT : Fit parameters
MFITMATH : Text string containing the formula with replaced dummies
MFITOUT : Found approximation (the application of MFITMATH)
MFIT_RES : Residuals (i.e. MFITOUT-Yvar)
MFIT_SUM : Mean squared residuals
MFIT_ERR : .FALSE. on successful completion.
Suppose you read X,Y=f(X) and Z (errorbar on Y) in the 3 arrays X, Y and
Z. You could change Z into weights (for example SIC\LET Z 1|Z^2 ), then
fit a cubic polynomial regression in variables X,Y by typing
MFIT Y=(&A*X^3+&B*X^2+&C*X+&D) /WEIGHTS Z
The MFIT command will print the used formula:
I-MFIT, Formula (stored in variable MFITMATH) :
(MFIT[01]*X^3+MFIT[02]*X^2+MFIT[03]*X+MFIT[04])
The array MFIT will contain MFIT[1]=value of '&A', and so on... To be
used afterwards.
Gildas manager
2001-04-18