25 #include <queso/GammaJointPdf.h>
26 #include <queso/GslVector.h>
27 #include <queso/GslMatrix.h>
28 #include <queso/BasicPdfsBase.h>
33 template<
class V,
class M>
40 BaseJointPdf<V,M>(((std::string)(prefix)+
"uni").c_str(),domainSet),
57 template<
class V,
class M>
62 template<
class V,
class M>
65 const V& domainVector,
66 const V* domainDirection,
69 V* hessianEffect)
const
73 queso_require_msg(!(domainDirection || gradVector || hessianMatrix || hessianEffect),
"incomplete code for gradVector, hessianMatrix and hessianEffect calculations");
76 return exp(this->lnValue(domainVector,domainDirection,gradVector,hessianMatrix,hessianEffect));
79 template<
class V,
class M>
82 const V& domainVector,
83 const V* domainDirection,
86 V* hessianEffect)
const
88 queso_require_msg(!(domainDirection || gradVector || hessianMatrix || hessianEffect),
"incomplete code for gradVector, hessianMatrix and hessianEffect calculations");
92 for (
unsigned int i = 0; i < domainVector.sizeLocal(); ++i) {
93 if (m_normalizationStyle == 0) {
94 aux = log(m_env.basicPdfs()->gammaPdfActualValue(domainVector[i],m_a[i],m_b[i]));
97 aux = (m_a[i]-1.)*log(domainVector[i]) - domainVector[i]/m_b[i];
99 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
100 *m_env.subDisplayFile() <<
"In GammaJointPdf<V,M>::lnValue()"
101 <<
", m_normalizationStyle = " << m_normalizationStyle
102 <<
": domainVector[" << i <<
"] = " << domainVector[i]
103 <<
", m_a[" << i <<
"] = " << m_a[i]
104 <<
", m_b[" << i <<
"] = " << m_b[i]
105 <<
", log(pdf)= " << aux
110 result += m_logOfNormalizationFactor;
115 template<
class V,
class M>
119 queso_assert_equal_to(m_a.sizeLocal(), m_b.sizeLocal());
120 queso_assert_equal_to(m_a.sizeLocal(), meanVector.sizeLocal());
122 for (
unsigned int i = 0; i < m_a.sizeLocal(); ++i) {
123 meanVector[i] = m_a[i] * m_b[i];
127 template<
class V,
class M>
131 queso_assert_equal_to(m_a.sizeLocal(), m_b.sizeLocal());
132 queso_assert_equal_to(m_a.sizeLocal(), covMatrix.numRowsGlobal());
133 queso_assert_equal_to(covMatrix.numCols(), covMatrix.numRowsGlobal());
135 covMatrix.zeroLower();
136 covMatrix.zeroUpper();
138 for (
unsigned int i = 0; i < m_a.sizeLocal(); ++i) {
139 covMatrix(i,i) = m_a[i] * m_b[i] * m_b[i];
143 template<
class V,
class M>
149 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
150 *m_env.subDisplayFile() <<
"Entering GammaJointPdf<V,M>::computeLogOfNormalizationFactor()"
154 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
155 *m_env.subDisplayFile() <<
"Leaving GammaJointPdf<V,M>::computeLogOfNormalizationFactor()"
156 <<
", m_logOfNormalizationFactor = " << m_logOfNormalizationFactor
A class for handling Gamma joint PDFs.
virtual void distributionMean(V &meanVector) const
Mean value of the underlying random variable.
GammaJointPdf(const char *prefix, const VectorSet< V, M > &domainSet, const V &a, const V &b)
double lnValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Logarithm of the value of the Gamma PDF.
const BaseEnvironment & m_env
A templated (base) class for handling joint PDFs.
~GammaJointPdf()
Destructor.
double computeLogOfNormalizationFactor(unsigned int numSamples, bool updateFactorInternally) const
Computes the logarithm of the normalization factor.
A templated class for handling sets.
double commonComputeLogOfNormalizationFactor(unsigned int numSamples, bool updateFactorInternally) const
Common method (to the derived classes) to compute the logarithm of the normalization factor...
virtual void distributionVariance(M &covMatrix) const
Covariance matrix of the underlying random variable.
double actualValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Actual value of the Gamma PDF.
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"))
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
unsigned int displayVerbosity() const