CLHEP 2.0.4.7 Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 // -*- C++ -*- 00002 // $Id: LikelihoodFunctional.cc,v 1.4 2003/10/10 17:40:39 garren Exp $ 00003 #include "CLHEP/GenericFunctions/LikelihoodFunctional.hh" 00004 #include "CLHEP/GenericFunctions/Argument.hh" 00005 #include "CLHEP/GenericFunctions/AbsFunction.hh" 00006 #include <iostream> 00007 #include <cmath> // for log() 00008 00009 namespace Genfun { 00010 LikelihoodFunctional::LikelihoodFunctional(const ArgumentList & aList): 00011 _aList(aList) 00012 {} 00013 00014 LikelihoodFunctional::~LikelihoodFunctional() { 00015 } 00016 00017 double LikelihoodFunctional::operator [] (const AbsFunction & function) const { 00018 double logLikelihood(0); 00019 for (unsigned int i=0; i<_aList.size();i++) { 00020 Argument a = _aList[i]; 00021 double f = function(a); 00022 if (f<0) 00023 std::cerr 00024 << "Warning.. negative likelihood arg[" << i << "]=" << a 00025 << std::endl; 00026 logLikelihood -= log(f); 00027 } 00028 return 2.0*logLikelihood; 00029 } 00030 } // namespace Genfun