| Getting Started | Documentation | Glish | Learn More | Programming | Contact Us |
| Version 1.9 Build 1556 |
|
| Package | utility | |
| Module | fitting |
| fitter | Construct fitting tool |
| chi2 | get the chi squared |
| constraint | get missing rank constraint equations |
| covariance | get the covariance matrix |
| deficiency | get missing rank |
| done | Remove the tool's resources |
| error | get errors in unknowns |
| fitavg | Get an average |
| fitpoly | Solve polynomial equations |
| fitspoly | Solve polynomial equationswith large x-range |
| fitted | Test Levenberg-Marquardt loop |
| fitter | Create a sub-tool |
| functional | Solve a general fitting problem |
| getstate | Obtain the state of the fitter |
| id | identification of tool |
| init | Initialize a fitting tool for use or re-use |
| linear | Solve a linear fitting problem |
| rank | get solution rank |
| reset | Reset the tool to its initialized state |
| sd | get standard deviation per unit weight |
| set | (Re-)initialize selected fitting tool properties |
| solution | get solution |
| stddev | get mean error (standard deviation per observation) |
| type | Obtain the type of the tool |
A fitting tool has properties that can be set at creation; by the init method, by the set method and implicity by the use of the linear and functional methods. Properties are:
- include 'fitting.g' # 1
T
- y := 0.1*1:5 # 2
- f := dfs.compiled('p') # 3
- dfit.linear(f,[],y); # 4
T
- dfit.solution(); # 5
0.3
- dfit.getstate() # 6
[n=1, typ=0, colfac=1e-08, lmfac=0.001, type=real]
- dfit.rank() # 7
1
- dfit.sd()
0.158114
- dfit.stddev()
0.158114
- dfit.chi2()
0.1
- dfit.covariance() # 8
0.2
- dfit.error()
0.0707107
- dfit.set(type='complex'); # 9
T
- dfit.getstate()
[n=1, typ=1, colfac=1e-08, lmfac=0.001, type=complex]
- dfit.linear(dfs.compiled('p*x'), [1:6]*0 + 1, [1:6] + 1.5i*(1:6)) # 10
T
- dfit.solution() # 11
3.5+5.25i
# a one step option:
- dfit.linear(dfs.poly(), 1:5, 1:5); dfit.solution() # 12
T
3+0i
- dfit.set(type='real'); # 13
T
- dfit.linear(dfs.poly(), 1:5, 1:5); dfit.solution() # 14
T
3
- dfit.set(type='complex') #15
T
- [1:5,2*(1:5)]+1i*(1:10) [1+1i 2+2i 3+3i 4+4i 5+5i 2+6i 4+7i 6+8i 8+9i 10+10i]where alternate values belong to the same set of observables
This example shows the general usage of the fitting tool for linear equations:
The above, simple, example, it is assumed that the data will fit a zero degree polynomial (i.e. just an average). It is just as easy to fit through the same data a higher degree polynomial. Let us first make the observed values:
- y := [1:10]The simple way to fit an average here is (note we are still in complex type mode, but easy to correct):
- dfit.fitavg(y) T - dfit.solution() 5.5+0i - dfit.set(type='real') T - dfit.fitavg(y) T - dfit.solution() 5.5Another way is to make use of a zero degree polynomial, specified as a = y:
- x:=array(1,10) - dfit.fitpoly(0,x,y) T - dfit.solution() 5.5What would a 2-degree polynomial through the data look like ( a + bx + cx2 = y):
- dfit.fitpoly(2,1:10,y) T - dfit.solution() [0 1 0]
Non-linear fitting can be done in the same way; with slightly different calls for the full-blown case. For the generic case just replace the linear with functional, and a non-linear method will be used, using the Levenberg-Marquardt method.
The major difference is that the functional provided as model should have initial parameter estimates set.
Note that, of course, you can write your own non-linear solution by providing an initial parameter estimate in the functional to be fitted, use the linear method, and upfate the parameters until some criterium is met.
| fitter | fitting tool |
| functionfitter | Tool to do simple fitting of numeric data |
| fitter | Construct fitting tool |
| chi2 | get the chi squared |
| constraint | get missing rank constraint equations |
| covariance | get the covariance matrix |
| deficiency | get missing rank |
| done | Remove the tool's resources |
| error | get errors in unknowns |
| fitavg | Get an average |
| fitpoly | Solve polynomial equations |
| fitspoly | Solve polynomial equationswith large x-range |
| fitted | Test Levenberg-Marquardt loop |
| fitter | Create a sub-tool |
| functional | Solve a general fitting problem |
| getstate | Obtain the state of the fitter |
| id | identification of tool |
| init | Initialize a fitting tool for use or re-use |
| linear | Solve a linear fitting problem |
| rank | get solution rank |
| reset | Reset the tool to its initialized state |
| sd | get standard deviation per unit weight |
| set | (Re-)initialize selected fitting tool properties |
| solution | get solution |
| stddev | get mean error (standard deviation per observation) |
| type | Obtain the type of the tool |