queso-0.51.1
Protected Attributes | List of all members
QUESO::LogNormalJointPdf< V, M > Class Template Reference

A class for handling Log-Normal joint PDFs. More...

#include <LogNormalJointPdf.h>

Inheritance diagram for QUESO::LogNormalJointPdf< V, M >:
Inheritance graph
[legend]
Collaboration diagram for QUESO::LogNormalJointPdf< V, M >:
Collaboration graph
[legend]

Public Member Functions

Constructor/Destructor methods
 LogNormalJointPdf (const char *prefix, const VectorSet< V, M > &domainSet, const V &lawExpVector, const V &lawVarVector)
 Constructor. More...
 
 ~LogNormalJointPdf ()
 Destructor. More...
 
Math methods
double actualValue (const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
 Actual value of the Log-Normal PDF (scalar function). More...
 
double lnValue (const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
 Logarithm of the value of the Log-Normal PDF (scalar function). More...
 
double computeLogOfNormalizationFactor (unsigned int numSamples, bool updateFactorInternally) const
 Computes the logarithm of the normalization factor. More...
 
const V & lawExpVector () const
 Access to the vector of mean values and private attribute: m_lawExpVector. More...
 
const V & lawVarVector () const
 Access to the vector of variance values and private attribute: m_lawVarVector. 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
 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...
 
- 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 Attributes

V * m_lawExpVector
 
V * m_lawVarVector
 
bool m_diagonalCovMatrix
 
- 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, class M>
class QUESO::LogNormalJointPdf< V, M >

A class for handling Log-Normal joint PDFs.

This class allows the mathematical definition of a Log-Normal Joint PDF.

Definition at line 49 of file LogNormalJointPdf.h.

Constructor & Destructor Documentation

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

Constructor.

Constructs a new object of the class, given a prefix and the domain of the PDF, a vector of mean values, lawExpVector, and a vector of covariance values lawVarVector (an alternative representation for a diagonal covariance matrix).

Definition at line 33 of file LogNormalJointPdf.C.

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

38  :
39  BaseJointPdf<V,M>(((std::string)(prefix)+"gau").c_str(),domainSet),
43 {
44  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
45  *m_env.subDisplayFile() << "Entering LogNormalJointPdf<V,M>::constructor() [1]"
46  << ": prefix = " << m_prefix
47  << std::endl;
48  }
49 
50  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 55)) {
51  *m_env.subDisplayFile() << "In LogNormalJointPdf<V,M>::constructor()"
52  //<< ", prefix = " << m_prefix
53  << ": meanVector = " << this->lawExpVector()
54  << ", Variances = " << this->lawVarVector()
55  << std::endl;
56  }
57 
58  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
59  *m_env.subDisplayFile() << "Leaving LogNormalJointPdf<V,M>::constructor() [1]"
60  << ": prefix = " << m_prefix
61  << std::endl;
62  }
63 }
const V & lawVarVector() const
Access to the vector of variance values and private attribute: m_lawVarVector.
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
const VectorSet< V, M > & domainSet() const
Access to the protected attribute m_domainSet: domain set of the scalar function. ...
const V & lawExpVector() const
Access to the vector of mean values and private attribute: m_lawExpVector.
const BaseEnvironment & m_env
unsigned int displayVerbosity() const
Definition: Environment.C:436
template<class V , class M >
QUESO::LogNormalJointPdf< V, M >::~LogNormalJointPdf ( )

Destructor.

Definition at line 66 of file LogNormalJointPdf.C.

67 {
68  delete m_lawVarVector;
69  delete m_lawExpVector;
70 }

Member Function Documentation

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

Actual value of the Log-Normal PDF (scalar function).

This method calls lnValue() and applies the exponential to its result.

Implements QUESO::BaseJointPdf< V, M >.

Definition at line 88 of file LogNormalJointPdf.C.

References UQ_FATAL_TEST_MACRO.

