#include <LMFitter.h>
Inheritance diagram for LMFitter:
A Fitter class that uses derivatives of functions for fitting.
An implementation of the Levenberg Marquart.
Kaustuv <kaustuv@stanford.edu>
Paul F. Kunz <Paul_Kunz@slac.stanford.edu>
Definition at line 32 of file LMFitter.h.
Public Member Functions | |
virtual void | calcAlpha () |
Calculates the alpha matrix. | |
virtual bool | calcBestFit () |
Calculates the best fit. | |
virtual int | calcCovariance (std::vector< std::vector< double > > &cov) |
Calculates the covariance matrix. | |
virtual int | calcDegreesOfFreedom () const |
Returns the number of degrees of freedom in the fit. | |
virtual bool | calcStep () |
Takes a step in the fitting and returns the change to the parameters of the function. | |
Fitter * | clone () const |
Makes a copy of the receiving object. | |
void | fillFreeParameters (std::vector< double > &) const |
Fills the vector with the free parameters values. | |
StatedFCN * | getFCN () |
Returns the objective function object. | |
virtual const std::vector< int > & | getFixedFlags () const |
Returns a vector containing flags for which parameters are to be held fixed during objective function minimization. | |
double | iterParam (std::string name) |
Given a string, this function returns the value of the associated iteration parameter. | |
LMFitter (const char *name) | |
The constructor taking name of fitter as argument. | |
const std::string & | name () const |
Returns the name of the fitter. | |
virtual bool | needsDerivatives () const |
Returns true as thi fitter needs the function to calculate its partial derivatives. | |
virtual double | objectiveValue () const |
Calculates the value of the objective function at the current set of parameters. | |
void | setFCN (StatedFCN *fcn) |
Sets the objective function object. | |
virtual void | setFitCut (TupleCut *cut) |
Sets the cut to limit range of fitting. | |
virtual void | setFitRange (bool yes=true) |
Sets use of a fitting range on or off. | |
virtual void | setFixedFlags (const std::vector< int > &flags) |
Sets the parameters that are to be held fixed during objective function minimization. | |
int | setIterParam (std::string name, double value) |
Given a string and a double, this function sets the value of the associated iteration parameter. | |
void | setLimits (const std::string &name, double lower, double upper) |
Sets the limits for the parameter of the model function with name name. | |
virtual void | setLimits (unsigned int i, double lower, double upper) |
Sets the limits for the parameter of the model function indexed by i. | |
void | setStepSize (const std::string &name, double size) |
Sets the minimization step size for model function parameter name. | |
virtual void | setStepSize (unsigned int i, double size) |
Sets the step size for parameter of the minimization. | |
virtual bool | solveSystem () |
Solves the system. | |
Protected Attributes | |
StatedFCN * | m_fcn |
The objective function. | |
int | m_max_iterations |
The maximum number of iterations allowed in attempting the fit. | |
std::string | m_name |
The name of the fitter. | |
Private Attributes | |
std::vector< std::vector< double > > | m_alpha |
The alpha matrix. | |
std::vector< double > | m_beta |
The beta vector. | |
double | m_chi_cutoff |
The Chi Squared cut-off parameter. | |
std::map< std::string, double * > | m_iter_params |
Map of the various iteration parameters to their name. | |
double | m_lambda |
The current lambda factor. | |
double | m_lambda_expand_factor |
The factor by which lambda is divided if it is too small. | |
double | m_lambda_shrink_factor |
The factor by which lambda is divided if it is too large. | |
double | m_start_lambda |
The starting lambda factor. |
|
The constructor taking name of fitter as argument.
Definition at line 48 of file LMFitter.cxx. References m_chi_cutoff, m_iter_params, m_lambda_expand_factor, m_lambda_shrink_factor, and m_start_lambda. Referenced by clone(). |
|
Calculates the alpha matrix.
Definition at line 77 of file LMFitter.cxx. References m_alpha, m_beta, Fitter::m_fcn, and m_lambda. Referenced by calcCovariance(), and calcStep(). |
|
Calculates the best fit.
Returns Implements Fitter. Definition at line 201 of file LMFitter.cxx. References std::abs(), calcStep(), Fitter::fillFreeParameters(), m_beta, m_chi_cutoff, Fitter::m_fcn, m_lambda, m_lambda_expand_factor, m_lambda_shrink_factor, Fitter::m_max_iterations, m_start_lambda, and Fitter::objectiveValue(). |
|
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 100 of file LMFitter.cxx. References calcAlpha(), hippodraw::Numeric::invertMatrix(), m_alpha, and m_lambda. |
|
Returns the number of degrees of freedom in the fit.
Definition at line 165 of file Fitter.cxx. References Fitter::m_fcn. Referenced by FunctionProjector::degreesOfFreedom(), and hippodraw::Python::export_Fitter(). |
|
Takes a step in the fitting and returns the change to the parameters of the function.
Definition at line 193 of file LMFitter.cxx. References calcAlpha(), and solveSystem(). Referenced by calcBestFit(). |
|
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 63 of file LMFitter.cxx. References LMFitter(). |
|
Fills the vector with the free parameters values.
Definition at line 68 of file Fitter.cxx. References Fitter::m_fcn. Referenced by calcBestFit(), and BFGSFitter::calcBestFit(). |
|
Returns the objective function object.
Definition at line 54 of file Fitter.cxx. References Fitter::m_fcn. Referenced by hippodraw::Python::export_Fitter(). |
|
Returns a vector containing flags for which parameters are to be held fixed during objective function minimization.
Definition at line 82 of file Fitter.cxx. References Fitter::m_fcn. Referenced by MinuitMigrad::calcBestFit(). |
|
Given a string, this function returns the value of the associated iteration parameter. Names of the various iteration parameters have been chosen according to the following simple rule. m_foo_bar is called foo_bar. Definition at line 243 of file LMFitter.cxx. References m_iter_params, and Fitter::m_max_iterations. |
|
Returns the name of the fitter.
Definition at line 61 of file Fitter.cxx. References Fitter::m_name. Referenced by hippodraw::Python::export_Fitter(), and MinuitMigrad::initialize(). |
|
Returns
Implements Fitter. Definition at line 70 of file LMFitter.cxx. |
|
Calculates the value of the objective function at the current set of parameters.
Definition at line 158 of file Fitter.cxx. References Fitter::m_fcn. Referenced by calcBestFit(), hippodraw::Python::export_Fitter(), BFGSFitter::function(), BFGSFitter::gradient(), BFGSFitter::gradp(), and FunctionProjector::objectiveValue(). |
|
Sets the objective function object. Sets the objective function object to be used and takes possession of it. That is, will delete the current object, if there is one, and will delete the object in this object's destructor. Definition at line 45 of file Fitter.cxx. References Fitter::m_fcn. |
|
Sets the cut to limit range of fitting.
Definition at line 179 of file Fitter.cxx. References Fitter::m_fcn. |
|
Sets use of a fitting range on or off.
Definition at line 186 of file Fitter.cxx. References Fitter::m_fcn. |
|
Sets the parameters that are to be held fixed during objective function minimization.
Definition at line 75 of file Fitter.cxx. References Fitter::m_fcn. Referenced by hippodraw::Python::export_Fitter(). |
|
Given a string and a double, this function sets the value of the associated iteration parameter. Names of the various parameters have been chosen according to the following simple rule. m_foo_bar is called foo_bar. Definition at line 263 of file LMFitter.cxx. References m_iter_params, and Fitter::m_max_iterations. |
|
Sets the limits for the parameter of the model function with name name.
Definition at line 123 of file Fitter.cxx. References Fitter::getParameterIndex(), and Fitter::setLimits(). |
|
Sets the limits for the parameter of the model function indexed by i.
Reimplemented in MinuitMigrad. Definition at line 89 of file Fitter.cxx. References Fitter::m_name. Referenced by hippodraw::Python::export_Fitter(), and Fitter::setLimits(). |
|
Sets the minimization step size for model function parameter name.
Definition at line 151 of file Fitter.cxx. References Fitter::getParameterIndex(), and Fitter::setStepSize(). |
|
Sets the step size for parameter of the minimization. This base class implementation throws FitterException. Derived classes that suport setting step size should override this member function. Reimplemented in MinuitMigrad. Definition at line 141 of file Fitter.cxx. References Fitter::m_name. Referenced by hippodraw::Python::export_Fitter(), and Fitter::setStepSize(). |
|
Solves the system.
Definition at line 112 of file LMFitter.cxx. References std::abs(), m_alpha, m_beta, and std::swap(). Referenced by calcStep(). |
|
The alpha matrix.
Definition at line 42 of file LMFitter.h. Referenced by calcAlpha(), calcCovariance(), and solveSystem(). |
|
The beta vector.
Definition at line 45 of file LMFitter.h. Referenced by calcAlpha(), calcBestFit(), and solveSystem(). |
|
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 50 of file LMFitter.h. Referenced by calcBestFit(), and LMFitter(). |
|
|
Map of the various iteration parameters to their name.
Definition at line 65 of file LMFitter.h. Referenced by iterParam(), LMFitter(), and setIterParam(). |
|
The current lambda factor.
Definition at line 56 of file LMFitter.h. Referenced by calcAlpha(), calcBestFit(), and calcCovariance(). |
|
The factor by which lambda is divided if it is too small.
Definition at line 62 of file LMFitter.h. Referenced by calcBestFit(), and LMFitter(). |
|
The factor by which lambda is divided if it is too large.
Definition at line 59 of file LMFitter.h. Referenced by calcBestFit(), and LMFitter(). |
|
The maximum number of iterations allowed in attempting the fit.
Definition at line 58 of file Fitter.h. Referenced by calcBestFit(), BFGSFitter::calcBestFit(), iterParam(), BFGSFitter::iterParam(), setIterParam(), and BFGSFitter::setIterParam(). |
|
The name of the fitter.
Definition at line 47 of file Fitter.h. Referenced by MinuitMigrad::checkIndex(), Fitter::name(), Fitter::setLimits(), and Fitter::setStepSize(). |
|
The starting lambda factor.
Definition at line 53 of file LMFitter.h. Referenced by calcBestFit(), and LMFitter(). |