Getting Started | Documentation | Glish | Learn More | Programming | Contact Us |
Version 1.9 Build 1556 |
|
Package | utility | |
Module | fitting | |
Tool | functionfitter |
linear | in | Linear or non-linear fit ? | |
Allowed: | T or F | ||
Default: | T | ||
fixed | in | Fixed parameters mask | |
Allowed: | Boolean vector | ||
Default: | All parameters fitted |
This function computes and returns the fit of the supplied model to the data.
If you are doing a linear fit, you don't need to set any parameters. If you are doing a non-linear fit, you should supply an initial guess via the setparameters function. Only the data for which the data mask is good (T) will be considered in the fit.
You can also hold parameters fixed in the fit via the argument fixed. You enter a vector of Boolean values (T to hold fixed, F to fit), one for each parameter. By default, all parameters are fitted for.
- include 'functionfitter.g' - ff := functionfitter() - x := 1:10 - y := 2 + 3*x - ff.setdata (x, y) - ff.setfunction ('p0 + p1*x') - print ff.fit(linear=T) [2 3] - - ff.setparameters([0,3.2]) # Set function parameters - print ff.fit(fixed=[F,T]) # Hold second parameter fixed at 3.2 [0.9 3.2] # parameter off a bit