25 #include <queso/InverseGammaJointPdf.h>
26 #include <queso/GslVector.h>
27 #include <queso/GslMatrix.h>
32 template<
class V,
class M>
39 BaseJointPdf<V,M>(((std::string)(prefix)+
"uni").c_str(),domainSet),
56 template<
class V,
class M>
61 template<
class V,
class M>
64 const V& domainVector,
65 const V* domainDirection,
68 V* hessianEffect)
const
72 queso_require_msg(!(domainDirection || gradVector || hessianMatrix || hessianEffect),
"incomplete code for gradVector, hessianMatrix and hessianEffect calculations");
75 return exp(this->lnValue(domainVector,domainDirection,gradVector,hessianMatrix,hessianEffect));
78 template<
class V,
class M>
81 const V& domainVector,
82 const V* domainDirection,
85 V* hessianEffect)
const
87 queso_require_msg(!(domainDirection || gradVector || hessianMatrix || hessianEffect),
"incomplete code for gradVector, hessianMatrix and hessianEffect calculations");
90 for (
unsigned int i = 0; i < domainVector.sizeLocal(); ++i) {
91 result -= (m_alpha[i]+1.)*log(domainVector[i]);
92 result -= m_beta[i]/domainVector[i];
93 if (m_normalizationStyle == 0) {
97 result += m_logOfNormalizationFactor;
102 template<
class V,
class M>
106 queso_assert_equal_to(m_alpha.sizeLocal(), m_beta.sizeLocal());
107 queso_assert_equal_to(m_alpha.sizeLocal(), meanVector.sizeLocal());
109 for (
unsigned int i = 0; i < m_alpha.sizeLocal(); ++i) {
110 queso_assert_greater(m_alpha[i], 1);
111 meanVector[i] = m_beta[i] / (m_alpha[i] - 1);
115 template<
class V,
class M>
119 queso_assert_equal_to(m_alpha.sizeLocal(), m_beta.sizeLocal());
120 queso_assert_equal_to(m_alpha.sizeLocal(), covMatrix.numCols());
121 queso_assert_equal_to (covMatrix.numCols(), covMatrix.numRowsGlobal());
123 covMatrix.zeroLower();
124 covMatrix.zeroUpper();
126 for (
unsigned int i = 0; i < m_alpha.sizeLocal(); ++i) {
127 queso_assert_greater(m_alpha[i], 2);
128 covMatrix(i,i) = m_beta[i]*m_beta[i] / (m_alpha[i] - 1) /
129 (m_alpha[i] - 1) / (m_alpha[i] - 2);
133 template<
class V,
class M>
139 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
140 *m_env.subDisplayFile() <<
"Entering InverseGammaJointPdf<V,M>::computeLogOfNormalizationFactor()"
144 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
145 *m_env.subDisplayFile() <<
"Leaving InverseGammaJointPdf<V,M>::computeLogOfNormalizationFactor()"
146 <<
", m_logOfNormalizationFactor = " << m_logOfNormalizationFactor
double actualValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Actual value of the Gamma PDF.
double lnValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
TODO: Logarithm of the value of the Gamma PDF.
virtual void distributionVariance(M &covMatrix) const
Covariance matrix of the underlying random variable.
~InverseGammaJointPdf()
Destructor.
A templated class for handling sets.
double computeLogOfNormalizationFactor(unsigned int numSamples, bool updateFactorInternally) const
Computes the logarithm of the normalization factor.
InverseGammaJointPdf(const char *prefix, const VectorSet< V, M > &domainSet, const V &alpha, const V &beta)
Constructor.
double commonComputeLogOfNormalizationFactor(unsigned int numSamples, bool updateFactorInternally) const
Common method (to the derived classes) to compute the logarithm of the normalization factor...
const BaseEnvironment & m_env
A class for handling Inverse Gamma joint PDFs.
A templated (base) class for handling joint PDFs.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int displayVerbosity() const
virtual void distributionMean(V &meanVector) const
Mean value of the underlying random variable.
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).