CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
LikelihoodFunctional.cc
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id: LikelihoodFunctional.cc,v 1.4 2003/10/10 17:40:39 garren Exp $
3#include "CLHEP/GenericFunctions/LikelihoodFunctional.hh"
4#include "CLHEP/GenericFunctions/Argument.hh"
5#include "CLHEP/GenericFunctions/AbsFunction.hh"
6#include <iostream>
7#include <sstream>
8#include <stdexcept>
9#include <cmath> // for log()
10#include <vector>
11
12namespace Genfun {
14_aList(aList)
15{}
16
18}
19
20double LikelihoodFunctional::operator [] (const AbsFunction & function) const {
21 double logLikelihood(0);
22 for (unsigned int i=0; i<_aList.size();i++) {
23 Argument a = _aList[i];
24 double f = function(a);
25 if (f<=0.0) {
26 std::ostringstream stream;
27 stream << "Negative likelihood arg[" << i << "]=" << a;
28 throw std::runtime_error(stream.str());
29 }
30 logLikelihood -= log(f);
31 }
32 return 2.0*logLikelihood;
33}
34} // namespace Genfun
LikelihoodFunctional(const ArgumentList &aList)
virtual double operator[](const AbsFunction &function) const
void f(void g())
Definition: excDblThrow.cc:38
Definition: Abs.hh:14
std::vector< Argument > ArgumentList
Definition: ArgumentList.hh:7