[root] / trunk / math / mathcore / inc / Fit / LogLikelihoodFCN.h Repository:
ViewVC logotype

Diff of /trunk/math/mathcore/inc/Fit/LogLikelihoodFCN.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 25485, Mon Sep 22 07:52:52 2008 UTC revision 25486, Mon Sep 22 12:43:03 2008 UTC
# Line 66  Line 66 
66        Constructor from unbin data set and model function (pdf)        Constructor from unbin data set and model function (pdf)
67     */     */
68     LogLikelihoodFCN (const UnBinData & data, IModelFunction & func) :     LogLikelihoodFCN (const UnBinData & data, IModelFunction & func) :
69          BaseObjFunction(func.NPar(), data.Size() ),
70        fData(data),        fData(data),
71        fFunc(func),        fFunc(func),
       fNDim(func.NPar() ),  
       fNPoints(data.Size()),  
72        fNEffPoints(0),        fNEffPoints(0),
       fNCalls(0),  
73        fGrad ( std::vector<double> ( func.NPar() ) )        fGrad ( std::vector<double> ( func.NPar() ) )
74     {}     {}
75    
# Line 101  Line 99 
99     /// clone the function (need to return Base for Windows)     /// clone the function (need to return Base for Windows)
100     BaseFunction * Clone() const { return  new LogLikelihoodFCN(fData,fFunc); }     BaseFunction * Clone() const { return  new LogLikelihoodFCN(fData,fFunc); }
101    
    unsigned int NDim() const { return fNDim; }  
102    
103     //using BaseObjFunction::operator();     //using BaseObjFunction::operator();
104    
    // count number of function calls  
    unsigned int NCalls() const { return fNCalls; }  
   
    // size of the data  
    unsigned int NPoints() const { return fNPoints; }  
   
105     // effective points used in the fit     // effective points used in the fit
106     unsigned int NFitPoints() const { return fNEffPoints; }     unsigned int NFitPoints() const { return fNEffPoints; }
107    
    void ResetNCalls() { fNCalls = 0; }  
   
108     /// i-th likelihood contribution and its gradient     /// i-th likelihood contribution and its gradient
109     double DataElement(const double * x, unsigned int i, double * g) const {     double DataElement(const double * x, unsigned int i, double * g) const {
110        return FitUtil::EvaluatePdf(fFunc, fData, x, i, g);        return FitUtil::EvaluatePdf(fFunc, fData, x, i, g);
# Line 131  Line 120 
120     /// get type of fit method function     /// get type of fit method function
121     virtual  typename BaseObjFunction::Type GetType() const { return BaseObjFunction::kLogLikelihood; }     virtual  typename BaseObjFunction::Type GetType() const { return BaseObjFunction::kLogLikelihood; }
122    
123       /// access to const reference to the data
124       virtual const UnBinData & Data() const { return fData; }
125    
126       /// access to const reference to the model function
127       virtual const IModelFunction & ModelFunction() const { return fFunc; }
128    
129  protected:  protected:
130    
# Line 141  Line 135 
135        Evaluation of the  function (required by interface)        Evaluation of the  function (required by interface)
136      */      */
137     double DoEval (const double * x) const {     double DoEval (const double * x) const {
138        fNCalls++;        this->UpdateNCalls();
139  #ifdef PARALLEL  #ifdef PARALLEL
140        return FitUtilParallel::EvaluateLogL(fFunc, fData, x, fNEffPoints);        return FitUtilParallel::EvaluateLogL(fFunc, fData, x, fNEffPoints);
141  #else  #else
# Line 161  Line 155 
155     const UnBinData & fData;     const UnBinData & fData;
156     mutable IModelFunction & fFunc;     mutable IModelFunction & fFunc;
157    
    unsigned int fNDim;  
    unsigned int fNPoints;   // size of the data  
158     mutable unsigned int fNEffPoints;  // number of effective points used in the fit     mutable unsigned int fNEffPoints;  // number of effective points used in the fit
    mutable unsigned int fNCalls;  
159    
160     mutable std::vector<double> fGrad; // for derivatives     mutable std::vector<double> fGrad; // for derivatives
161    

Legend:
Removed from v.25485  
changed lines
  Added in v.25486

Subversion Admin
ViewVC Help
Powered by ViewVC 1.0.9