queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
QUESO::InverseGammaJointPdf< V, M > Class Template Reference

A class for handling Inverse Gamma joint PDFs. More...

#include <InverseGammaJointPdf.h>

Inheritance diagram for QUESO::InverseGammaJointPdf< V, M >:
QUESO::BaseJointPdf< V, M > QUESO::BaseScalarFunction< V, M >

Public Member Functions

Constructor/Destructor methods
 InverseGammaJointPdf (const char *prefix, const VectorSet< V, M > &domainSet, const V &alpha, const V &beta)
 Constructor. More...
 
 ~InverseGammaJointPdf ()
 Destructor. More...
 
Math methods
double actualValue (const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
 Actual value of the Gamma PDF. More...
 
double lnValue (const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
 TODO: Logarithm of the value of the Gamma PDF. More...
 
virtual void distributionMean (V &meanVector) const
 Mean value of the underlying random variable. More...
 
virtual void distributionVariance (M &covMatrix) const
 Covariance matrix of the underlying random variable. More...
 
double computeLogOfNormalizationFactor (unsigned int numSamples, bool updateFactorInternally) const
 Computes the logarithm of the normalization factor. More...
 
- Public Member Functions inherited from QUESO::BaseJointPdf< V, M >
 BaseJointPdf (const char *prefix, const VectorSet< V, M > &domainSet)
 Default constructor. More...
 
virtual ~BaseJointPdf ()
 Destructor. More...
 
virtual void setNormalizationStyle (unsigned int value) const
 
void setLogOfNormalizationFactor (double value) const
 Sets a logarithmic value to be used in the normalization factor (stored in the protected attribute m_normalizationStyle.) More...
 
virtual void print (std::ostream &os) const
 Print method. Non-pure for backwards compatibility. More...
 
- Public Member Functions inherited from QUESO::BaseScalarFunction< V, M >
void setFiniteDifferenceStepSize (double fdStepSize)
 Sets the step size for finite differencing gradients. More...
 
void setFiniteDifferenceStepSize (unsigned int i, double fdStepSize)
 
 BaseScalarFunction (const char *prefix, const VectorSet< V, M > &domainSet)
 Default constructor. More...
 
virtual ~BaseScalarFunction ()
 Destructor. More...
 
const VectorSet< V, M > & domainSet () const
 Access to the protected attribute m_domainSet: domain set of the scalar function. More...
 
virtual double lnValue (const V &domainVector) const
 Returns the logarithm of the function at domainVector. More...
 
virtual double lnValue (const V &domainVector, V &gradVector) const
 Returns the logarithm of the function and its gradient at domainVector. More...
 
virtual double lnValue (const V &domainVector, V &gradVector, const V &domainDirection, V &hessianEffect) const
 

Protected Attributes

m_alpha
 
m_beta
 
- Protected Attributes inherited from QUESO::BaseJointPdf< V, M >
unsigned int m_normalizationStyle
 
double m_logOfNormalizationFactor
 
- Protected Attributes inherited from QUESO::BaseScalarFunction< V, M >
const BaseEnvironmentm_env
 
std::string m_prefix
 
const VectorSet< V, M > & m_domainSet
 Domain set of the scalar function. More...
 

Additional Inherited Members

- Protected Member Functions inherited from QUESO::BaseJointPdf< V, M >
double commonComputeLogOfNormalizationFactor (unsigned int numSamples, bool updateFactorInternally) const
 Common method (to the derived classes) to compute the logarithm of the normalization factor. More...
 

Detailed Description

template<class V = GslVector, class M = GslMatrix>
class QUESO::InverseGammaJointPdf< V, M >

A class for handling Inverse Gamma joint PDFs.

This class allows the mathematical definition of an Inverse Gamma Joint PDF.

Definition at line 50 of file InverseGammaJointPdf.h.

Constructor & Destructor Documentation

template<class V , class M >
QUESO::InverseGammaJointPdf< V, M >::InverseGammaJointPdf ( const char *  prefix,
const VectorSet< V, M > &  domainSet,
const V &  alpha,
const V &  beta 
)

Constructor.

Constructs a new object of the class, given a prefix, the domain set, and the parameters alpha and beta of the Inverse Gamma PDF.

Definition at line 33 of file InverseGammaJointPdf.C.

References QUESO::BaseEnvironment::displayVerbosity(), QUESO::BaseScalarFunction< V, M >::m_env, QUESO::BaseScalarFunction< V, M >::m_prefix, and QUESO::BaseEnvironment::subDisplayFile().

38  :
39  BaseJointPdf<V,M>(((std::string)(prefix)+"uni").c_str(),domainSet),
40  m_alpha(alpha),
41  m_beta (beta)
42 {
43  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
44  *m_env.subDisplayFile() << "Entering InverseGammaJointPdf<V,M>::constructor()"
45  << ": prefix = " << m_prefix
46  << std::endl;
47  }
48 
49  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
50  *m_env.subDisplayFile() << "Leaving InverseGammaJointPdf<V,M>::constructor()"
51  << ": prefix = " << m_prefix
52  << std::endl;
53  }
54 }
const VectorSet< V, M > & domainSet() const
Access to the protected attribute m_domainSet: domain set of the scalar function. ...
const BaseEnvironment & m_env
unsigned int displayVerbosity() const
Definition: Environment.C:450
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
template<class V , class M >
QUESO::InverseGammaJointPdf< V, M >::~InverseGammaJointPdf ( )

Destructor.

