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

A templated (base) class for handling joint PDFs. More...

#include <JointPdf.h>

Inheritance diagram for QUESO::BaseJointPdf< V, M >:
QUESO::BaseScalarFunction< V, M > QUESO::BayesianJointPdf< QUESO::GslVector, QUESO::GslMatrix > QUESO::BayesianJointPdf< V, M > QUESO::BetaJointPdf< V, M > QUESO::ConcatenatedJointPdf< V, M > QUESO::GammaJointPdf< V, M > QUESO::GaussianJointPdf< V, M > QUESO::GenericJointPdf< V, M > QUESO::InverseGammaJointPdf< V, M > QUESO::InvLogitGaussianJointPdf< V, M > QUESO::JeffreysJointPdf< V, M > QUESO::LogNormalJointPdf< V, M > QUESO::PoweredJointPdf< V, M > QUESO::UniformJointPdf< V, M > QUESO::WignerJointPdf< V, M >

Public Member Functions

Constructor/Destructor methods
 BaseJointPdf (const char *prefix, const VectorSet< V, M > &domainSet)
 Default constructor. More...
 
virtual ~BaseJointPdf ()
 Destructor. More...
 
Mathematical methods
virtual double actualValue (const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const =0
 Actual value of the PDF (scalar function). More...
 
virtual void distributionMean (V &meanVector) const
 
virtual void distributionVariance (M &covMatrix) const
 
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 double computeLogOfNormalizationFactor (unsigned int numSamples, bool m_logOfNormalizationFactor) const =0
 Computes the logarithm of the normalization factor. See template specialization. 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 V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
 Logarithm of the value of the scalar function. Deprecated. 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 Member Functions

double commonComputeLogOfNormalizationFactor (unsigned int numSamples, bool updateFactorInternally) const
 Common method (to the derived classes) to compute the logarithm of the normalization factor. More...
 

Protected Attributes

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...
 

Detailed Description

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

A templated (base) class for handling joint PDFs.

This class allows the mathematical definition of a Joint PDF, which is a scalar function such as * \( \pi: B \subset R^n \rightarrow R \); ie a function of one or more variables that has always one-dimensional range. QUESO currently supports basic PDFs such as uniform and Gaussian and also more complex PDFs, such as the ones coming from a Bayesian analysis. They are implemented in the derived classes UniformJointPdf, GaussianJointPdf, and BayesianJointPdf, respectively. The posterior PDF may be represented within QUESO by GenericJointPdf.

Definition at line 55 of file JointPdf.h.

Constructor & Destructor Documentation

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

Default constructor.

Instantiates an object of the class, i.e. a scalar function, given a prefix and its domain.

Definition at line 33 of file JointPdf.C.

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

36  :
37  BaseScalarFunction<V,M>(((std::string)(prefix)+"pd_").c_str(), domainSet),
40 {
41  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
42  *m_env.subDisplayFile() << "Entering BaseJointPdf<V,M>::constructor() [3]"
43  << ": prefix = " << m_prefix
44  << std::endl;
45  }
46 
47  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
48  *m_env.subDisplayFile() << "Leaving BaseJointPdf<V,M>::constructor() [3]"
49  << ": prefix = " << m_prefix
50  << std::endl;
51  }
52 }
double m_logOfNormalizationFactor
Definition: JointPdf.h:122
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 m_normalizationStyle
Definition: JointPdf.h:121
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::BaseJointPdf< V, M >::~BaseJointPdf ( )
virtual

Destructor.

Definition at line 55 of file JointPdf.C.

56 {
57 }

Member Function Documentation

template<class V = GslVector, class M = GslMatrix>
virtual double QUESO::BaseJointPdf< V, M >::actualValue ( const V &  domainVector,
const V *  domainDirection,
V *  gradVector,
M *  hessianMatrix,
V *  hessianEffect 
) const
pure virtual
template<class V , class M >
double QUESO::BaseJointPdf< V, M >::commonComputeLogOfNormalizationFactor ( unsigned int  numSamples,
bool  updateFactorInternally 
) const
protected

