manpagez: man pages & more
info mathgl_en
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.16 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 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 it. At this, the ‘x,y,z’ coordinates are equidistantly distributed in the axis range. Number of points in fit is defined by option value (default is mglFitPnts=100). Note, that this functions use GSL library and do something only if MathGL was compiled with GSL support. See section Nonlinear fitting hints, for sample code and picture.

MGL command: fits res adat sdat 'func' 'var' [ini=0]
MGL command: fits res xdat adat sdat 'func' 'var' [ini=0]
MGL command: fits res xdat ydat adat sdat 'func' 'var' [ini=0]
MGL command: fits res xdat ydat zdat adat sdat 'func' 'var' [ini=0]
Method on mglGraph: mglData FitS (const mglDataA &a, const mglDataA &s, const char *func, const char *var, const char *opt="")
Method on mglGraph: mglData FitS (const mglDataA &a, const mglDataA &s, const char *func, const char *var, mglData &ini, const char *opt="")
Method on mglGraph: mglData FitS (const mglDataA &x, const mglDataA &a, const mglDataA &s, const char *func, const char *var, const char *opt="")
Method on mglGraph: mglData FitS (const mglDataA &x, const mglDataA &a, const mglDataA &s, const char *func, const char *var, mglData &ini, const char *opt="")
Method on mglGraph: mglData FitS (const mglDataA &x, const mglDataA &y, const mglDataA &a, const mglDataA &s, const char *func, const char *var, const char *opt="")
Method on mglGraph: mglData FitS (const mglDataA &x, const mglDataA &y, const mglDataA &a, const mglDataA &s, const char *func, const char *var, mglData &ini, const char *opt="")
Method on mglGraph: mglData FitS (const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const mglDataA &s, const char *func, const char *var, const char *opt="")
Method on mglGraph: mglData FitS (const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const mglDataA &s, const char *func, const char *var, mglData &ini, const char *opt="")
C function: HMDT mgl_fit_ys (HMGL gr, HCDT a, HCDT s, const char *func, const char *var, HMDT ini, const char *opt)
C function: HMDT mgl_fit_xys (HMGL gr, HCDT x, HCDT a, HCDT s, const char *func, const char *var, HMDT ini, const char *opt)
C function: HMDT mgl_fit_xyzs (HMGL gr, HCDT x, HCDT y, HCDT a, HCDT s, const char *func, const char *var, HMDT ini, const char *opt)
C function: HMDT mgl_fit_xyzas (HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, HCDT s, const char *func, const char *var, HMDT ini, const char *opt)

Fit data along x-, y- and z-directions for array specified parametrically a[i,j,k](x[i,j,k], y[i,j,k], z[i,j,k]) with weight factor s[i,j,k].

MGL command: fit res adat sdat 'func' 'var' [ini=0]
MGL command: fit res xdat adat sdat 'func' 'var' [ini=0]
MGL command: fit res xdat ydat adat sdat 'func' 'var' [ini=0]
MGL command: fit res xdat ydat zdat adat sdat 'func' 'var' [ini=0]
Method on mglGraph: mglData Fit (const mglDataA &a, const char *func, const char *var, const char *opt="")
Method on mglGraph: mglData Fit (const mglDataA &a, const char *func, const char *var, mglData &ini, const char *opt="")
Method on mglGraph: mglData Fit (const mglDataA &x, const mglDataA &a, const char *func, const char *var, const char *opt="")
Method on mglGraph: mglData Fit (const mglDataA &x, const mglDataA &a, const char *func, const char *var, mglData &ini, const char *opt="")
Method on mglGraph: mglData Fit (const mglDataA &x, const mglDataA &y, const mglDataA &a, const char *func, const char *var, const char *opt="")
Method on mglGraph: mglData Fit (const mglDataA &x, const mglDataA &y, const mglDataA &a, const char *func, const char *var, mglData &ini, const char *opt="")
Method on mglGraph: mglData Fit (const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const char *func, const char *var, const char *opt="")
Method on mglGraph: mglData Fit (const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const char *func, const char *var, mglData &ini, const char *opt="")
C function: HMDT mgl_fit_y (HMGL gr, HCDT a, const char *func, const char *var, HMDT ini, const char *opt)
C function: HMDT mgl_fit_xy (HMGL gr, HCDT x, HCDT a, const char *func, const char *var, HMDT ini, const char *opt)
C function: HMDT mgl_fit_xyz (HMGL gr, HCDT x, HCDT y, HCDT a, const char *func, const char *var, HMDT ini, const char *opt)
C function: HMDT mgl_fit_xyza (HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *func, const char *var, HMDT ini, const char *opt)

Fit data along x-, y- and z-directions for array specified parametrically a[i,j,k](x[i,j,k], y[i,j,k], z[i,j,k]) with weight factor 1.

Method on mglGraph: mglData Fit2 (const mglDataA &a, const char *func, const char *var, const char *opt="")
Method on mglGraph: mglData Fit2 (mglData &fit, const mglDataA &a, const char *func, const char *var, mglData &ini, const char *opt="")
Method on mglGraph: mglData Fit3 (mglData &fit, const mglDataA &a, const char *func, const char *var, const char *opt="")
Method on mglGraph: mglData Fit3 (mglData &fit, const mglDataA &a, const char *func, const char *var, mglData &ini, const char *opt="")
C function: HMDT mgl_fit_2 (HMGL gr, HCDT a, const char *func, const char *var, HMDT ini, const char *opt)
C function: HMDT mgl_fit_3 (HMGL gr, HCDT a, const char *func, const char *var, HMDT ini, const char *opt)

Fit data along all directions for 2d or 3d arrays a with s=1 and x, y, z equidistantly distributed in interval [Min, Max].

MGL command: putsfit x y ['pre'='' 'fnt'='' size=-1]
Method on mglGraph: void PutsFit (mglPoint p, const char *prefix="", const char *font="", mreal size=-1)
C function: void mgl_puts_fit (HMGL gr, mreal x, mreal y, mreal z, const char *prefix, const char *font, mreal size)

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: const char * GetFit ()
C function: const char * mgl_get_fit (HMGL gr)

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


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on March 21, 2014 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.