BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType > Class Template Reference

Description

template<class DerivFunType, class ModelFunType = ROOT::Math::IParamMultiFunction>
class ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >

LogLikelihoodFCN class for likelihood fits

it is template to distinguish gradient and non-gradient case

Definition at line 41 of file LogLikelihoodFCN.h.

Inheritance diagram for ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >:
[legend]
Collaboration diagram for ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >:
[legend]

Public Types

typedef BasicFCN< DerivFunType, ModelFunType, UnBinDataBaseFCN
 
typedef BaseObjFunction::BaseFunction BaseFunction
 
typedef ::ROOT::Math::BasicFitMethodFunction< DerivFunType > BaseObjFunction
 
typedef ::ROOT::Math::IParamMultiFunctionTempl< TIModelFunction
 
typedef ModelFunType::BackendType T
 
typedef BaseObjFunction::Type_t Type_t
 

Public Member Functions

 LogLikelihoodFCN (const LogLikelihoodFCN &f)
 
 LogLikelihoodFCN (const std::shared_ptr< UnBinData > &data, const std::shared_ptr< IModelFunction > &func, int weight=0, bool extended=false, const ::ROOT::Fit::ExecutionPolicy &executionPolicy=::ROOT::Fit::ExecutionPolicy::kSerial)
 
 LogLikelihoodFCN (const UnBinData &data, const IModelFunction &func, int weight=0, bool extended=false, const ::ROOT::Fit::ExecutionPolicy &executionPolicy=::ROOT::Fit::ExecutionPolicy::kSerial)
 
virtual ~LogLikelihoodFCN ()
 
virtual BaseFunctionClone () const
 clone the function (need to return Base for Windows) More...
 
virtual double DataElement (const double *x, unsigned int i, double *g) const
 i-th likelihood contribution and its gradient More...
 
virtual void Gradient (const double *x, double *g) const
 
virtual unsigned int NFitPoints () const
 
LogLikelihoodFCNoperator= (const LogLikelihoodFCN &rhs)
 
virtual BaseObjFunction::Type_t Type () const
 get type of fit method function More...
 
void UseSumOfWeightSquare (bool on=true)
 

Private Member Functions

virtual double DoDerivative (const double *x, unsigned int icoord) const
 
virtual double DoEval (const double *x) const
 

Private Attributes

::ROOT::Fit::ExecutionPolicy fExecutionPolicy
 
std::vector< double > fGrad
 
bool fIsExtended
 
unsigned int fNEffPoints
 
int fWeight
 

Member Typedef Documentation

◆ BaseFCN

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
typedef BasicFCN<DerivFunType,ModelFunType,UnBinData> ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::BaseFCN

Definition at line 46 of file LogLikelihoodFCN.h.

◆ BaseFunction

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
typedef BaseObjFunction::BaseFunction ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::BaseFunction

Definition at line 49 of file LogLikelihoodFCN.h.

◆ BaseObjFunction

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
typedef ::ROOT::Math::BasicFitMethodFunction<DerivFunType> ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::BaseObjFunction

Definition at line 48 of file LogLikelihoodFCN.h.

◆ IModelFunction

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
typedef ::ROOT::Math::IParamMultiFunctionTempl<T> ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::IModelFunction

Definition at line 51 of file LogLikelihoodFCN.h.

◆ T

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
typedef ModelFunType::BackendType ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::T

Definition at line 45 of file LogLikelihoodFCN.h.

◆ Type_t

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
typedef BaseObjFunction::Type_t ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::Type_t

Definition at line 52 of file LogLikelihoodFCN.h.

Constructor & Destructor Documentation

◆ LogLikelihoodFCN() [1/3]

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::LogLikelihoodFCN ( const std::shared_ptr< UnBinData > &  data,
const std::shared_ptr< IModelFunction > &  func,
int  weight = 0,
bool  extended = false,
const ::ROOT::Fit::ExecutionPolicy &  executionPolicy = ::ROOT::Fit::ExecutionPolicy::kSerial 
)
inline

Constructor from unbin data set and model function (pdf)

