queso-0.53.0
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 setNormalizationStyle (unsigned int value) const
 Sets a value to be used in the normalization style (stored in the protected attribute m_normalizationStyle.) More...
 
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...
 
- 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 56 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 }
unsigned int displayVerbosity() const
Definition: Environment.C:396
unsigned int m_normalizationStyle
Definition: JointPdf.h:99
double m_logOfNormalizationFactor
Definition: JointPdf.h:100
const BaseEnvironment & m_env
const VectorSet< V, M > & domainSet() const
Access to the protected attribute m_domainSet: domain set of the scalar function. ...
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
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 77 of file JointPdf.C.

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

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::JeffreysJointPdf< V, M >::computeLogOfNormalizationFactor(), QUESO::LogNormalJointPdf< V, M >::computeLogOfNormalizationFactor(), QUESO::GammaJointPdf< V, M >::computeLogOfNormalizationFactor(), QUESO::GaussianJointPdf< V, M >::computeLogOfNormalizationFactor(), and QUESO::InvLogitGaussianJointPdf< V, M >::computeLogOfNormalizationFactor().

78 {
79  double value = 0.;
80 
81  double volume = m_domainSet.volume();
82  if (((boost::math::isnan)(volume)) ||
83  (volume == -INFINITY ) ||
84  (volume == INFINITY ) ||
85  (volume <= 0. )) {
86  // Do nothing
87  }
88  else {
89  const BoxSubset<V,M>* boxSubset = dynamic_cast<const BoxSubset<V,M>* >(&m_domainSet);
90  if (boxSubset == NULL) {
91  // Do nothing
92  }
93  else {
94  V tmpVec(m_domainSet.vectorSpace().zeroVector());
95  double sum = 0.;
96  for (unsigned int i = 0; i < numSamples; ++i) {
97  tmpVec.cwSetUniform(boxSubset->minValues(),boxSubset->maxValues());
98  sum += this->actualValue(tmpVec,NULL,NULL,NULL,NULL);
99  }
100  double avgValue = sum/((double) numSamples);
101  value = -( log(avgValue) + log(volume) );
102  if (updateFactorInternally) {
104  }
105  }
106  }
107 
108  return value;
109 }
double m_logOfNormalizationFactor
Definition: JointPdf.h:100
const VectorSet< V, M > & m_domainSet
Domain set of the scalar function.
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 = 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 >::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 69 of file JointPdf.C.

70 {
72  return;
73 }
double m_logOfNormalizationFactor
Definition: JointPdf.h:100
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 (stored in the protected attribute m_normalizationStyle.)

Reimplemented in QUESO::ConcatenatedJointPdf< V, M >, QUESO::BayesianJointPdf< V, M >, QUESO::BayesianJointPdf< P_V, P_M >, and QUESO::PoweredJointPdf< V, M >.

Definition at line 61 of file JointPdf.C.

62 {
63  m_normalizationStyle = value;
64  return;
65 }
unsigned int m_normalizationStyle
Definition: JointPdf.h:99

Member Data Documentation

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

Definition at line 100 of file JointPdf.h.

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

Definition at line 99 of file JointPdf.h.


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

Generated on Thu Jun 11 2015 13:52:35 for queso-0.53.0 by  doxygen 1.8.5