manpagez: man pages & more
info mathgl
Home | html | info | man
[ < ] [ > ]   [ << ] [ 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 MinMax. 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): float FitS (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, bool print=false)
Method on mglGraph (C++, Python): float FitS (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, bool print=false)
C function: float mgl_fit_xyzas (HMGL gr, HMDT fit, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const HMDT s, const char *func, const char *var, float *ini)
C function: float mgl_fit_xyzas_d (HMGL gr, HMDT fit, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const HMDT s, const char *func, const char *var, HMDT ini)

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): float FitS (mglData &fit, const mglData &x, const mglData &y, const mglData &a, const mglData &s, const char *func, const char *var, float *ini=NULL, bool print=false)
Method on mglGraph (C++, Python): float FitS (mglData &fit, const mglData &x, const mglData &y, const mglData &a, const mglData &s, const char *func, const char *var, mglData &ini, bool print=false)
C function: float mgl_fit_xyzs (HMGL gr, HMDT fit, const HMDT x, const HMDT y, const HMDT a, const HMDT s, const char *func, const char *var, float *ini)
C function: float mgl_fit_xyzs_d (HMGL gr, HMDT fit, const HMDT x, const HMDT y, const HMDT a, const HMDT s, const char *func, const char *var, HMDT ini)

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): float FitS (mglData &fit, const mglData &x, const mglData &a, const mglData &s, const char *func, const char *var, float *ini=NULL, bool print=false)
Method on mglGraph (C++, Python): float FitS (mglData &fit, const mglData &x, const mglData &a, const mglData &s, const char *func, const char *var, mglData &ini, bool print=false)
C function: float mgl_fit_xys (HMGL gr, HMDT fit, const HMDT x, const HMDT a, const HMDT s, const char *func, const char *var, float *ini)
C function: float mgl_fit_xys_d (HMGL gr, HMDT fit, const HMDT x, const HMDT a, const HMDT s, const char *func, const char *var, HMDT ini)

Fit data along x-direction for 1d array specified parametrically a[i](x[i]) for each data slice.

Method on mglGraph (C++, Python): float FitS (mglData &fit, const mglData &a, const mglData &s, const char *func, const char *var, float *ini=NULL, bool print=false)
Method on mglGraph (C++, Python): float FitS (mglData &fit, const mglData &a, const mglData &s, const char *func, const char *var, mglData &ini, bool print=false)
C function: float mgl_fit_ys (HMGL gr, HMDT fit, const HMDT a, const HMDT s, const char *func, const char *var, float *ini)
C function: float mgl_fit_ys_d (HMGL gr, HMDT fit, const HMDT a, const HMDT s, const char *func, const char *var, HMDT ini)

Fit data along x-direction for 1d array with x equidistantly distributed in interval [Min.x, Max.x].

Method on mglGraph (C++, Python): float Fit (mglData &fit, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *func, const char *var, float *ini=NULL, bool print=false)
Method on mglGraph (C++, Python): float Fit (mglData &fit, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *func, const char *var, mglData &ini, bool print=false)
C function: float mgl_fit_xyza (HMGL gr, HMDT fit, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const char *func, const char *var, float *ini)
C function: float mgl_fit_xyza_d (HMGL gr, HMDT fit, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const char *func, const char *var, HMDT ini)

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): float Fit (mglData &fit, const mglData &x, const mglData &y, const mglData &a, const char *func, const char *var, float *ini=NULL, bool print=false)
Method on mglGraph (C++, Python): float Fit (mglData &fit, const mglData &x, const mglData &y, const mglData &a, const char *func, const char *var, mglData &ini, bool print=false)
C function: float mgl_fit_xyz (HMGL gr, HMDT fit, const HMDT x, const HMDT y, const HMDT a, const char *func, const char *var, float *ini)
C function: float mgl_fit_xyz_d (HMGL gr, HMDT fit, const HMDT x, const HMDT y, const HMDT a, const char *func, const char *var, HMDT ini)

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): float Fit (mglData &fit, const mglData &x, const mglData &a, const char *func, const char *var, float *ini=NULL, bool print=false)
Method on mglGraph (C++, Python): float Fit (mglData &fit, const mglData &x, const mglData &a, const char *func, const char *var, mglData &ini, bool print=false)
C function: float mgl_fit_xy (HMGL gr, HMDT fit, const HMDT x, const HMDT a, const char *func, const char *var, float *ini)
C function: float mgl_fit_xy_d (HMGL gr, HMDT fit, const HMDT x, const HMDT a, const char *func, const char *var, HMDT ini)

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): float Fit (mglData &fit, const mglData &a, const char *func, const char *var, float *ini="", bool print=false)
Method on mglGraph (C++, Python): float Fit (mglData &fit, const mglData &a, const char *func, const char *var, mglData &ini, bool print=false)
C function: float mgl_fit_1 (HMGL gr, HMDT fit, const HMDT a, const char *func, const char *var, float *ini)
C function: float mgl_fit_1_d (HMGL gr, HMDT fit, const HMDT a, const char *func, const char *var, HMDT ini)

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): float Fit2 (mglData &fit, const mglData &a, const char *func, const char *var, float *ini=NULL, bool print=false)
Method on mglGraph (C++, Python): float Fit2 (mglData &fit, const mglData &a, const char *func, const char *var, mglData &ini, bool print=false)
C function: float mgl_fit_2 (HMGL gr, HMDT fit, const HMDT a, const char *func, const char *var, float *ini)
C function: float mgl_fit_2_d (HMGL gr, HMDT fit, const HMDT a, const char *func, const char *var, HMDT ini)

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): float Fit3 (mglData &fit, const mglData &a, const char *func, const char *var, float *ini=NULL, bool print=false)
Method on mglGraph (C++, Python): float Fit3 (mglData &fit, const mglData &a, const char *func, const char *var, mglData &ini, bool print=false)
C function: float mgl_fit_3 (HMGL gr, HMDT fit, const HMDT a, const char *func, const char *var, float *ini)
C function: float mgl_fit_3_d (HMGL gr, HMDT fit, const HMDT a, const char *func, const char *var, HMDT ini)

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): void PutsFit (mglPoint p, const char *prefix="", const char *font=NULL, float size=-1)
C function: void mgl_puts_fit (HMGL gr, float x, float y, float z, const char *prefix, const char *font, float size=-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 (HMGL gr)

Get last fitted formula with found coefficients (as numbers).

General option (C++) of mglGraph: int FitPnts

Minimal number of points for output array after nonlinear fitting.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2024
Individual documents may contain additional copyright information.