Definition at line 58 of file LogLikelihoodFCN.h.

58  :
59  BaseFCN( data, func),
60  fIsExtended(extended),
61  fWeight(weight),
62  fNEffPoints(0),
63  fGrad ( std::vector<double> ( func->NPar() ) ),
64  fExecutionPolicy(executionPolicy)
65  {}
BasicFCN< DerivFunType, ModelFunType, UnBinData > BaseFCN
::ROOT::Fit::ExecutionPolicy fExecutionPolicy
std::vector< double > fGrad

Referenced by ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::Clone().

◆ LogLikelihoodFCN() [2/3]

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::LogLikelihoodFCN ( const UnBinData data,
const IModelFunction func,
int  weight = 0,
bool  extended = false,
const ::ROOT::Fit::ExecutionPolicy &  executionPolicy = ::ROOT::Fit::ExecutionPolicy::kSerial 
)
inline

Constructor from unbin data set and model function (pdf) for object managed by users

Definition at line 70 of file LogLikelihoodFCN.h.

70  :
71  BaseFCN(std::shared_ptr<UnBinData>(const_cast<UnBinData*>(&data), DummyDeleter<UnBinData>()), std::shared_ptr<IModelFunction>(dynamic_cast<IModelFunction*>(func.Clone() ) ) ),
72  fIsExtended(extended),
73  fWeight(weight),
74  fNEffPoints(0),
75  fGrad ( std::vector<double> ( func.NPar() ) ),
76  fExecutionPolicy(executionPolicy)
77  {}
::ROOT::Math::IParamMultiFunctionTempl< T > IModelFunction

◆ ~LogLikelihoodFCN()

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
virtual ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::~LogLikelihoodFCN ( )
inlinevirtual

Destructor (no operations)

Definition at line 82 of file LogLikelihoodFCN.h.

82 {}

◆ LogLikelihoodFCN() [3/3]

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::LogLikelihoodFCN ( const LogLikelihoodFCN< DerivFunType, ModelFunType > &  f)
inline

Copy constructor

Definition at line 87 of file LogLikelihoodFCN.h.

87  :
88  BaseFCN(f.DataPtr(), f.ModelFunctionPtr() ),
89  fIsExtended(f.fIsExtended ),
90  fWeight( f.fWeight ),
91  fNEffPoints( f.fNEffPoints ),
92  fGrad( f.fGrad),
93  fExecutionPolicy(f.fExecutionPolicy)
94  { }

Member Function Documentation

◆ Clone()

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
virtual BaseFunction* ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::Clone ( ) const
inlinevirtual

clone the function (need to return Base for Windows)

Definition at line 112 of file LogLikelihoodFCN.h.

112 { return new LogLikelihoodFCN(*this); }
LogLikelihoodFCN(const std::shared_ptr< UnBinData > &data, const std::shared_ptr< IModelFunction > &func, int weight=0, bool extended=false, const ::ROOT::Fit::ExecutionPolicy &executionPolicy=::ROOT::Fit::ExecutionPolicy::kSerial)

References ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::LogLikelihoodFCN().

Here is the call graph for this function:

◆ DataElement()

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
virtual double ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::DataElement ( const double *  x,
unsigned int  i,
double *  g 
) const
inlinevirtual

i-th likelihood contribution and its gradient

Definition at line 121 of file LogLikelihoodFCN.h.

121  {
122  if (i==0) this->UpdateNCalls();
123  return FitUtil::EvaluatePdf(BaseFCN::ModelFunction(), BaseFCN::Data(), x, i, g);
124  }
double EvaluatePdf(const IModelFunction &func, const UnBinData &data, const double *x, unsigned int ipoint, double *g=0)

References ROOT::Fit::FitUtil::EvaluatePdf().

Here is the call graph for this function:

◆ DoDerivative()

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
virtual double ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::DoDerivative ( const double *  x,
unsigned int  icoord 
) const
inlineprivatevirtual

Definition at line 161 of file LogLikelihoodFCN.h.

