Next: MFIT /EPSILON
Up: SIC Language Internal Help
[SIC\]MFIT Yvar=Func(Xvar,&A,&B,...) [/START A1 B1 ...] [/STEP A2 B2
...] [/EPSILON e] [/WEIGHTS w] [/METHOD m] [/QUIET]
[SIC\]MFIT Filename [/START A1 B1 ...] [/STEP A2 B2 ...] [/EPSILON
e] [/WEIGHTS w] [/METHOD m] [/QUIET]
Perform a least squares fit using the specified Method. 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.
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 structure
variable MFIT%. An array with weights may be given by option /WEIGHTS.
It must match the dimension of the formula result (defaulted to uniform
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 defines the following global SIC variables to hold its
MFIT%PAR : Fit parameters
MFIT%ERRORS : The parameter errors, if they have been computed
MFIT%MATH : Text string containing the formula with replaced dummies
MFIT%FIT : Found approximation (the application of MFIT%MATH)
MFIT%RES : Residuals (i.e. Yvar-MFIT%FIT)
MFIT%STATUS : .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 MFIT%MATH) :
The array MFIT%PAR will contain MFIT%PAR=value of '&A', and so on...
to be used afterwards.