Getting Started | Documentation | Glish | Learn More | Programming | Contact Us |
Version 1.9 Build 1556 |
|
Package | utility | |
Module | fitting | |
Tool | functionfitter |
pars | in | The parameters to set | |
Allowed: | Numeric vector |
This function sets the parameters of the function that you wish to fit to the data. If you are going to do a linear fit, you don't need to call this function.
If you are going to do a non-linear fit you need to set a guess for the parameters (else they will be zero by default).
When you set parameters, the internally stored Functional tool is updated with the new parameters. Actually doing a fit does not change the values of the parameters. This means that if you wanted to do something like 1) do a fit, 2) set the parameters of the function to the solution and then hold a parameter fixed, and re-fit, you would need to do that explicitly yourself (see example below).
- include 'functionfitter.g' - x := 1:10 # Make some data - y := 2 + 3*x - ff := functionfitter() # Create fitter - ff.setdata(x,y) # Set data - ff.setfunction ('p0 + p1*x') # Create functional (parameters [0,0]) - sol := ff.fit() # Linear fit all parameters solved for - print sol [2 3] - ff.setparameters(1.2*sol) # Update internal functional parameters - print ff.fit(fixed=[F,T]) # Hold second parameter fixed at wrong value [-1.3 3.6] # and drive solution off for first parameter