Definition at line 57 of file InverseGammaJointPdf.C.

58 {
59 }

Member Function Documentation

template<class V , class M >
double QUESO::InverseGammaJointPdf< V, M >::actualValue ( const V &  domainVector,
const V *  domainDirection,
V *  gradVector,
M *  hessianMatrix,
V *  hessianEffect 
) const
virtual

Actual value of the Gamma PDF.

This routine calls method lnValue() and returns the exponent of the returning value of such method.

Implements QUESO::BaseJointPdf< V, M >.

Definition at line 63 of file InverseGammaJointPdf.C.

References QUESO::queso_require_equal_to_msg.

69 {
70  queso_require_equal_to_msg(domainVector.sizeLocal(), this->m_domainSet.vectorSpace().dimLocal(), "invalid input");
71 
72  queso_require_msg(!(domainDirection || gradVector || hessianMatrix || hessianEffect), "incomplete code for gradVector, hessianMatrix and hessianEffect calculations");
73 
74  // No need to multiply by exp(m_logOfNormalizationFactor) because 'lnValue()' is called [PDF-07]
75  return exp(this->lnValue(domainVector,domainDirection,gradVector,hessianMatrix,hessianEffect));
76 }
double lnValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
TODO: Logarithm of the 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"))
const VectorSet< V, M > & m_domainSet
Domain set of the scalar function.
template<class V , class M >
double QUESO::InverseGammaJointPdf< V, M >::computeLogOfNormalizationFactor ( unsigned int  numSamples,
bool  updateFactorInternally 
) const
virtual

Computes the logarithm of the normalization factor.

This routine calls BaseJointPdf::commonComputeLogOfNormalizationFactor().

Implements QUESO::BaseJointPdf< V, M >.

Definition at line 135 of file InverseGammaJointPdf.C.

References QUESO::BaseJointPdf< V, M >::commonComputeLogOfNormalizationFactor().

136 {
137  double value = 0.;
138 
139  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
140  *m_env.subDisplayFile() << "Entering InverseGammaJointPdf<V,M>::computeLogOfNormalizationFactor()"
141  << std::endl;
142  }
143  value = BaseJointPdf<V,M>::commonComputeLogOfNormalizationFactor(numSamples, updateFactorInternally);
144  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
145  *m_env.subDisplayFile() << "Leaving InverseGammaJointPdf<V,M>::computeLogOfNormalizationFactor()"
146  << ", m_logOfNormalizationFactor = " << m_logOfNormalizationFactor
147  << std::endl;
148  }
149 
150  return value;
151 }
double m_logOfNormalizationFactor
Definition: JointPdf.h:122
double commonComputeLogOfNormalizationFactor(unsigned int numSamples, bool updateFactorInternally) const
Common method (to the derived classes) to compute the logarithm of the normalization factor...
Definition: JointPdf.C:115
const BaseEnvironment & m_env
unsigned int displayVerbosity() const
Definition: Environment.C:450
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
template<class V , class M >
void QUESO::InverseGammaJointPdf< V, M >::distributionMean ( V &  meanVector) const
virtual

Mean value of the underlying random variable.

Reimplemented from QUESO::BaseJointPdf< V, M >.

Definition at line 104 of file InverseGammaJointPdf.C.

105 {
106  queso_assert_equal_to(m_alpha.sizeLocal(), m_beta.sizeLocal());
107  queso_assert_equal_to(m_alpha.sizeLocal(), meanVector.sizeLocal());
108 
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);
112  }
113 }
template<class V , class M >
void QUESO::InverseGammaJointPdf< V, M >::distributionVariance ( M &  covMatrix) const
virtual

Covariance matrix of the underlying random variable.

Reimplemented from QUESO::BaseJointPdf< V, M >.

Definition at line 117 of file InverseGammaJointPdf.C.

118 {
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());
122 
123  covMatrix.zeroLower();
124  covMatrix.zeroUpper();
125 
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);
130  }
131 }
template<class V , class M >
double QUESO::InverseGammaJointPdf< V, M >::lnValue ( const V &  domainVector,
const V *  domainDirection,
V *  gradVector,
M *  hessianMatrix,
V *  hessianEffect 
) const
virtual

TODO: Logarithm of the value of the Gamma PDF.

Todo:
: implement me!

Reimplemented from QUESO::BaseScalarFunction< V, M >.

Definition at line 80 of file InverseGammaJointPdf.C.

86 {
87  queso_require_msg(!(domainDirection || gradVector || hessianMatrix || hessianEffect), "incomplete code for gradVector, hessianMatrix and hessianEffect calculations");
88 
89  double result = 0.;
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) {
94  // Code needs to be done yet
95  }
96  }
97  result += m_logOfNormalizationFactor; // [PDF-07]
98 
99  return result;
100 }
double m_logOfNormalizationFactor
Definition: JointPdf.h:122
unsigned int m_normalizationStyle
Definition: JointPdf.h:121

Member Data Documentation

template<class V = GslVector, class M = GslMatrix>
V QUESO::InverseGammaJointPdf< V, M >::m_alpha
protected

Definition at line 93 of file InverseGammaJointPdf.h.

template<class V = GslVector, class M = GslMatrix>
V QUESO::InverseGammaJointPdf< V, M >::m_beta
protected

Definition at line 94 of file InverseGammaJointPdf.h.


The documentation for this class was generated from the following files:

Generated on Tue Jun 5 2018 19:49:30 for queso-0.57.1 by  doxygen 1.8.5