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>
54 const V * domainDirection, V * gradVector, M * hessianMatrix,
55 V * hessianEffect)
const
57 return std::exp(this->lnValue(domainVector, domainDirection, gradVector,
58 hessianMatrix, hessianEffect));
61 template<
class V,
class M>
64 const V * domainDirection, V * gradVector, M * hessianMatrix,
65 V * hessianEffect)
const
67 V modelOutput(this->m_observations, 0, 0);
69 this->evaluateModel(domainVector, domainDirection, modelOutput, gradVector,
70 hessianMatrix, hessianEffect);
72 modelOutput -= this->m_observations;
73 modelOutput *= modelOutput;
74 modelOutput /= this->m_covariance;
76 double norm2_squared = modelOutput.sumOfComponents();
78 return -0.5 * norm2_squared;
A class that represents a Gaussian likelihood with diagonal covariance matrix.
virtual double lnValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Logarithm of the value of the scalar function.
A templated class for handling sets.
virtual ~GaussianLikelihoodDiagonalCovariance()
Destructor.
virtual double actualValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Actual value of the scalar function.
#define queso_error_msg(msg)
Base class for canned Gaussian likelihoods.
GaussianLikelihoodDiagonalCovariance(const char *prefix, const VectorSet< V, M > &domainSet, const V &observations, const V &covariance)
Default constructor.