Standard Library function that performs anonlinear least-squares fit to a function of an arbitrary number of parameters.
y A vector containing the dependent y-coordinates of the input data points. Must have the same number of elements as the x input parameter.
wt The vector of weighting factors for determining the weighting of the least-squares fit (see Discussion). The vector must be the same size as the x input parameter.
parms A six-element vector containing the parameters of the fitted function. On input, it should contain the initial estimates of each parameter.
If parms is supplied as a double-precision variable, the calculations are performed in double-precision accuracy. Otherwise, the calculations are performed in single-precision accuracy.
sigma (optional) A vector containing the standard deviations for the parameters in parms.
The initial estimates of parms should be as close to the actual values as possible or the solution may not converge. CURVEFIT performs iterations of the fitting function until the chi-squared value for the goodness of fit changes by less than 0.1 percent, or until 20 iterations are reached.
TIP: These initial estimates for parms can be calculated from the result of the POLY_FIT function when it is used to fit a straight line through data.
CURVEFIT is modified from the program CURFIT found in Data Reduction and Error Analysis for the Physical Sciences, by Philip Bevington, McGraw-Hill, New York, 1969. It combines a gradient search with an analytical solution developed from linearizing the fitting function. This method is termed a "gradient-expansion algorithm."
wt can have any value, as long as its size is correct. Some possible ways to weight a curve are suggested below (where i is an index into y, the vector of Y values):
TIP: In most cases, you would use a different weighting factor for each scale or instrument that was used to measure your original data.
gaussfit.pro
file in the Standard Library.