queso-0.56.1
Protected Member Functions | Protected Attributes | List of all members
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 >:
Inheritance graph
[legend]
Collaboration diagram for QUESO::BaseJointPdf< V, M >:
Collaboration graph
[legend]

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 double lnValue (const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const =0
 Logarithm of the value of the 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 >
 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...
 

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 }
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
unsigned int m_normalizationStyle
Definition: JointPdf.h:124
unsigned int displayVerbosity() const
Definition: Environment.C:449
double m_logOfNormalizationFactor
Definition: JointPdf.h:125
const BaseEnvironment & m_env
const VectorSet< V, M > & domainSet() const
Access to the protected attribute m_domainSet: domain set of the scalar function. ...
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 }
bool queso_isnan(T arg)
Definition: math_macros.h:39
const VectorSet< V, M > & m_domainSet
Domain set of the scalar function.
double m_logOfNormalizationFactor
Definition: JointPdf.h:125
virtual double actualValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const =0
Actual value of the PDF (scalar function).
template<class V = GslVector, class M = GslMatrix>
virtual double QUESO::BaseJointPdf< V, M >::computeLogOfNormalizationFactor ( unsigned int  numSamples,
bool  m_logOfNormalizationFactor 
) const
pure virtual
template<class V, class M >
void QUESO::BaseJointPdf< V, M >::distributionMean ( V &  meanVector) const
virtual
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.

References queso_not_implemented.

71 {
73 }
#define queso_not_implemented()
Definition: asserts.h:56
template<class V = GslVector, class M = GslMatrix>
virtual double QUESO::BaseJointPdf< V, M >::lnValue ( const V &  domainVector,
const V *  domainDirection,
V *  gradVector,
M *  hessianMatrix,
V *  hessianEffect 
) const
pure virtual
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 }
const VectorSet< V, M > & m_domainSet
Domain set of the scalar function.
unsigned int m_normalizationStyle
Definition: JointPdf.h:124
double m_logOfNormalizationFactor
Definition: JointPdf.h:125
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:125
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 >, QUESO::BayesianJointPdf< P_V, P_M >, 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:124

Member Data Documentation

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

Definition at line 125 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 124 of file JointPdf.h.


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

Generated on Thu Dec 15 2016 13:23:15 for queso-0.56.1 by  doxygen 1.8.5