25 #include <queso/GslVector.h>
26 #include <queso/GslMatrix.h>
27 #include <queso/VectorSet.h>
28 #include <queso/VectorSpace.h>
29 #include <queso/GaussianLikelihoodFullCovarianceRandomCoefficient.h>
33 template<
class V,
class M>
36 const V & observations,
const M & covariance)
38 m_covariance(covariance)
40 if (covariance.numRowsLocal() != observations.sizeLocal()) {
41 queso_error_msg(
"Covariance matrix not same size as observation vector");
45 template<
class V,
class M>
50 template<
class V,
class M>
54 V modelOutput(this->m_observations, 0, 0);
55 V weightedMisfit(this->m_observations, 0, 0);
57 this->evaluateModel(domainVector, modelOutput);
60 modelOutput -= this->m_observations;
63 this->m_covariance.invertMultiply(modelOutput, weightedMisfit);
66 modelOutput *= weightedMisfit;
69 double norm2_squared = modelOutput.sumOfComponents();
72 double deter_cov = this->m_covariance.determinant();
74 deter_cov = std::sqrt(deter_cov);
79 double cov_coeff = domainVector[domainVector.sizeLocal()-1];
80 cov_coeff = std::pow(std::sqrt(cov_coeff), this->m_observations.sizeLocal());
82 return -0.5 * norm2_squared / cov_coeff - std::log(cov_coeff * deter_cov);
virtual ~GaussianLikelihoodFullCovarianceRandomCoefficient()
Destructor.
A class that represents a Gaussian likelihood with full covariance and random coefficient.
A templated class for handling sets.
GaussianLikelihoodFullCovarianceRandomCoefficient(const char *prefix, const VectorSet< V, M > &domainSet, const V &observations, const M &covariance)
Default constructor.
virtual double lnValue(const V &domainVector) const
Logarithm of the value of the scalar function.
Base class for canned Gaussian likelihoods.