Common method (to the derived classes) to compute the logarithm of the normalization factor.

The normalization factor is calculated by finding the max and min values of the domain set and then drawing numSamples samples from a uniform distribution varying from min to max. Such samples are averaged and the logarithmic value is assigned to protected attribute m_logOfNormalizationFactor if the parameter m_logOfNormalizationFactor is true.

Definition at line 115 of file JointPdf.C.

References QUESO::BoxSubset< V, M >::maxValues(), QUESO::BoxSubset< V, M >::minValues(), and QUESO::queso_isnan().

Referenced by QUESO::GenericJointPdf< V, M >::computeLogOfNormalizationFactor(), QUESO::UniformJointPdf< V, M >::computeLogOfNormalizationFactor(), QUESO::WignerJointPdf< V, M >::computeLogOfNormalizationFactor(), QUESO::BetaJointPdf< V, M >::computeLogOfNormalizationFactor(), QUESO::InverseGammaJointPdf< V, M >::computeLogOfNormalizationFactor(), QUESO::LogNormalJointPdf< V, M >::computeLogOfNormalizationFactor(), QUESO::JeffreysJointPdf< V, M >::computeLogOfNormalizationFactor(), QUESO::GaussianJointPdf< V, M >::computeLogOfNormalizationFactor(), QUESO::GammaJointPdf< V, M >::computeLogOfNormalizationFactor(), and QUESO::InvLogitGaussianJointPdf< V, M >::computeLogOfNormalizationFactor().

116 {
117  double value = 0.;
118 
119  double volume = m_domainSet.volume();
120  if ((queso_isnan(volume)) ||
121  (volume == -INFINITY ) ||
122  (volume == INFINITY ) ||
123  (volume <= 0. )) {
124  // Do nothing
125  }
126  else {
127  const BoxSubset<V,M>* boxSubset = dynamic_cast<const BoxSubset<V,M>* >(&m_domainSet);
128  if (boxSubset == NULL) {
129  // Do nothing
130  }
131  else {
132  V tmpVec(m_domainSet.vectorSpace().zeroVector());
133  double sum = 0.;
134  for (unsigned int i = 0; i < numSamples; ++i) {
135  tmpVec.cwSetUniform(boxSubset->minValues(),boxSubset->maxValues());
136  sum += this->actualValue(tmpVec,NULL,NULL,NULL,NULL);
137  }
138  double avgValue = sum/((double) numSamples);
139  value = -( log(avgValue) + log(volume) );
140  if (updateFactorInternally) {
142  }
143  }
144  }
145 
146  return value;
147 }
double m_logOfNormalizationFactor
Definition: JointPdf.h:122
bool queso_isnan(T arg)
Definition: math_macros.h:39
virtual double actualValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const =0
Actual value of the PDF (scalar function).
const VectorSet< V, M > & m_domainSet
Domain set of the scalar function.
template<class V, class M >
void QUESO::BaseJointPdf< V, M >::distributionMean ( V &  meanVector) const
virtual

Mean value of the underlying random variable. Not implemented in base class, but not pure virtual for backwards compatibility reasons.

Reimplemented in QUESO::InvLogitGaussianJointPdf< V, M >, QUESO::GammaJointPdf< V, M >, QUESO::GaussianJointPdf< V, M >, QUESO::ConcatenatedJointPdf< V, M >, QUESO::BayesianJointPdf< V, M >, QUESO::LogNormalJointPdf< V, M >, QUESO::JeffreysJointPdf< V, M >, QUESO::BetaJointPdf< V, M >, QUESO::InverseGammaJointPdf< V, M >, QUESO::WignerJointPdf< V, M >, and QUESO::UniformJointPdf< V, M >.

Definition at line 62 of file JointPdf.C.

63 {
64  queso_not_implemented();
65 }
template<class V , class M>
void QUESO::BaseJointPdf< V, M >::distributionVariance ( M &  covMatrix) const
virtual