161  {
162  Gradient(x, &fGrad[0]);
163  return fGrad[icoord];
164  }
virtual void Gradient(const double *x, double *g) const

References ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::fGrad, and ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::Gradient().

Here is the call graph for this function:

◆ DoEval()

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
virtual double ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::DoEval ( const double *  x) const
inlineprivatevirtual

Evaluation of the function (required by interface)

Definition at line 155 of file LogLikelihoodFCN.h.

155  {
156  this->UpdateNCalls();
157  return FitUtil::Evaluate<T>::EvalLogL(BaseFCN::ModelFunction(), BaseFCN::Data(), x, fWeight, fIsExtended, fNEffPoints, fExecutionPolicy);
158  }
static double EvalLogL(const IModelFunctionTempl< double > &func, const UnBinData &data, const double *p, int iWeight, bool extended, unsigned int &nPoints, ROOT::Fit::ExecutionPolicy executionPolicy, unsigned nChunks=0)
Definition: FitUtil.h:1461

References ROOT::Fit::FitUtil::Evaluate< T >::EvalLogL(), ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::fExecutionPolicy, ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::fIsExtended, ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::fNEffPoints, and ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::fWeight.

Here is the call graph for this function:

◆ Gradient()

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
virtual void ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::Gradient ( const double *  x,
double *  g 
) const
inlinevirtual

Definition at line 127 of file LogLikelihoodFCN.h.

127  {
128  // evaluate the chi2 gradient
129  FitUtil::Evaluate<typename BaseFCN::T>::EvalLogLGradient(BaseFCN::ModelFunction(), BaseFCN::Data(), x, g,
131  }
static void EvalLogLGradient(const IModelFunctionTempl< double > &func, const UnBinData &data, const double *p, double *g, unsigned int &nPoints, ROOT::Fit::ExecutionPolicy executionPolicy=ROOT::Fit::ExecutionPolicy::kSerial, unsigned nChunks=0)
Definition: FitUtil.h:1506

References ROOT::Fit::FitUtil::Evaluate< T >::EvalLogLGradient(), ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::fExecutionPolicy, and ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::fNEffPoints.

Referenced by ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::DoDerivative().

Here is the call graph for this function:

◆ NFitPoints()

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
virtual unsigned int ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::NFitPoints ( ) const
inlinevirtual

◆ operator=()

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
LogLikelihoodFCN& ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::operator= ( const LogLikelihoodFCN< DerivFunType, ModelFunType > &  rhs)
inline

Assignment operator

Definition at line 100 of file LogLikelihoodFCN.h.

100  {
101  SetData(rhs.DataPtr() );
102  SetModelFunction(rhs.ModelFunctionPtr() );
103  fNEffPoints = rhs.fNEffPoints;
104  fGrad = rhs.fGrad;
105  fIsExtended = rhs.fIsExtended;
106  fWeight = rhs.fWeight;
107  fExecutionPolicy = rhs.fExecutionPolicy;
108  }

References ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::fExecutionPolicy, ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::fGrad, ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::fIsExtended, ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::fNEffPoints, and ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::fWeight.

◆ Type()

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
virtual BaseObjFunction::Type_t ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::Type ( ) const
inlinevirtual

◆ UseSumOfWeightSquare()

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
void ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::UseSumOfWeightSquare ( bool  on = true)
inline

Definition at line 139 of file LogLikelihoodFCN.h.

139  {
140  if (fWeight == 0) return; // do nothing if it was not weighted
141  if (on) fWeight = 2;
142  else fWeight = 1;
143  }

References ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::fWeight.

Member Data Documentation

◆ fExecutionPolicy

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
::ROOT::Fit::ExecutionPolicy ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::fExecutionPolicy
private

◆ fGrad

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
std::vector<double> ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::fGrad
mutableprivate

◆ fIsExtended

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
bool ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::fIsExtended
private

◆ fNEffPoints

◆ fWeight

template<class DerivFunType , class ModelFunType = ROOT::Math::IParamMultiFunction>
int ROOT::Fit::LogLikelihoodFCN< DerivFunType, ModelFunType >::fWeight
private

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