94 {
95  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 55)) {
96  *m_env.subDisplayFile() << "Entering LogNormalJointPdf<V,M>::actualValue()"
97  << ", meanVector = " << *m_lawExpVector
98  << ": domainVector = " << domainVector
99  << ", domainVector.sizeLocal() = " << domainVector.sizeLocal()
100  << ", this->m_domainSet.vectorSpace().dimLocal() = " << this->m_domainSet.vectorSpace().dimLocal()
101  << std::endl;
102  }
103 
104  UQ_FATAL_TEST_MACRO(domainVector.sizeLocal() != this->m_domainSet.vectorSpace().dimLocal(),
105  m_env.worldRank(),
106  "LogNormalJointPdf<V,M>::actualValue()",
107  "invalid input");
108 
109  UQ_FATAL_TEST_MACRO((gradVector || hessianMatrix || hessianEffect),
110  m_env.worldRank(),
111  "LogNormalJointPdf<V,M>::actualValue()",
112  "incomplete code for gradVector, hessianMatrix and hessianEffect calculations");
113 
114  double returnValue = 0.;
115 
116  V zeroVector(domainVector);
117  zeroVector.cwSet(0.);
118  if (domainVector.atLeastOneComponentSmallerOrEqualThan(zeroVector)) {
119  returnValue = 0.;
120  }
121  else if (this->m_domainSet.contains(domainVector) == false) { // prudenci 2011-Oct-04
122  returnValue = 0.;
123  }
124  else {
125  returnValue = std::exp(this->lnValue(domainVector,domainDirection,gradVector,hessianMatrix,hessianEffect));
126  }
127  //returnValue *= exp(m_logOfNormalizationFactor); // No need, because 'lnValue()' is called right above // [PDF-10]
128 
129  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 55)) {
130  *m_env.subDisplayFile() << "Leaving LogNormalJointPdf<V,M>::actualValue()"
131  << ", meanVector = " << *m_lawExpVector
132  << ": domainVector = " << domainVector
133  << ", returnValue = " << returnValue
134  << std::endl;
135  }
136 
137  return returnValue;
138 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
const VectorSet< V, M > & m_domainSet
Domain set of the scalar function.
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
double lnValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Logarithm of the value of the Log-Normal PDF (scalar function).
const BaseEnvironment & m_env
unsigned int displayVerbosity() const
Definition: Environment.C:436
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
template<class V , class M >
double QUESO::LogNormalJointPdf< 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 209 of file LogNormalJointPdf.C.

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

210 {
211  double value = 0.;
212 
213  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
214  *m_env.subDisplayFile() << "Entering LogNormalJointPdf<V,M>::computeLogOfNormalizationFactor()"
215  << std::endl;
216  }
217  value = BaseJointPdf<V,M>::commonComputeLogOfNormalizationFactor(numSamples, updateFactorInternally);
218  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
219  *m_env.subDisplayFile() << "Leaving LogNormalJointPdf<V,M>::computeLogOfNormalizationFactor()"
220  << ", m_logOfNormalizationFactor = " << m_logOfNormalizationFactor
221  << std::endl;
222  }
223 
224  return value;
225 }
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
double m_logOfNormalizationFactor
Definition: JointPdf.h:104
const BaseEnvironment & m_env
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:77
unsigned int displayVerbosity() const
Definition: Environment.C:436
template<class V , class M >
const V & QUESO::LogNormalJointPdf< V, M >::lawExpVector ( ) const

Access to the vector of mean values and private attribute: m_lawExpVector.

Definition at line 74 of file LogNormalJointPdf.C.

Referenced by QUESO::LogNormalJointPdf< V, M >::LogNormalJointPdf().

75 {
76  return *m_lawExpVector;
77 }
template<class V , class M >
const V & QUESO::LogNormalJointPdf< V, M >::lawVarVector ( ) const

Access to the vector of variance values and private attribute: m_lawVarVector.

Definition at line 81 of file LogNormalJointPdf.C.

Referenced by QUESO::LogNormalJointPdf< V, M >::LogNormalJointPdf().

82 {
83  return *m_lawVarVector;
84 }
template<class V , class M >
double QUESO::LogNormalJointPdf< V, M >::lnValue ( const V &  domainVector,
const V *  domainDirection,
V *  gradVector,
M *  hessianMatrix,
V *  hessianEffect 
) const
virtual

Logarithm of the value of the Log-Normal PDF (scalar function).

The logarithm of the value of the Log-Normal density of diagonal covariance matrix (sigma^2) comes from the summation:

