PsiLAB Help Manual Page

Section: Nonlinear least square fit

Name: nlsfit

Perform a nonlinear least square fit of a 1 dimensional dataset.
This function provides a fitting algorithm when the model depends nonlineary on a set of M unknown parameters a k , k = 1,2,....,M .
[ Slow and obsolete version. Use the Fit module instead. ]
With a dataset y(x) depending on x and optionally the deviations sig(x) , nlsfit fits the dataset in respect to the function model
Y=Y(x,a k )

and returns
  1. The fitted parameter set param fit ,
  2. the remaining least square sum C2 .R,
  3. and the standard errors of the fit parameters.

The standard errors are only useable, if the sig(x) deviations of the dataset are provided. The NLS fit algorithm uses the Levenberg.Marquardt method, attempting to reduce the value C2 , as described in Numerical Recipes.
x:(float, 'a, 'b) Matrix.t
y:(float, 'a, 'b) Matrix.t
?sigv:(float, 'c, 'd) Matrix.t list
func:(float -> (float, 'e, 'f) Matrix.t -> float)
param0:(float, 'e, 'f) Matrix.t
-> param fit :(float, 'e, 'f) Matrix.t *
chisq:float * param sig :(float, 'g, 'h) Matrix.t

At least the x, y, func, and param0 arguments are needed. The model function expects 2 arguments: the variable x and the parameter matrix param .
The minchisq argument determines the condition for the end of the fit, it's the minimal difference between two successfull fit iterations of chisq. The maxstep argument sets the maximal number of iterations, and the plot arguments set on true will result in a graphical plot of the dataset and the fitted model function.
Printed by PsiLAB