27 #include <queso/GslVector.h>
28 #include <queso/GslMatrix.h>
29 #include <queso/VectorSet.h>
30 #include <queso/GaussianLikelihoodDiagonalCovariance.h>
34 template<
class V,
class M>
37 const V & observations,
const V & covariance)
39 m_covariance(covariance)
41 if (covariance.sizeLocal() != observations.sizeLocal()) {
42 queso_error_msg(
"Covariance matrix not same size as observation vector");
46 template<
class V,
class M>
51 template<
class V,
class M>
55 V modelOutput(this->m_observations, 0, 0);
57 this->evaluateModel(domainVector, modelOutput);
59 modelOutput -= this->m_observations;
60 modelOutput *= modelOutput;
61 modelOutput /= this->m_covariance;
63 double norm2_squared = modelOutput.sumOfComponents();
65 return -0.5 * norm2_squared;
A templated class for handling sets.
GaussianLikelihoodDiagonalCovariance(const char *prefix, const VectorSet< V, M > &domainSet, const V &observations, const V &covariance)
Default constructor.
virtual ~GaussianLikelihoodDiagonalCovariance()
Destructor.
A class that represents a Gaussian likelihood with diagonal covariance matrix.
virtual double lnValue(const V &domainVector) const
Logarithm of the value of the scalar function.
Base class for canned Gaussian likelihoods.