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’). If string var contain digits 1,2,3 or 4 then robust approximation is used with replacing norm |df|^2 by following: ‘1’ - sqrt(1+|df|^2)-1, ‘2’ - |df|^4, ‘3’ - Andrew sine (1-cos(df)), ‘4’ - Tukey biweight (|df|^2*(1-C*|df|^2)). 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 Nonlinear fitting hints, for sample code and picture.
res adat sdat 'func' 'var' [ini=0]
¶res xdat adat sdat 'func' 'var' [ini=0]
¶res xdat ydat adat sdat 'func' 'var' [ini=0]
¶res xdat ydat zdat adat sdat 'func' 'var' [ini=0]
¶mglGraph
: mglData
FitS (const mglDataA &
a, const mglDataA &
s, const char *
func, const char *
var, const char *
opt=""
)
¶mglGraph
: mglData
FitS (const mglDataA &
a, const mglDataA &
s, const char *
func, const char *
var, mglData &
ini, const char *
opt=""
)
¶mglGraph
: mglData
FitS (const mglDataA &
x, const mglDataA &
a, const mglDataA &
s, const char *
func, const char *
var, const char *
opt=""
)
¶mglGraph
: mglData
FitS (const mglDataA &
x, const mglDataA &
a, const mglDataA &
s, const char *
func, const char *
var, mglData &
ini, const char *
opt=""
)
¶mglGraph
: mglData
FitS (const mglDataA &
x, const mglDataA &
y, const mglDataA &
a, const mglDataA &
s, const char *
func, const char *
var, const char *
opt=""
)
¶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=""
)
¶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=""
)
¶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=""
)
¶HMDT
mgl_fit_ys (HMGL
gr, HCDT
a, HCDT
s, const char *
func, const char *
var, HMDT
ini, const char *
opt)
¶HMDT
mgl_fit_xys (HMGL
gr, HCDT
x, HCDT
a, HCDT
s, const char *
func, const char *
var, HMDT
ini, const char *
opt)
¶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)
¶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]. If string var contains digits, then the norm for approximation is changed: ’1’ for norm sqrt(1+|u|^2), ’2’ for norm |u|^4, ’3’ for norm 1-cos(u), ’4’ for norm |u|^2*(2-|u|^2/6^2), default norm |u|^2.
res adat 'func' 'var' [ini=0]
¶res xdat adat 'func' 'var' [ini=0]
¶res xdat ydat adat 'func' 'var' [ini=0]
¶res xdat ydat zdat adat 'func' 'var' [ini=0]
¶mglGraph
: mglData
Fit (const mglDataA &
a, const char *
func, const char *
var, const char *
opt=""
)
¶mglGraph
: mglData
Fit (const mglDataA &
a, const char *
func, const char *
var, mglData &
ini, const char *
opt=""
)
¶mglGraph
: mglData
Fit (const mglDataA &
x, const mglDataA &
a, const char *
func, const char *
var, const char *
opt=""
)
¶mglGraph
: mglData
Fit (const mglDataA &
x, const mglDataA &
a, const char *
func, const char *
var, mglData &
ini, const char *
opt=""
)
¶mglGraph
: mglData
Fit (const mglDataA &
x, const mglDataA &
y, const mglDataA &
a, const char *
func, const char *
var, const char *
opt=""
)
¶mglGraph
: mglData
Fit (const mglDataA &
x, const mglDataA &
y, const mglDataA &
a, const char *
func, const char *
var, mglData &
ini, const char *
opt=""
)
¶mglGraph
: mglData
Fit (const mglDataA &
x, const mglDataA &
y, const mglDataA &
z, const mglDataA &
a, const char *
func, const char *
var, const char *
opt=""
)
¶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=""
)
¶HMDT
mgl_fit_y (HMGL
gr, HCDT
a, const char *
func, const char *
var, HMDT
ini, const char *
opt)
¶HMDT
mgl_fit_xy (HMGL
gr, HCDT
x, HCDT
a, const char *
func, const char *
var, HMDT
ini, const char *
opt)
¶HMDT
mgl_fit_xyz (HMGL
gr, HCDT
x, HCDT
y, HCDT
a, const char *
func, const char *
var, HMDT
ini, const char *
opt)
¶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. If string var contains digits, then the norm for approximation is changed: ’1’ for norm sqrt(1+|u|^2), ’2’ for norm |u|^4, ’3’ for norm 1-cos(u), ’4’ for norm |u|^2*(2-|u|^2/6^2), default norm |u|^2.
mglGraph
: mglData
Fit2 (const mglDataA &
a, const char *
func, const char *
var, const char *
opt=""
)
¶mglGraph
: mglData
Fit2 (mglData &
fit, const mglDataA &
a, const char *
func, const char *
var, mglData &
ini, const char *
opt=""
)
¶mglGraph
: mglData
Fit3 (mglData &
fit, const mglDataA &
a, const char *
func, const char *
var, const char *
opt=""
)
¶mglGraph
: mglData
Fit3 (mglData &
fit, const mglDataA &
a, const char *
func, const char *
var, mglData &
ini, const char *
opt=""
)
¶HMDT
mgl_fit_2 (HMGL
gr, HCDT
a, const char *
func, const char *
var, HMDT
ini, const char *
opt)
¶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 axis range.
x y
['pre'='' 'fnt'='' size=-1
]
¶mglGraph
: void
PutsFit (mglPoint
p, const char *
prefix=""
, const char *
font=""
, mreal
size=-1
)
¶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.
mglGraph
: const char *
GetFit
() ¶const char *
mgl_get_fit (HMGL
gr)
¶
mgl_get_fit (long
gr, char *
out, int
len)
¶Get last fitted formula with found coefficients (as numbers).