eLynx SDK
v3.3.0 C++ image processing API reference |
Non-linear iterative function fitter, implemented using Gauss-Newton method. More...
#include <GaussNewton.h>
Static Public Member Functions | |
static void | FitParams (const IFunctionNL &iFunction, const IMatrix &iSamples, const IVector &iInitialGuess, IVector &oParams, double iEpsilon=1e-5, uint32 iMaxIterations=0) |
Fits specified function for the given set of samples, using initial parameters guess for the first iteration. |
Non-linear iterative function fitter, implemented using Gauss-Newton method.
The class solves the problem of fitting nonlinear function to given set of samples - in other words, it tries to find the values for function parameters, for which the sum of squares of differences between function and given set of samples is minimized. The function can be of one or more independent variables. The non-linearity of the function is in the meaning of parameters, not variables - function with linear parameters can be fitted with single-pass least squares method. The function has to implement IFunctionNL interface in order to be fitted. The samples are given using matrix, parameters using vector. As the method is iterative one, caller must supply initial guess for parameter values.
static void eLynx::Math::GaussNewton::FitParams | ( | const IFunctionNL & | iFunction, |
const IMatrix & | iSamples, | ||
const IVector & | iInitialGuess, | ||
IVector & | oParams, | ||
double | iEpsilon = 1e-5 , |
||
uint32 | iMaxIterations = 0 |
||
) | [static] |
Fits specified function for the given set of samples, using initial parameters guess for the first iteration.
In general, it fits function of n-independent variables and m-parameters to the finite set of samples. Samples are specified as matrix with n+1 columns, one sample per row. Columns 0, 1, ... holds values for independent variables, last column contains values for dependent variable (function results). Initial parameters guess and resulting parameters values are given by vectors of size m.
iFunction | the function to be fitted |
iSamples | the matrix of samples |
iInitialGuess | the initial guess for parameters values |
oParams | the resulting parameters values (the best fit) |
iEpsilon | the iteration threshold value - if the difference in the length of parameter vector between two iterations is less than this value, the iteration stops |
iMaxIterations | if nonzero, the iteration will be stopped after specified number of iterations, even if threshold was not reached. Can be used to prevent infinite iteration problem. |