| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
3.15 Nonlinear fitting
These functions 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 function ‘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. Parameter print=true switch on printing the found coefficients to Message (see section Error handling).
Functions Fit() and FitS() do not draw the obtained data themselves. They fill the data fit by formula ‘f’ with found coefficients and return the \chi^2 error of approximation. At this, the ‘x,y,z’ coordinates are equidistantly distributed in the interval Min–Max. Number of points in fit is selected as maximal value of fit size and the value of FitPnts. Note, that this functions use GSL library and do something only if MathGL was compiled with GSL support. See section Fitting sample, for sample code and picture.
- Method on
mglGraph(C++, Python):floatFitS (mglData &fit,const mglData &x,const mglData &y,const mglData &z,const mglData &a,const mglData &s,const char *func,const char *var,float *ini=NULL,boolprint=false) - Method on
mglGraph(C++, Python):floatFitS (mglData &fit,const mglData &x,const mglData &y,const mglData &z,const mglData &a,const mglData &s,const char *func,const char *var,mglData &ini,boolprint=false) - C function:
floatmgl_fit_xyzas (HMGLgr,HMDTfit,const HMDTx,const HMDTy,const HMDTz,const HMDTa,const HMDTs,const char *func,const char *var,float *ini) - C function:
floatmgl_fit_xyzas_d (HMGLgr,HMDTfit,const HMDTx,const HMDTy,const HMDTz,const HMDTa,const HMDTs,const char *func,const char *var,HMDTini) Fit data along x-, y- and z-directions for 3d array specified parametrically a[i,j,k](x[i,j,k], y[i,j,k], z[i,j,k]).
- Method on
mglGraph(C++, Python):floatFitS (mglData &fit,const mglData &x,const mglData &y,const mglData &a,const mglData &s,const char *func,const char *var,float *ini=NULL,boolprint=false) - Method on
mglGraph(C++, Python):floatFitS (mglData &fit,const mglData &x,const mglData &y,const mglData &a,const mglData &s,const char *func,const char *var,mglData &ini,boolprint=false) - C function:
floatmgl_fit_xyzs (HMGLgr,HMDTfit,const HMDTx,const HMDTy,const HMDTa,const HMDTs,const char *func,const char *var,float *ini) - C function:
floatmgl_fit_xyzs_d (HMGLgr,HMDTfit,const HMDTx,const HMDTy,const HMDTa,const HMDTs,const char *func,const char *var,HMDTini) Fit data along x-, and y-directions for 2d array specified parametrically a[i,j](x[i,j], y[i,j]) for each data slice.
- Method on
mglGraph(C++, Python):floatFitS (mglData &fit,const mglData &x,const mglData &a,const mglData &s,const char *func,const char *var,float *ini=NULL,boolprint=false) - Method on
mglGraph(C++, Python):floatFitS (mglData &fit,const mglData &x,const mglData &a,const mglData &s,const char *func,const char *var,mglData &ini,boolprint=false) - C function:
floatmgl_fit_xys (HMGLgr,HMDTfit,const HMDTx,const HMDTa,const HMDTs,const char *func,const char *var,float *ini) - C function:
floatmgl_fit_xys_d (HMGLgr,HMDTfit,const HMDTx,const HMDTa,const HMDTs,const char *func,const char *var,HMDTini) Fit data along x-direction for 1d array specified parametrically a[i](x[i]) for each data slice.
- Method on
mglGraph(C++, Python):floatFitS (mglData &fit,const mglData &a,const mglData &s,const char *func,const char *var,float *ini=NULL,boolprint=false) - Method on
mglGraph(C++, Python):floatFitS (mglData &fit,const mglData &a,const mglData &s,const char *func,const char *var,mglData &ini,boolprint=false) - C function:
floatmgl_fit_ys (HMGLgr,HMDTfit,const HMDTa,const HMDTs,const char *func,const char *var,float *ini) - C function:
floatmgl_fit_ys_d (HMGLgr,HMDTfit,const HMDTa,const HMDTs,const char *func,const char *var,HMDTini) Fit data along x-direction for 1d array with x equidistantly distributed in interval [Min.x, Max.x].
- Method on
mglGraph(C++, Python):floatFit (mglData &fit,const mglData &x,const mglData &y,const mglData &z,const mglData &a,const char *func,const char *var,float *ini=NULL,boolprint=false) - Method on
mglGraph(C++, Python):floatFit (mglData &fit,const mglData &x,const mglData &y,const mglData &z,const mglData &a,const char *func,const char *var,mglData &ini,boolprint=false) - C function:
floatmgl_fit_xyza (HMGLgr,HMDTfit,const HMDTx,const HMDTy,const HMDTz,const HMDTa,const char *func,const char *var,float *ini) - C function:
floatmgl_fit_xyza_d (HMGLgr,HMDTfit,const HMDTx,const HMDTy,const HMDTz,const HMDTa,const char *func,const char *var,HMDTini) Fit data along x-, y- and z-directions for 3d array specified parametrically a[i,j,k](x[i,j,k], y[i,j,k], z[i,j,k]) with s[i,j,k]=1.
- Method on
mglGraph(C++, Python):floatFit (mglData &fit,const mglData &x,const mglData &y,const mglData &a,const char *func,const char *var,float *ini=NULL,boolprint=false) - Method on
mglGraph(C++, Python):floatFit (mglData &fit,const mglData &x,const mglData &y,const mglData &a,const char *func,const char *var,mglData &ini,boolprint=false) - C function:
floatmgl_fit_xyz (HMGLgr,HMDTfit,const HMDTx,const HMDTy,const HMDTa,const char *func,const char *var,float *ini) - C function:
floatmgl_fit_xyz_d (HMGLgr,HMDTfit,const HMDTx,const HMDTy,const HMDTa,const char *func,const char *var,HMDTini) Fit data along x-, and y-directions for 2d array specified parametrically a[i,j](x[i,j], y[i,j]) with s[i,j]=1 for each data slice.
- Method on
mglGraph(C++, Python):floatFit (mglData &fit,const mglData &x,const mglData &a,const char *func,const char *var,float *ini=NULL,boolprint=false) - Method on
mglGraph(C++, Python):floatFit (mglData &fit,const mglData &x,const mglData &a,const char *func,const char *var,mglData &ini,boolprint=false) - C function:
floatmgl_fit_xy (HMGLgr,HMDTfit,const HMDTx,const HMDTa,const char *func,const char *var,float *ini) - C function:
floatmgl_fit_xy_d (HMGLgr,HMDTfit,const HMDTx,const HMDTa,const char *func,const char *var,HMDTini) Fit data along x-direction for 1d array specified parametrically a[i](x[i]) with s[i]=1 for each data slice.
- Method on
mglGraph(C++, Python):floatFit (mglData &fit,const mglData &a,const char *func,const char *var,float *ini="",boolprint=false) - Method on
mglGraph(C++, Python):floatFit (mglData &fit,const mglData &a,const char *func,const char *var,mglData &ini,boolprint=false) - C function:
floatmgl_fit_1 (HMGLgr,HMDTfit,const HMDTa,const char *func,const char *var,float *ini) - C function:
floatmgl_fit_1_d (HMGLgr,HMDTfit,const HMDTa,const char *func,const char *var,HMDTini) Fit data along x-direction for 1d array a with s=1 and x equidistantly distributed in interval [Min.x, Max.x].
- Method on
mglGraph(C++, Python):floatFit2 (mglData &fit,const mglData &a,const char *func,const char *var,float *ini=NULL,boolprint=false) - Method on
mglGraph(C++, Python):floatFit2 (mglData &fit,const mglData &a,const char *func,const char *var,mglData &ini,boolprint=false) - C function:
floatmgl_fit_2 (HMGLgr,HMDTfit,const HMDTa,const char *func,const char *var,float *ini) - C function:
floatmgl_fit_2_d (HMGLgr,HMDTfit,const HMDTa,const char *func,const char *var,HMDTini) Fit data along x-, and y-directions for 2d array a with s=1 and x, y equidistantly distributed in interval [Min, Max].
- Method on
mglGraph(C++, Python):floatFit3 (mglData &fit,const mglData &a,const char *func,const char *var,float *ini=NULL,boolprint=false) - Method on
mglGraph(C++, Python):floatFit3 (mglData &fit,const mglData &a,const char *func,const char *var,mglData &ini,boolprint=false) - C function:
floatmgl_fit_3 (HMGLgr,HMDTfit,const HMDTa,const char *func,const char *var,float *ini) - C function:
floatmgl_fit_3_d (HMGLgr,HMDTfit,const HMDTa,const char *func,const char *var,HMDTini) Fit data along x-, y- and z-directions for 3d array a with s=1 and x, y, z equidistantly distributed in interval [Min, Max].
- Method on
mglGraph(C++, Python):voidPutsFit (mglPointp,const char *prefix="",const char *font=NULL,floatsize=-1) - C function:
voidmgl_puts_fit (HMGLgr,floatx,floaty,floatz,const char *prefix,const char *font,floatsize=-1) Print last fitted formula with found coefficients (as numbers) at position p0. The string prefix will be printed before formula. All other parameters are the same as in Text printing.
- Method on
mglGraph(C++, Python):const char *GetFit () - C function:
const char *mgl_get_fit (HMGLgr) Get last fitted formula with found coefficients (as numbers).
- General option (C++) of mglGraph:
intFitPnts Minimal number of points for output array after nonlinear fitting.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
