CLHEP VERSION Reference Documentation
CLHEP Home Page
CLHEP Documentation
CLHEP Bug Reports
Main Page
Namespaces
Classes
Files
File List
File Members
GenericFunctions
src
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
11
namespace
Genfun {
12
LikelihoodFunctional::LikelihoodFunctional
(
const
ArgumentList
& aList):
13
_aList(aList)
14
{}
15
16
LikelihoodFunctional::~LikelihoodFunctional
() {
17
}
18
19
double
LikelihoodFunctional::operator []
(
const
AbsFunction
&
function
)
const
{
20
double
logLikelihood(0);
21
for
(
unsigned
int
i=0; i<_aList.size();i++) {
22
Argument
a
= _aList[i];
23
double
f
=
function
(
a
);
24
if
(f<=0.0) {
25
std::ostringstream stream;
26
stream <<
"Negative likelihood arg["
<< i <<
"]="
<<
a
;
27
throw
std::runtime_error(stream.str());
28
}
29
logLikelihood -= log(f);
30
}
31
return
2.0*logLikelihood;
32
}
33
}
// namespace Genfun
Generated on Mon May 6 2013 04:04:10 for CLHEP by
1.8.1.2