[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
8.15 Nonlinear fitting (MGL)
These commands fit data to formula. Fitting goal is to find formula parameters for the best fit the data points, i.e. to minimize the sum \sum_i (f(x_i, y_i, z_i) - a_i)^2/s_i^2. At this, approximation function ‘f’ can depend only on one argument ‘x’ (1D case), on two arguments ‘x,y’ (2D case) and on three arguments ‘x,y,z’ (3D case). The command ‘f’ also may depend on parameters. Normally the list of fitted parameters is specified by var string (like, ‘abcd’). Usually user should supply initial values for fitted parameters by ini variable. But if he/she don’t supply it then the zeros are used.
Commands fit and fits do not draw the obtained data themselves. They fill the data out by formula ‘f’ with found coefficients. At this, the ‘x,y,z’ coordinates are equidistantly distributed in the bounding box. Number of points in out is selected as maximal value of out size or 100. Also you may print the last formula with found coefficients by putsfit
command. See section Fitting sample, for sample code and picture.
The dimensions of arrays must be at least the same as the number of specified arrays xdat, ydat, zdat. Also the fitting only along specified directions will be performed (for example, along x and y if only xdat and ydat are specified). If array xdat is not specified then its an automatic array is used with values equidistantly distributed along x.
- MGL command: fits adat sdat 'func' 'var' [ini=0]
- MGL command: fits xdat adat sdat 'func' 'var' [ini=0]
- MGL command: fits xdat ydat adat sdat 'func' 'var' [ini=0]
- MGL command: fits xdat ydat zdat adat sdat 'func' 'var' [ini=0]
Fit data along x-, y- and z-directions for 1d-,2d- or 3d array specified parametrically adat[i,j,k](xdat[i,j,k], ydat[i,j,k], zdat[i,j,k]) with weight factor sdat[i,j,k].
- MGL command: fit adat 'func' 'var' [ini=0]
- MGL command: fit xdat adat 'func' 'var' [ini=0]
- MGL command: fit xdat ydat adat 'func' 'var' [ini=0]
- MGL command: fit xdat ydat zdat adat 'func' 'var' [ini=0]
Fit data along x-, y- and z-directions for 1d-,2d- or 3d array specified parametrically adat[i,j,k](xdat[i,j,k], ydat[i,j,k], zdat[i,j,k]) with weight factor =1.
- MGL command: putsfit
x y
['pre'='' 'fnt'=''size=-1
] Print last fitted formula with found coefficients (as numbers) at position {x, y}. The string pre will be printed before formula. All other parameters are the same as in Text printing (MGL).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |