The following is a brief summary of the non-linear least-squares fit problem. See module header, Fitting, for a more complete description.
Given a set of N data points (measurements), (x(i), y(i)) i = 0,...,N-1, along with a set of standard deviations, sigma(i), for the data points, and a specified non-linear function, f(x;a) where a = a(j) j = 0,...,M-1 are a set of parameters to be determined, the non-linear least-squares fit tries to minimize
chi-square = [(y(0)-f(x(0);a)/sigma(0)]^2 + [(y(1)-f(x(1);a)/sigma(1)]^2 + ... + [(y(N-1)-f(x(N-1);a))/sigma(N-1)]^2.by adjusting {a(j)} in the equation.
For multidimensional functions, x(i) is a vector, and
f(x(i);a) = f(x(i,0), x(i,1), x(i,2), ...;a)
If the measurement errors (standard deviation sigma) are not known at all, they can all be set to one initially. In this case, we assume all measurements have the same standard deviation, after minimizing chi-square, we recompute
sigma^2 = {(y(0)-z(0))^2 + (y(1)-z(1))^2 + ... + (y(N-1)-z(N-1))^2}/(N-M) = chi-square/(N-M).
A statistic weight can be also be assigned to each measurement if the standard deviation is not available. sigma can be calculated from
sigma = 1/ sqrt(weight)Alternatively a 'weight' switch can be set with asWeight(). For best arithmetic performance, weight should be normalized to a maximum value of one. Having a large weight value can sometimes lead to overflow problems.
The function to be fitted to the data can be given as an instance of the Function class. One can also form a sum of functions using the CompoundFunction.
For small datasets the usage of the calls is:
The solution of a fit always produces the total number of parameters given to the fitter. I.e. including any parameters that were fixed. In the latter case the solution returned will be the fixed value.
If there are a large number of unknowns or a large number of data points machine memory limits (or timing reasons) may not allow a complete in-core fitting to be performed. In this case one can incrementally build the normal equation (see buildNormalMatrix()).
The normal operation of the class tests for real inversion problems only. If tests are needed for almost collinear columns in the solution matrix, the collinearity can be set as the square of the sine of the minimum angle allowed.
Singular Value Decomposition is supported by setting the 'svd' switch, which has a behaviour completely identical to, apart from a default collinearity check of 1e-8.
Other information (see a.o. LSQaips) can be set and obtained as well.
Create a fitter: the normal way to generate a fitter object. Necessary data will be deduced from the Functional provided with setFunction(). Create optionally a fitter with SVD behaviour specified.
Destructor
setMaxIter() sets the maximum number of iterations to do before stopping. Default value is 30.
getMaxIter() queries what the maximum number of iterations currently is
Generalised fitter