vec_math
Interface ModelFitting

All Known Implementing Classes:
AbstractFit, ExpressionFit, HarmonicFit, OrbitFit, PhaseRegression

public interface ModelFitting

Model fitting instances can fit measurements to a particular model. Once the measured data is fitted to the model with fit(), the fitted model parameters getFittedParameters() can be retrieved, as well as the underlying data model getDataModel() that holds the link to the original measurements as well as the model fit.


Method Summary
 List<Variable> fit()
          Tries to fit the measures to the underlying data model.
 double getChi2()
          Returns the least-square chi2 value, weighted to the measurement errors, i.e.
 DataModel getDataModel()
          Returns the data model constructed out of the fitted data.
 List<Variable> getFittedParameters()
          Returns the fitted parameters after a successful call to fit().
 double getR2()
          Returns the coefficient of determination, R², which is in a linear model the square of the correlation coefficient.
 double getRms()
          Returns the RMS, which is the square root of the average residual squared of the model.
 DataModel prepareFit(VectorG[] data)
          Initializing the fitting process by preparing the underlying data model.
 double qualityOfFit()
          Returns a quality indicator for the fit, if in doubt return the chi2-expectation value.
 boolean setConstant(Variable to)
          Sets a parameter as a constant for the fit.
 boolean setInitialCondition(Variable to)
          Sets a parameter as an initial condition for the fit.
 

Method Detail

prepareFit

DataModel prepareFit(VectorG[] data)
Initializing the fitting process by preparing the underlying data model. All information known is present in the vector array passed over, and the model fitting instance must know how to discern the independant and depandant variables and erros from the individual vectors. In the most simple case, the data consists of two-dimensional vectors. The data model should be cached for later retrieval via getDataModel().

Parameters:
data - An array of measurements. Each vector contains dependant and independant variables and eventually their errors.
Returns:
The newly prepared data model.

fit

List<Variable> fit()
Tries to fit the measures to the underlying data model. The fitter must have been prepared with prepareFit(vec_math.VectorG[]). The solution returned is also retrievable later via getFittedParameters()

Returns:
Non-null, if a fit could be obtained.

setInitialCondition

boolean setInitialCondition(Variable to)
Sets a parameter as an initial condition for the fit. The argument describes the initial value of a parameter. During the fitting process, the value of this parameter may change. It is part of the fit returned.

Returns:
false, if the initial condition does not apply to this model.

setConstant

boolean setConstant(Variable to)
Sets a parameter as a constant for the fit. During the fitting process, the value of this parameter may not change and it is not part of the fit returned.

Returns:
false, if the constant does not apply to this model.

getDataModel

DataModel getDataModel()
Returns the data model constructed out of the fitted data. This method should return non-null after a call to prepareFit(vec_math.VectorG[]) has commenced, independant of (later) fitting success.


getFittedParameters

List<Variable> getFittedParameters()
Returns the fitted parameters after a successful call to fit().


qualityOfFit

double qualityOfFit()
Returns a quality indicator for the fit, if in doubt return the chi2-expectation value.


getRms

double getRms()
Returns the RMS, which is the square root of the average residual squared of the model. It can be obtained after fitting to the model, then calculating the resiuduals of the last fit, squaring those residuals and calculating their average.


getChi2

double getChi2()
Returns the least-square chi2 value, weighted to the measurement errors, i.e. the sum of (yi-fit)^2/err_i^2.


getR2

double getR2()
Returns the coefficient of determination, R², which is in a linear model the square of the correlation coefficient.