#include <LMFitter.h>


Public Member Functions | |
| virtual void | calcAlpha () |
| Calculates the alpha matrix. More... | |
| virtual bool | calcBestFit () |
| Calculates the best fit. More... | |
| virtual int | calcCovariance (std::vector< std::vector< double > > &cov) |
| Calculates the covariance matrix. More... | |
| virtual int | calcDegreesOfFreedom () const |
| Returns the number of degrees of freedom in the fit. More... | |
| virtual bool | calcStep () |
| Takes a step in the fitting and returns the change to the parameters of the function. More... | |
| Fitter * | clone () const |
| Makes a copy of the receiving object. More... | |
| virtual void | copyFrom (const Fitter *other) |
| Makes a copy of other. More... | |
| void | fillFreeParameters (std::vector< double > &) const |
| Fills the vector with the free parameters values. More... | |
| StatedFCN * | getFCN () |
| Returns the objective function object. More... | |
| virtual const std::vector< int > & | getFixedFlags () const |
| Sets the limits of the model function parameter values. More... | |
| bool | getUseErrors () const |
Returns true if error data from the DataSource will be used if available. More... | |
| bool | isCompatible (const FunctionBase *) const |
Returns true if the function is compatible with the objective function. More... | |
| LMFitter (const char *name) | |
| The constructor taking name of fitter as argument. More... | |
| const std::string & | name () const |
| Returns the name of the fitter. More... | |
| bool | needsIntegrated () const |
Returns true if the Fitter needs integrated intervals. More... | |
| virtual double | objectiveValue () const |
| Calculates the value of the objective function at the current set of parameters. More... | |
| void | setDataSource (const DataSource *source) |
| Sets the source of data to be used. More... | |
| virtual void | setFCN (StatedFCN *fcn) |
| Sets the objective function. More... | |
| virtual void | setFitCut (TupleCut *cut) |
| Sets the cut to limit range of fitting. More... | |
| virtual void | setFitRange (bool yes=true) |
| Sets use of a fitting range on or off. More... | |
| virtual void | setFixedFlags (const std::vector< int > &flags) |
| Sets the parameters that are to be held fixed during objective function minimization. More... | |
| void | setFunction (FunctionBase *function) |
| Sets the model function. More... | |
| virtual void | setLimits (unsigned int i, double lower, double upper) |
| Sets the limits for the parameter of the model function indexed by i. More... | |
| void | setLimits (const std::string &name, double lower, double upper) |
| Sets the limits for the parameter of the model function with name name. More... | |
| virtual void | setStepSize (unsigned int i, double size) |
| Sets the step size for parameter of the minimization. More... | |
| void | setStepSize (const std::string &name, double size) |
| Sets the minimization step size for model function parameter name. More... | |
| void | setUseErrors (bool yes=true) |
| Sets the fitter to use error data from the DataSource, if available. More... | |
| virtual bool | solveSystem () |
| Solves the system. More... | |
Protected Attributes | |
| StatedFCN * | m_fcn |
| The objective function. More... | |
| int | m_max_iterations |
| The maximum number of iterations allowed in attempting the fit. More... | |
| std::string | m_name |
| The name of the fitter. More... | |
Private Member Functions | |
| LMFitter (const LMFitter &) | |
| The copy constructor. More... | |
Private Attributes | |
| std::vector< std::vector < double > > | m_alpha |
| The alpha matrix. More... | |
| std::vector< double > | m_beta |
| The beta vector. More... | |
| double | m_chi_cutoff |
| The Chi Squared cut-off parameter. More... | |
| double | m_lambda |
| The current lambda factor. More... | |
| double | m_lambda_expand_factor |
| The factor by which lambda is divided if it is too small. More... | |
| double | m_lambda_shrink_factor |
| The factor by which lambda is divided if it is too large. More... | |
| double | m_start_lambda |
| The starting lambda factor. More... | |
A Fitter class.
A Fitter class that uses derivatives of functions for fitting.
An implementation of the Levenberg Marquart.
Definition at line 33 of file LMFitter.h.
| LMFitter | ( | const char * | name | ) |
The constructor taking name of fitter as argument.
Definition at line 42 of file LMFitter.cxx.
|
virtual |
Calculates the alpha matrix.
Definition at line 72 of file LMFitter.cxx.
References LMFitter::m_alpha, LMFitter::m_beta, Fitter::m_fcn, and LMFitter::m_lambda.
Referenced by LMFitter::calcCovariance(), and LMFitter::calcStep().
|
virtual |
Calculates the best fit.
Returns true if the fit converged; otherwise it returns false.
Implements Fitter.
Definition at line 196 of file LMFitter.cxx.
References LMFitter::calcStep(), Fitter::fillFreeParameters(), i, LMFitter::m_beta, LMFitter::m_chi_cutoff, Fitter::m_fcn, LMFitter::m_lambda, LMFitter::m_lambda_expand_factor, LMFitter::m_lambda_shrink_factor, Fitter::m_max_iterations, LMFitter::m_start_lambda, Fitter::objectiveValue(), and ok.
|
virtual |
Calculates the covariance matrix.
Returns EXIT_SUCCESS if a minima of the chi2 functions is found, returns EXIT_FAILURE in case algorithm converges on other stationary points (i.e. on saddle points).
Reimplemented from Fitter.
Definition at line 95 of file LMFitter.cxx.
References LMFitter::calcAlpha(), hippodraw::Numeric::invertMatrix(), LMFitter::m_alpha, and LMFitter::m_lambda.
|
virtualinherited |
Returns the number of degrees of freedom in the fit.
Definition at line 229 of file Fitter.cxx.
References Fitter::m_fcn.
Referenced by FunctionProjector::degreesOfFreedom().
|
virtual |
Takes a step in the fitting and returns the change to the parameters of the function.
Definition at line 188 of file LMFitter.cxx.
References LMFitter::calcAlpha(), ok, and LMFitter::solveSystem().
Referenced by LMFitter::calcBestFit().
|
virtual |
Makes a copy of the receiving object.
Makes copy of receiving object by creating a new one with the only constructor.
Implements Fitter.
Definition at line 65 of file LMFitter.cxx.
References LMFitter::LMFitter().
|
virtualinherited |
|
inherited |
Fills the vector with the free parameters values.
Definition at line 142 of file Fitter.cxx.
References Fitter::m_fcn.
Referenced by LMFitter::calcBestFit(), and BFGSFitter::calcBestFit().
|
inherited |
Returns the objective function object.
Definition at line 73 of file Fitter.cxx.
References Fitter::m_fcn.
|
virtualinherited |
Sets the limits of the model function parameter values.
Attempts to set the limits of the model function parameter values. This base class implementation throws a FitterException. Derived classes that support setting limits of the parameter values should override this member function.Returns a vector containing flags for which parameters are to be held fixed during objective function minimization.
Definition at line 156 of file Fitter.cxx.
References Fitter::m_fcn.
Referenced by MinuitMigrad::initialize().
|
inherited |
Returns true if error data from the DataSource will be used if available.
Definition at line 119 of file Fitter.cxx.
References Fitter::m_fcn, and yes.
|
inherited |
Returns true if the function is compatible with the objective function.
Definition at line 80 of file Fitter.cxx.
References Fitter::m_fcn, and yes.
|
inherited |
Returns the name of the fitter.
Definition at line 57 of file Fitter.cxx.
References Fitter::m_name.
Referenced by Fitter::getParameterIndex(), MinuitMigrad::initialize(), BFGSFitter::iterParam(), and BFGSFitter::setIterParam().
|
inherited |
Returns true if the Fitter needs integrated intervals.
Definition at line 131 of file Fitter.cxx.
References Fitter::m_fcn, and yes.
|
virtualinherited |
Calculates the value of the objective function at the current set of parameters.
Definition at line 222 of file Fitter.cxx.
References Fitter::m_fcn.
Referenced by LMFitter::calcBestFit(), BFGSFitter::function(), BFGSFitter::gradient(), BFGSFitter::gradp(), and FunctionProjector::objectiveValue().
|
inherited |
Sets the source of data to be used.
Definition at line 100 of file Fitter.cxx.
References Fitter::m_fcn, and Fitter::setUseErrors().
|
virtual |
Sets the objective function.
Sets the objective function and indicate to it that it needs partial derivatives.
Reimplemented from Fitter.
Definition at line 241 of file LMFitter.cxx.
References Fitter::setFCN().
|
virtualinherited |
Sets the cut to limit range of fitting.
Definition at line 243 of file Fitter.cxx.
References Fitter::m_fcn.
|
virtualinherited |
Sets use of a fitting range on or off.
Definition at line 250 of file Fitter.cxx.
References Fitter::m_fcn.
|
virtualinherited |
Sets the parameters that are to be held fixed during objective function minimization.
Definition at line 149 of file Fitter.cxx.
References Fitter::m_fcn.
|
inherited |
|
virtualinherited |
Sets the limits for the parameter of the model function indexed by i.
This base class implementation throws a std::runtime_error. Derived classes that implement this function should override it.
Reimplemented in MinuitMigrad.
Definition at line 163 of file Fitter.cxx.
References Fitter::m_name.
Referenced by Fitter::setLimits().
|
inherited |
Sets the limits for the parameter of the model function with name name.
Definition at line 197 of file Fitter.cxx.
References Fitter::getParameterIndex(), index, and Fitter::setLimits().
|
virtualinherited |
Sets the step size for parameter of the minimization.
This base class implementation throws FitterException. Derived classes that support setting step size should override this member function.
Reimplemented in MinuitMigrad.
Definition at line 205 of file Fitter.cxx.
References Fitter::m_name.
Referenced by Fitter::setStepSize().
|
inherited |
Sets the minimization step size for model function parameter name.
Definition at line 215 of file Fitter.cxx.
References Fitter::getParameterIndex(), index, and Fitter::setStepSize().
|
inherited |
Sets the fitter to use error data from the DataSource, if available.
Definition at line 110 of file Fitter.cxx.
References Fitter::m_fcn.
Referenced by Fitter::setDataSource().
|
virtual |
Solves the system.
Definition at line 107 of file LMFitter.cxx.
References i, LMFitter::m_alpha, and LMFitter::m_beta.
Referenced by LMFitter::calcStep().
|
private |
The alpha matrix.
Definition at line 43 of file LMFitter.h.
Referenced by LMFitter::calcAlpha(), LMFitter::calcCovariance(), and LMFitter::solveSystem().
|
private |
The beta vector.
Definition at line 46 of file LMFitter.h.
Referenced by LMFitter::calcAlpha(), LMFitter::calcBestFit(), and LMFitter::solveSystem().
|
private |
The Chi Squared cut-off parameter.
If the two iterations of a step change the Chi squared less than this quantity, then no more steps are taken.
Definition at line 51 of file LMFitter.h.
Referenced by LMFitter::calcBestFit().
|
protectedinherited |
The objective function.
Definition at line 59 of file Fitter.h.
Referenced by LMFitter::calcAlpha(), LMFitter::calcBestFit(), MinuitMigrad::calcBestFit(), BFGSFitter::calcBestFit(), Fitter::calcDegreesOfFreedom(), MinuitMigrad::checkIndex(), Fitter::copyFrom(), Fitter::fillFreeParameters(), Fitter::Fitter(), BFGSFitter::function(), Fitter::getFCN(), Fitter::getFixedFlags(), Fitter::getParameterIndex(), Fitter::getUseErrors(), BFGSFitter::gradient(), BFGSFitter::gradp(), MinuitMigrad::initialize(), MinuitMigrad::initLimits(), Fitter::isCompatible(), Fitter::needsIntegrated(), Fitter::objectiveValue(), Fitter::setDataSource(), Fitter::setFCN(), Fitter::setFitCut(), Fitter::setFitRange(), Fitter::setFixedFlags(), Fitter::setFunction(), Fitter::setUseErrors(), and Fitter::~Fitter().
|
private |
The current lambda factor.
Definition at line 57 of file LMFitter.h.
Referenced by LMFitter::calcAlpha(), LMFitter::calcBestFit(), and LMFitter::calcCovariance().
|
private |
The factor by which lambda is divided if it is too small.
Definition at line 63 of file LMFitter.h.
Referenced by LMFitter::calcBestFit().
|
private |
The factor by which lambda is divided if it is too large.
Definition at line 60 of file LMFitter.h.
Referenced by LMFitter::calcBestFit().
|
protectedinherited |
The maximum number of iterations allowed in attempting the fit.
Definition at line 62 of file Fitter.h.
Referenced by LMFitter::calcBestFit(), BFGSFitter::calcBestFit(), BFGSFitter::iterParam(), and BFGSFitter::setIterParam().
|
protectedinherited |
The name of the fitter.
Definition at line 51 of file Fitter.h.
Referenced by MinuitMigrad::checkIndex(), Fitter::name(), Fitter::setLimits(), and Fitter::setStepSize().
|
private |
The starting lambda factor.
Definition at line 54 of file LMFitter.h.
Referenced by LMFitter::calcBestFit().