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

8.17 Nonlinear fitting (Pure C)

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.

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.

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]).

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.

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.

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].

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.

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.

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.

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].

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].

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].

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 {x, y, z}. The string prefix will be printed before formula. All other parameters are the same as in Text printing (Pure C).


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