\[ lnValue =- \sum_i \frac{1}{domainVector_i * \sqrt{2 \pi * lawVarVector_i}} exp(-\frac{(\ln( domainVector_i) - lawExpVector_i)^2}{2 lawVarVector_i}) \]

as long as $ domainVector_i > 0 $ for all $ i $.

Implements QUESO::BaseJointPdf< V, M >.

Definition at line 142 of file LogNormalJointPdf.C.

References UQ_FATAL_TEST_MACRO.

148 {
149  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 55)) {
150  *m_env.subDisplayFile() << "Entering LogNormalJointPdf<V,M>::lnValue()"
151  << ", meanVector = " << *m_lawExpVector
152  << ": domainVector = " << domainVector
153  << std::endl;
154  }
155 
156  UQ_FATAL_TEST_MACRO((gradVector || hessianMatrix || hessianEffect),
157  m_env.worldRank(),
158  "LogNormalJointPdf<V,M>::lnValue()",
159  "incomplete code for gradVector, hessianMatrix and hessianEffect calculations");
160 
161  if (domainDirection) {}; // just to remove compiler warning
162 
163  double returnValue = 0.;
164 
165  V zeroVector(domainVector);
166  zeroVector.cwSet(0.);
167  if (domainVector.atLeastOneComponentSmallerOrEqualThan(zeroVector)) {
168  returnValue = -INFINITY;
169  }
170  else if (this->m_domainSet.contains(domainVector) == false) { // prudenci 2011-Oct-04
171  returnValue = -INFINITY;
172  }
173  else {
174  if (m_diagonalCovMatrix) {
175  V diffVec(zeroVector);
176  for (unsigned int i = 0; i < domainVector.sizeLocal(); ++i) {
177  diffVec[i] = std::log(domainVector[i]) - this->lawExpVector()[i];
178  }
179  returnValue = ((diffVec*diffVec)/this->lawVarVector()).sumOfComponents();
180  returnValue *= -0.5;
181  if (m_normalizationStyle == 0) {
182  for (unsigned int i = 0; i < domainVector.sizeLocal(); ++i) {
183  returnValue -= std::log(domainVector[i] * std::sqrt(2. * M_PI * this->lawVarVector()[i])); // Contribution of 1/(x\sqrt{2\pi\sigma^2})
184  }
185  }
186  }
187  else {
188  UQ_FATAL_TEST_MACRO(true,
189  m_env.worldRank(),
190  "LogNormalJointPdf<V,M>::lnValue()",
191  "situation with a non-diagonal covariance matrix makes no sense");
192  }
193  returnValue += m_logOfNormalizationFactor; // [PDF-10]
194  }
195 
196  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 55)) {
197  *m_env.subDisplayFile() << "Leaving LogNormalJointPdf<V,M>::lnValue()"
198  << ", meanVector = " << *m_lawExpVector
199  << ": domainVector = " << domainVector
200  << ", returnValue = " << returnValue
201  << std::endl;
202  }
203 
204  return returnValue;
205 }
const V & lawVarVector() const
Access to the vector of variance values and private attribute: m_lawVarVector.
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
unsigned int m_normalizationStyle
Definition: JointPdf.h:103
const VectorSet< V, M > & m_domainSet
Domain set of the scalar function.
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
double m_logOfNormalizationFactor
Definition: JointPdf.h:104
const V & lawExpVector() const
Access to the vector of mean values and private attribute: m_lawExpVector.
const BaseEnvironment & m_env
unsigned int displayVerbosity() const
Definition: Environment.C:436
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223

Member Data Documentation

template<class V, class M>
bool QUESO::LogNormalJointPdf< V, M >::m_diagonalCovMatrix
protected

Definition at line 96 of file LogNormalJointPdf.h.

template<class V, class M>
V* QUESO::LogNormalJointPdf< V, M >::m_lawExpVector
protected

Definition at line 94 of file LogNormalJointPdf.h.

template<class V, class M>
V* QUESO::LogNormalJointPdf< V, M >::m_lawVarVector
protected

Definition at line 95 of file LogNormalJointPdf.h.


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

Generated on Thu Apr 23 2015 19:26:18 for queso-0.51.1 by  doxygen 1.8.5