BESTFIT command

Syntax: BESTFIT pmin pmax penalty error parm pout
BESTFIT\WEIGHTS w pmin pmax penalty error parm pout
BESTFIT\CYCLES n pmin pmax penalty error parm pout
BESTFIT\WEIGHTS\CYCLES w n pmin pmax penalty error parm pout
Qualifiers: \WEIGHTS, \CYCLES
Defaults: \-WEIGHTS, \-CYCLES

The BESTFIT command calculates parameters for a least squares fit to an error vector using adjustable parameters. The parameter ranges, as well as the penalty function, must be vectors, with lengths equal to the number, M, of parameters for the fit. The error array must be a vector with length equal to the number of locations, N. The influence function, PARM, must be a matrix with N rows and M columns.

Suppose you have an error vector, ERROR, with length N, and that you have M variable parameters. The measured effect of a unit change for each of the parameters at each of the N locations is stored in a matrix, PARM, with N rows and M columns. Suppose you have a vector PENALTY, of length M, which represents the resistences to change of the M parameters, that is, the larger PENALTY[i] the smaller will be the adjustment of the ith parameter. The optimal set of changes of the M parameters within their allowed range, PMIN to PMAX, will be determined in the 'least-squares sense'. A vector, POUT, will be created with length M and filled with the parameter changes giving the "best" fit.

The \CYCLES qualifier allows the user to specify the maximum number of iteration steps for the fit. When this maximum number is reached, the fit will stop. The fit will also stop if the fit is successful before this maximum iteration number is reached. If the \WEIGHTS qualifier is also used, the weight array comes before the iteration number in the parameter list.

If the \WEIGHTS qualifier is used, a weight vector, w, will be expected. The weight vector should have length N, the length of the error vector. The weight, w[i], corresponds to the 'importance' of reducing the initial error to zero at the ith location. The closer to zero the value of w[i], the looser will be the fit at the ith location. If the \CYCLES qualifier is also used, the weight array comes before the iteration number in the parameter list.