#ifndef ROOT_Fit_PoissonLikelihoodFCN
#define ROOT_Fit_PoissonLikelihoodFCN
#ifndef ROOT_Math_FitMethodunction
#include "Math/FitMethodFunction.h"
#endif
#ifndef ROOT_Math_IParamFunction
#include "Math/IParamFunction.h"
#endif
#ifndef ROOT_Fit_BinData
#include "Fit/BinData.h"
#endif
#ifndef ROOT_Fit_FitUtil
#include "Fit/FitUtil.h"
#endif
namespace ROOT {
namespace Fit {
template<class FunType>
class PoissonLikelihoodFCN : public ::ROOT::Math::BasicFitMethodFunction<FunType> {
public:
typedef ::ROOT::Math::BasicFitMethodFunction<FunType> BaseObjFunction;
typedef typename BaseObjFunction::BaseFunction BaseFunction;
typedef ::ROOT::Math::IParamMultiFunction IModelFunction;
PoissonLikelihoodFCN (const BinData & data, IModelFunction & func) :
BaseObjFunction(func.NPar(), data.Size() ),
fData(data),
fFunc(func),
fNEffPoints(0),
fGrad ( std::vector<double> ( func.NPar() ) )
{ }
~PoissonLikelihoodFCN () {}
private:
PoissonLikelihoodFCN(const PoissonLikelihoodFCN &) {}
PoissonLikelihoodFCN & operator = (const PoissonLikelihoodFCN & rhs) { return *this; }
public:
BaseFunction * Clone() const { return new PoissonLikelihoodFCN(fData,fFunc); }
unsigned int NFitPoints() const { return fNEffPoints; }
double DataElement(const double * x, unsigned int i, double * g) const {
return FitUtil::EvaluatePoissonBinPdf(fFunc, fData, x, i, g);
}
virtual void Gradient(const double *x, double *g) const {
FitUtil::EvaluatePoissonLogLGradient(fFunc, fData, x, g );
}
virtual typename BaseObjFunction::Type_t Type() const { return BaseObjFunction::kLogLikelihood; }
virtual const BinData & Data() const { return fData; }
virtual const IModelFunction & ModelFunction() const { return fFunc; }
protected:
private:
double DoEval (const double * x) const {
this->UpdateNCalls();
return FitUtil::EvaluatePoissonLogL(fFunc, fData, x, fNEffPoints);
}
virtual double DoDerivative(const double * x, unsigned int icoord ) const {
Gradient(x, &fGrad[0]);
return fGrad[icoord];
}
const BinData & fData;
mutable IModelFunction & fFunc;
unsigned int fNDim;
unsigned int fNPoints;
mutable unsigned int fNEffPoints;
mutable unsigned int fNCalls;
mutable std::vector<double> fGrad;
};
typedef PoissonLikelihoodFCN<ROOT::Math::IMultiGenFunction> PoissonLLFunction;
typedef PoissonLikelihoodFCN<ROOT::Math::IMultiGradFunction> PoissonLLGradFunction;
}
}
#endif /* ROOT_Fit_PoissonLikelihoodFCN */
Last change: Fri Dec 12 12:11:39 2008
Last generated: 2008-12-12 12:11
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.