Next: fit2, Previous: find_minloc, Up: Internal Routines [Contents][Index]

`fit( [`

`x`,] `y`, start=`start`, step=`step` [,
lowbound=`lowbound`, highbound=`highbound`,
weights=`weights`] [, qthresh=`qthresh`, pthresh=`pthresh`,
ithresh=`ithresh`, dthresh=`dthresh`, fac=`fac`,
niter=`niter`, nsame=`nsame`] [, err=`err`, fit=`fit`,
tthresh=`tthresh`] [, /vocal, /down, /pchi, /gaussians, /powerfunc])

Iterative non-linear fit to Gaussians, power functions, and user-defined
functions. The selected function is evaluated at positions

under guidance of trial model parameters and the found
model values are compared with `x`

. The model parameters are
adjusted to minimize the differences between the model values and
`y`

. The return value is an array containing the best found
model parameters and (at the end) the last fit quality number.
`y`

The fitted function depends on

, `fit``/gaussians`

, and
`/powerfunc`

.

`fit`If specified, then it must be a string containing the name of a function that takes arguments

,`par`

,`x`

, and, optionally,`y`

, with`w`

an array containing the current fit parameters and`par`

the weight of each data point, and that returns the fit quality which is a positive number that is closer to zero the better the fit is. Minimization of the fit quality is then the goal of the iterations.`w`- /gaussians
If

is not specified, then this keyword selects fitting to the sum of one or more gaussian functions of the form`fit`

. In this case`par`(0) +

(1)*exp(-((`par`

-`x`

(2))/`par`

(3))^2)`par`

must have four plus a multiple of three elements, and for each extra set of three an extra gaussian is added.`step`- /powerfunc
If

is not specified, then this keyword selects fitting to a general power function superimposed on a linear trend, of the form`fit`

.`par`(0) +

(1)*`par`

+`x`

(2)*(`par`

-`x`

(3))^`par`

(4)`par`

The fit parameters that are tried depend on

,
`start`

, `step`

, and `lowbound`

.
`hibound`

`x y`The data points to be fitted to.

`niter`In each iteration cycle,

different parameter sets are tried.`niter`

defaults to 10.`niter``start`contains the start values of the parameters. This array must have a number of elements equal to the number of fit parameters or the number of fit parameters plus one. In the latter case, the last element is ignored. (This is so that output from a previous call to

`fit`

can be entered as start values for the next call.)`step`contains the initial rms values by which the parameters are randomly varied from iteration to iteration. This array must have one element for each fitted parameter.

`lowbound`contains lower bounds on the parameters (default: no bounds). This array must have one element per fitted parameter.

`hibound`contains upper bounds on the parameters (default: no bounds). This array must have one element per fitted parameter.

The stop criterion on the iterations depend on

,
`qthresh`

, `pthresh`

, `ithresh`

,
`dthresh`

, and `tthresh`

, and parameter change
depends on `nsame`

. Estimated errors on the parameters are
returned in `fac`

.
`err`

`qthresh`contains a threshold on the fit quality, below which iteration is ceased. Defaults to zero.

`pthresh`contains thresholds on the maximum absolute change in the best-so-far parameters. When the change in the last iteration cycle is smaller than the corresponding threshold for all parameters, then the iteration is ceased [note: not yet implemented]. defaults to zero.

`ithresh`contains a threshold on the number of iteration cycles, above which iteration is ceased.

defaults to 1000.`ithresh``dthresh`contains a threshold on the relative change in the fit quality since the last iteration. If the relative change is less than

, then iteration is ceased.`dthresh`

defaults to 0.`dthresh``tthresh`contains the maximum number of seconds that the fit process may take. If at the end of an iteration it is more than

seconds later than when the fit process began, then iteration is ceased. If this variable is equal to 0, then no time threshold is applied. It defaults to 3600, i.e., one hour.`tthresh``nsame`If the best-so-far parameters do not change during

iteration cycles, then iterations are ceased.`nsame`

defaults to 5.`nsame``fac`contains a factor which limits the change of the rms spread of the parameters from iteration cycle to iteration cycle. The rms spread of each parameter in the next iteration cycle equals the change in the best-so-far value of that parameter since the last iteration cycle, but is limited in change to a factor of between

and 1/`fac`

.`fac`

defaults to 0.5.`fac``err`If

is defined, then rough estimates for the formal errors on the parameters are returned in it.`err`

`/down`

When the best-so-far parameters do not change from one iteration cycle to the next, then the rms parameter spread is decreased (if

`/down`

is specified, or by default) or increased (if`/nodown`

is specified) by a factor of 2 in the next iteration cycle.`/vocal`

selects display of best-so-far parameters after each iteration cycle. Displayed is: iteration rms-error: fit-parameters. Only those fit parameters for which the corresponding

value is unequal to zero are shown, and at most the first twenty such parameters are displayed.`step`

Next: fit2, Previous: find_minloc, Up: Internal Routines [Contents][Index]