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

A class for handling jeffreys joint PDFs. More...

#include <JeffreysJointPdf.h>

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

Public Member Functions

Constructor/Destructor methods
 JeffreysJointPdf (const char *prefix, const VectorSet< V, M > &domainSet)
 Constructor. More...
 
 ~JeffreysJointPdf ()
 Destructor. More...
 
Math methods
double actualValue (const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
 Actual value of the jeffreys PDF. More...
 
double lnValue (const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
 Logarithm of the value of the jeffreys PDF. More...
 
virtual void distributionMean (V &meanVector) const
 
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
 

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

Detailed Description

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

A class for handling jeffreys joint PDFs.

This class allows the mathematical definition of a Jeffreys Joint PDF.

Definition at line 46 of file JeffreysJointPdf.h.

Constructor & Destructor Documentation

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

Constructor.

Constructs a new object of the class, given a prefix and the domain set of the jeffreys PDF.

Definition at line 33 of file JeffreysJointPdf.C.

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

36  :
37  BaseJointPdf<V,M>(((std::string)(prefix)+"jef").c_str(),
38  domainSet)
39 {
40  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
41  *m_env.subDisplayFile() << "Entering JeffreysJointPdf<V,M>::constructor()"
42  << ": prefix = " << m_prefix
43  << std::endl;
44  }
45 
46  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
47  *m_env.subDisplayFile() << "Leaving JeffreysJointPdf<V,M>::constructor()"
48  << ": prefix = " << m_prefix
49  << std::endl;
50  }
51 }
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::JeffreysJointPdf< V, M >::~JeffreysJointPdf ( )

Destructor.

Definition at line 54 of file JeffreysJointPdf.C.

55 {
56 }

Member Function Documentation

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

Actual value of the jeffreys PDF.

If the domain of the PDF is well defined (neither negative nor infinite), then the actual value is given by 1.0 / (domainVector[0] * ... * domainVector[n-1]), otherwise the actual value is 0.0

Implements QUESO::BaseJointPdf< V, M >.

Definition at line 60 of file JeffreysJointPdf.C.

66 {
67  if (domainVector.sizeLocal() != this->m_domainSet.vectorSpace().dimLocal()) {
68  queso_error_msg("There is an invalid input while computing JeffreysJointPdf<V,M>::actualValue()");
69  }
70 
71  if (gradVector ) *gradVector = m_domainSet.vectorSpace().zeroVector();
72  if (hessianMatrix) *hessianMatrix *= 0.;
73  if (hessianEffect) *hessianEffect = m_domainSet.vectorSpace().zeroVector();
74 
75  if (domainDirection) {}; // just to remove compiler warning
76 
77  double pdf = 1.0;
78  for (unsigned int i = 0; i < domainVector.sizeLocal(); ++i){
79  if (domainVector[i] < 0.0 ) {
80  queso_error_msg("The domain for Jeffreys prior should be greater than zero.");
81  }
82  else if ((domainVector[i] == -INFINITY ) ||
83  (domainVector[i] == INFINITY ) ||
84  (m_normalizationStyle != 0 )) {//TODO: R: not sure what this is doing?
85  pdf = 0.0;
86  }
87  else {
88  pdf = pdf * (1.0 / domainVector[i]);
89  }
90  }
91  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
92  *m_env.subDisplayFile() << " return pdf " << std::endl;
93  }
94  return pdf; // No need to multiply by exp(m_logOfNormalizationFactor) [PDF-04]
95 }
const BaseEnvironment & m_env
const VectorSet< V, M > & m_domainSet
Domain set of the scalar function.
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 >
double QUESO::JeffreysJointPdf< 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 161 of file JeffreysJointPdf.C.

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

162 {
163  double value = 0.;
164 
165  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
166  *m_env.subDisplayFile() << "Entering JeffreysJointPdf<V,M>::computeLogOfNormalizationFactor()"
167  << std::endl;
168  }
169  value = BaseJointPdf<V,M>::commonComputeLogOfNormalizationFactor(numSamples, updateFactorInternally);
170  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
171  *m_env.subDisplayFile() << "Leaving JeffreysJointPdf<V,M>::computeLogOfNormalizationFactor()"
172  << ", m_logOfNormalizationFactor = " << m_logOfNormalizationFactor
173  << std::endl;
174  }
175 
176  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
177  *m_env.subDisplayFile() << " return normalization factor " << std::endl;
178  }
179  return value;
180 }
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::JeffreysJointPdf< V, M >::distributionMean ( V &  meanVector) const
virtual

Mean value of the underlying random variable. This may make no sense for the Jeffrey's prior.

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

Definition at line 140 of file JeffreysJointPdf.C.

141 {
142  // FIXME: This is an improper prior; the "mean" makes little sense.
143  // At least we can return something within the domain set.
144  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
145  *m_env.subDisplayFile() << "Warning: JeffreysJointPdf<V,M>::distributionMean() makes little sense"
146  << std::endl;
147  }
148  m_domainSet.centroid(meanVector);
149 }
const BaseEnvironment & m_env
const VectorSet< V, M > & m_domainSet
Domain set of the scalar function.
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::JeffreysJointPdf< V, M >::distributionVariance ( M &  covMatrix) const
virtual

Covariance matrix of the underlying random variable.

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

Definition at line 153 of file JeffreysJointPdf.C.

154 {
155  // There's no way this is anything like well-defined
156  queso_not_implemented();
157 }
template<class V , class M >
double QUESO::JeffreysJointPdf< V, M >::lnValue ( const V &  domainVector,
const V *  domainDirection,
V *  gradVector,
M *  hessianMatrix,
V *  hessianEffect 
) const
virtual

Logarithm of the value of the jeffreys PDF.

Analogous to the actualValue routine, except that the logarithm of the calculated value is returned.

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

Definition at line 101 of file JeffreysJointPdf.C.

107 {
108  if (gradVector ) *gradVector = m_domainSet.vectorSpace().zeroVector();
109  if (hessianMatrix) *hessianMatrix *= 0.0;
110  if (hessianEffect) *hessianEffect = m_domainSet.vectorSpace().zeroVector();
111 
112  if (domainVector[0]) {}; // just to remove compiler warning
113  if (domainDirection) {}; // just to remove compiler warning
114 
115  double pdf = 1.0;
116  double result = 0.;
117  for (unsigned int i = 0; i < domainVector.sizeLocal(); ++i){
118  if (domainVector[i] < 0.0) {
119  queso_error_msg("The domain for Jeffreys prior should be greater than zero.");
120  }
121  else if ((domainVector[i] == -INFINITY ) ||
122  (domainVector[i] == INFINITY ) ||
123  (m_normalizationStyle != 0 )) {//TODO: R: not sure what this is doing?
124  pdf = 0.0;
125  result = -INFINITY; //TODO: what do we do here?
126  }
127  else {
128  pdf = pdf * (1.0 / domainVector[i]);
129  result = std::log(pdf);
130  }
131  }
132  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
133  *m_env.subDisplayFile() << " return log(pdf) " << std::endl;
134  }
135  return result; // No need to add m_logOfNormalizationFactor [PDF-04]
136 }
const BaseEnvironment & m_env
const VectorSet< V, M > & m_domainSet
Domain set of the scalar function.
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

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

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