Covariance matrix of the underlying random variable. Not implemented in base class, but not pure virtual for backwards compatibility reasons.

Reimplemented in QUESO::InvLogitGaussianJointPdf< V, M >, QUESO::GammaJointPdf< V, M >, QUESO::GaussianJointPdf< V, M >, QUESO::ConcatenatedJointPdf< V, M >, QUESO::BayesianJointPdf< V, M >, QUESO::LogNormalJointPdf< V, M >, QUESO::JeffreysJointPdf< V, M >, QUESO::BetaJointPdf< V, M >, QUESO::InverseGammaJointPdf< V, M >, QUESO::WignerJointPdf< V, M >, and QUESO::UniformJointPdf< V, M >.

Definition at line 70 of file JointPdf.C.

71 {
72  queso_not_implemented();
73 }
template<class V , class M >
void QUESO::BaseJointPdf< V, M >::print ( std::ostream &  os) const
virtual

Print method. Non-pure for backwards compatibility.

Reimplemented in QUESO::InvLogitGaussianJointPdf< V, M >, and QUESO::GaussianJointPdf< V, M >.

Definition at line 94 of file JointPdf.C.

95 {
96  // Print m_env?
97  // Print mean?
98  // Print var?
99 
100  os << "Start printing BaseJointPdf<V, M>" << std::endl;
101  os << "m_prefix:" << std::endl;
102  os << this->m_prefix << std::endl;
103  os << "m_domainSet:" << std::endl;
104  os << this->m_domainSet << std::endl;
105  os << "m_normalizationStyle:" << std::endl;
106  os << this->m_normalizationStyle << std::endl;
107  os << "m_logOfNormalizationFactor:" << std::endl;
108  os << this->m_logOfNormalizationFactor << std::endl;
109  os << "End printing BaseJointPdf<V, M>" << std::endl;
110 }
double m_logOfNormalizationFactor
Definition: JointPdf.h:122
const VectorSet< V, M > & m_domainSet
Domain set of the scalar function.
unsigned int m_normalizationStyle
Definition: JointPdf.h:121
template<class V , class M >
void QUESO::BaseJointPdf< V, M >::setLogOfNormalizationFactor ( double  value) const

Sets a logarithmic value to be used in the normalization factor (stored in the protected attribute m_normalizationStyle.)

Definition at line 86 of file JointPdf.C.

87 {
89  return;
90 }
double m_logOfNormalizationFactor
Definition: JointPdf.h:122
template<class V , class M >
void QUESO::BaseJointPdf< V, M >::setNormalizationStyle ( unsigned int  value) const
virtual

Sets a value to be used in the normalization style. Default value is zero.

The value is stored in m_normalizationStyle.

If the normalization style is zero, one should compute analytical normalization constants in lnValue and actualValue. It doesn't appear to be used in many of of the computeLogOfNormalizationFactor methods in derived classes.

Reimplemented in QUESO::ConcatenatedJointPdf< V, M >, QUESO::BayesianJointPdf< V, M >, QUESO::BayesianJointPdf< QUESO::GslVector, QUESO::GslMatrix >, and QUESO::PoweredJointPdf< V, M >.

Definition at line 78 of file JointPdf.C.

79 {
80  m_normalizationStyle = value;
81  return;
82 }
unsigned int m_normalizationStyle
Definition: JointPdf.h:121

Member Data Documentation

template<class V = GslVector, class M = GslMatrix>
double QUESO::BaseJointPdf< V, M >::m_logOfNormalizationFactor
mutableprotected

Definition at line 122 of file JointPdf.h.

template<class V = GslVector, class M = GslMatrix>
unsigned int QUESO::BaseJointPdf< V, M >::m_normalizationStyle
mutableprotected

Flag to decide which style of normalisation to use. The constructor sets this to zero in the initialisation list.

Definition at line 121 of file JointPdf.h.


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

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