BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
ROOT::Minuit2::FumiliChi2FCN Class Referenceabstract

Description

Extension of the FCNBase for the Fumili method. Fumili applies only to minimization problems used for fitting. The method is based on a linearization of the model function negleting second derivatives. User needs to provide the model function. The figure-of-merit describing the difference between the model function and the actual measurements in the case of chi-square is the sum of the squares of the figures-of-merit calculated for each measurement point, which is implemented by the operator() member function. The user still has to implement the calculation of the individual figures-of-merit (which in the majority of the cases will be the (measured Value - the Value predicted by the model)/standard deviation implemeted by the FumiliStandardChi2FCN; however this form can become more complicated (see for an example Numerical Recipes' section on "Straight-Line Data with Errors in Both Coordinates")).

Author
Andras Zsenei and Lorenzo Moneta, Creation date: 24 Aug 2004
See also
MINUIT Tutorial on function minimization, section 5
FumiliStandardChi2FCN

Definition at line 52 of file FumiliChi2FCN.h.

Inheritance diagram for ROOT::Minuit2::FumiliChi2FCN:
[legend]
Collaboration diagram for ROOT::Minuit2::FumiliChi2FCN:
[legend]

Public Member Functions

 FumiliChi2FCN ()
 
virtual ~FumiliChi2FCN ()
 
virtual unsigned int Dimension ()
 
virtual std::vector< double > Elements (const std::vector< double > &par) const =0
 
virtual double ErrorDef () const
 
virtual void EvaluateAll (const std::vector< double > &par)=0
 
virtual const std::vector< double > & GetMeasurement (int Index) const =0
 
virtual int GetNumberOfMeasurements () const =0
 
virtual const std::vector< double > & Gradient () const
 
virtual double Hessian (unsigned int row, unsigned int col) const
 
const ParametricFunctionModelFunction () const
 
double operator() (const std::vector< double > &par) const
 
virtual void SetErrorDef (double)
 
void SetModelFunction (const ParametricFunction &modelFCN)
 
virtual double Up () const
 
virtual double Value () const
 

Protected Member Functions

std::vector< double > & Gradient ()
 
std::vector< double > & Hessian ()
 
virtual void InitAndReset (unsigned int npar)
 
void SetFCNValue (double value)
 

Private Attributes

std::vector< double > fGradient
 
std::vector< double > fHessian
 
const ParametricFunctionfModelFunction = nullptr
 
unsigned int fNumberOfParameters
 
double fValue
 

Constructor & Destructor Documentation

◆ FumiliChi2FCN()

ROOT::Minuit2::FumiliChi2FCN::FumiliChi2FCN ( )
inline

Definition at line 56 of file FumiliChi2FCN.h.

56 {}

◆ ~FumiliChi2FCN()

virtual ROOT::Minuit2::FumiliChi2FCN::~FumiliChi2FCN ( )
inlinevirtual

Definition at line 58 of file FumiliChi2FCN.h.

58 {}

Member Function Documentation

◆ Dimension()

virtual unsigned int ROOT::Minuit2::FumiliFCNBase::Dimension ( )
inlinevirtualinherited

return number of function variable (parameters) , i.e. function dimension

Definition at line 132 of file FumiliFCNBase.h.

132 { return fNumberOfParameters; }

References ROOT::Minuit2::FumiliFCNBase::fNumberOfParameters.

◆ Elements()

virtual std::vector<double> ROOT::Minuit2::FumiliChi2FCN::Elements ( const std::vector< double > &  par) const
pure virtual

Evaluates the model function for the different measurement points and the Parameter values supplied, calculates a figure-of-merit for each measurement and returns a vector containing the result of this evaluation.

Parameters
parvector of Parameter values to feed to the model function.
Returns
A vector containing the figures-of-merit for the model function evaluated for each set of measurements.

Implemented in ROOT::Minuit2::FumiliStandardChi2FCN.

Referenced by operator()().

◆ ErrorDef()

virtual double ROOT::Minuit2::FCNBase::ErrorDef ( ) const
inlinevirtualinherited

Error definition of the function. MINUIT defines Parameter errors as the change in Parameter Value required to change the function Value by up. Normally, for chisquared fits it is 1, and for negative log likelihood, its Value is 0.5. If the user wants instead the 2-sigma errors for chisquared fits, it becomes 4, as Chi2(x+n*sigma) = Chi2(x) + n*n.

Comment a little bit better with links!!!!!!!!!!!!!!!!!

Definition at line 93 of file FCNBase.h.

93 {return Up();}
virtual double Up() const =0

References ROOT::Minuit2::FCNBase::Up().

Here is the call graph for this function:

◆ EvaluateAll()

virtual void ROOT::Minuit2::FumiliFCNBase::EvaluateAll ( const std::vector< double > &  par)
pure virtualinherited

Evaluate function Value, Gradient and Hessian using Fumili approximation, for values of parameters p The resul is cached inside and is return from the FumiliFCNBase::Value , FumiliFCNBase::Gradient and FumiliFCNBase::Hessian methods

Parameters
parvector of parameters

Implemented in ROOT::Minuit2::FumiliFCNAdapter< Function >, ROOT::Minuit2::FumiliStandardMaximumLikelihoodFCN, and ROOT::Minuit2::FumiliStandardChi2FCN.

◆ GetMeasurement()

virtual const std::vector<double>& ROOT::Minuit2::FumiliChi2FCN::GetMeasurement ( int  Index) const
pure virtual

Accessor to the parameters of a given measurement. For example in the case of a chi-square fit with a one-dimensional Gaussian, the Parameter characterizing the measurement will be the position. It is the Parameter that is feeded to the model function.

Parameters
IndexIndex of the measueremnt the parameters of which to return
Returns
A reference to a vector containing the values characterizing a measurement

Implemented in ROOT::Minuit2::FumiliStandardChi2FCN.

◆ GetNumberOfMeasurements()

virtual int ROOT::Minuit2::FumiliChi2FCN::GetNumberOfMeasurements ( ) const
pure virtual

Accessor to the number of measurements used for calculating the present figure of merit.

Returns
the number of measurements

Implemented in ROOT::Minuit2::FumiliStandardChi2FCN.

◆ Gradient() [1/2]

std::vector<double>& ROOT::Minuit2::FumiliFCNBase::Gradient ( )
inlineprotectedinherited

Definition at line 149 of file FumiliFCNBase.h.

149 { return fGradient; }
std::vector< double > fGradient

References ROOT::Minuit2::FumiliFCNBase::fGradient.

◆ Gradient() [2/2]

virtual const std::vector<double>& ROOT::Minuit2::FumiliFCNBase::Gradient ( ) const
inlinevirtualinherited

Return cached Value of function Gradient estimated previously using the FumiliFCNBase::EvaluateAll method

Definition at line 112 of file FumiliFCNBase.h.

112 { return fGradient; }

References ROOT::Minuit2::FumiliFCNBase::fGradient.

◆ Hessian() [1/2]

std::vector<double>& ROOT::Minuit2::FumiliFCNBase::Hessian ( )
inlineprotectedinherited

Definition at line 151 of file FumiliFCNBase.h.

151 { return fHessian; }
std::vector< double > fHessian

References ROOT::Minuit2::FumiliFCNBase::fHessian.

◆ Hessian() [2/2]

virtual double ROOT::Minuit2::FumiliFCNBase::Hessian ( unsigned int  row,
unsigned int  col 
) const
inlinevirtualinherited

Return Value of the i-th j-th element of the Hessian matrix estimated previously using the FumiliFCNBase::EvaluateAll method

Parameters
rowrow Index of the matrix
colcol Index of the matrix

Definition at line 120 of file FumiliFCNBase.h.

120  {
121  assert( row < fGradient.size() && col < fGradient.size() );
122  if(row > col)
123  return fHessian[col+row*(row+1)/2];
124  else
125  return fHessian[row+col*(col+1)/2];
126  }

References ROOT::Minuit2::FumiliFCNBase::fGradient, and ROOT::Minuit2::FumiliFCNBase::fHessian.

◆ InitAndReset()

virtual void ROOT::Minuit2::FumiliFCNBase::InitAndReset ( unsigned int  npar)
inlineprotectedvirtualinherited

initialize and reset values of gradien and Hessian

Definition at line 140 of file FumiliFCNBase.h.

140  {
141  fNumberOfParameters = npar;
142  fGradient = std::vector<double>(npar);
143  fHessian = std::vector<double>(static_cast<int>( 0.5*npar*(npar+1) ));
144  }

References ROOT::Minuit2::FumiliFCNBase::fGradient, ROOT::Minuit2::FumiliFCNBase::fHessian, and ROOT::Minuit2::FumiliFCNBase::fNumberOfParameters.

◆ ModelFunction()

const ParametricFunction* ROOT::Minuit2::FumiliChi2FCN::ModelFunction ( ) const
inline

Returns the model function used for the data.

Returns
Returns a pointer to the model function.

Definition at line 81 of file FumiliChi2FCN.h.

81 { return fModelFunction; }
const ParametricFunction * fModelFunction

References fModelFunction.

◆ operator()()

double ROOT::Minuit2::FumiliChi2FCN::operator() ( const std::vector< double > &  par) const
inlinevirtual

Calculates the sum of Elements squared, ie the chi-square. The user must implement in a class which inherits from FumiliChi2FCN the member function Elements() which will supply the Elements for the sum.

Parameters
parvector containing the Parameter values for the model function
Returns
The sum of Elements squared
See also
FumiliFCNBase::elements

Implements ROOT::Minuit2::FCNBase.

Definition at line 146 of file FumiliChi2FCN.h.

146  {
147 
148  double chiSquare = 0.0;
149  std::vector<double> vecElements = Elements(par);
150  unsigned int vecElementsSize = vecElements.size();
151 
152  for (unsigned int i = 0; i < vecElementsSize; ++i)
153  chiSquare += vecElements[i]*vecElements[i];
154 
155  return chiSquare;
156  }
virtual std::vector< double > Elements(const std::vector< double > &par) const =0

References Elements().

Here is the call graph for this function:

◆ SetErrorDef()

virtual void ROOT::Minuit2::FCNBase::SetErrorDef ( double  )
inlinevirtualinherited

add interface to set dynamically a new error definition Re-implement this function if needed.

Reimplemented in ROOT::Minuit2::FumiliFCNAdapter< Function >, and ROOT::Minuit2::FCNAdapter< Function >.

Definition at line 114 of file FCNBase.h.

114 {};

◆ SetFCNValue()

void ROOT::Minuit2::FumiliFCNBase::SetFCNValue ( double  value)
inlineprotectedinherited

Definition at line 147 of file FumiliFCNBase.h.

147 { fValue = value; }

References ROOT::Minuit2::FumiliFCNBase::fValue.

◆ SetModelFunction()

void ROOT::Minuit2::FumiliChi2FCN::SetModelFunction ( const ParametricFunction modelFCN)
inline

Sets the model function for the data (for example gaussian+linear for a peak)

Parameters
modelFunctiona reference to the model function.

Definition at line 69 of file FumiliChi2FCN.h.

69 { fModelFunction = &modelFCN; }

References fModelFunction.

Referenced by ROOT::Minuit2::FumiliStandardChi2FCN::FumiliStandardChi2FCN().

◆ Up()

virtual double ROOT::Minuit2::FumiliChi2FCN::Up ( ) const
inlinevirtual

!!!!!!!!!!!! to be commented

Implements ROOT::Minuit2::FCNBase.

Definition at line 166 of file FumiliChi2FCN.h.

166 { return 1.0; }

◆ Value()

virtual double ROOT::Minuit2::FumiliFCNBase::Value ( ) const
inlinevirtualinherited

Return cached Value of objective function estimated previously using the FumiliFCNBase::EvaluateAll method

Definition at line 106 of file FumiliFCNBase.h.

106 { return fValue; }

References ROOT::Minuit2::FumiliFCNBase::fValue.

Member Data Documentation

◆ fGradient

std::vector<double> ROOT::Minuit2::FumiliFCNBase::fGradient
privateinherited

◆ fHessian

std::vector<double> ROOT::Minuit2::FumiliFCNBase::fHessian
privateinherited

◆ fModelFunction

const ParametricFunction* ROOT::Minuit2::FumiliChi2FCN::fModelFunction = nullptr
private

Definition at line 171 of file FumiliChi2FCN.h.

Referenced by ModelFunction(), and SetModelFunction().

◆ fNumberOfParameters

unsigned int ROOT::Minuit2::FumiliFCNBase::fNumberOfParameters
privateinherited

◆ fValue

double ROOT::Minuit2::FumiliFCNBase::fValue
privateinherited

The documentation for this class was generated from the following file: