queso-0.53.0
Private Attributes | List of all members
QUESO::InvLogitGaussianJointPdf< V, M > Class Template Reference

A class for handling hybrid (transformed) Gaussians with bounds. More...

#include <InvLogitGaussianJointPdf.h>

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

Public Member Functions

Constructor/Destructor methods
 InvLogitGaussianJointPdf (const char *prefix, const BoxSubset< V, M > &domainBoxSubset, const V &lawExpVector, const V &lawVarVector)
 Constructor. More...
 
 InvLogitGaussianJointPdf (const char *prefix, const BoxSubset< V, M > &domainBoxSubset, const V &lawExpVector, const M &lawCovMatrix)
 Constructor. More...
 
 ~InvLogitGaussianJointPdf ()
 Destructor. More...
 
Math methods
double actualValue (const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
 Actual value of the (transformed) Gaussian PDF. More...
 
double lnValue (const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
 Logarithm of the value of the (transformed) Gaussian PDF (scalar function). More...
 
double computeLogOfNormalizationFactor (unsigned int numSamples, bool updateFactorInternally) const
 Computes the logarithm of the normalization factor. More...
 
void updateLawExpVector (const V &newLawExpVector)
 Updates the mean of the Gaussian (not transformed) with the new value newLawExpVector. More...
 
void updateLawCovMatrix (const M &newLawCovMatrix)
 Updates the lower triangular matrix from Cholesky decomposition of the covariance matrix to the new value newLowerCholLawCovMatrix. More...
 
const M & lawCovMatrix () const
 Returns the covariance matrix; access to protected attribute m_lawCovMatrix. More...
 
const V & lawExpVector () const
 Access to the vector of mean values of the Gaussian (not transformed) 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...
 

Private Attributes

V * m_lawExpVector
 
V * m_lawVarVector
 
bool m_diagonalCovMatrix
 
const M * m_lawCovMatrix
 
const BoxSubset< V, M > & m_domainBoxSubset
 

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::InvLogitGaussianJointPdf< V, M >

A class for handling hybrid (transformed) Gaussians with bounds.

This class allows the mathematical definition of a Gaussian PDF in dimensions of a VectorSubset that are unbounded, and a logit transformed Gaussian PDF in dimensions that have a lower or upper (or both) bound. For the bounded directions, the PDF is

\[ p(x) = \frac{1}{2 \sigma^2 \pi} \exp \left( - \frac12 (\mbox{logit} x - \mu)^2 \right) \mbox{logit}'(x), \quad x \in [a, b], \]

where logit is defined as

\[ \mbox{logit}(x) = \log \left( \frac{x - a}{b - x} \right), \quad x \in [a, b]. \]

Definition at line 58 of file InvLogitGaussianJointPdf.h.

Constructor & Destructor Documentation

template<class V , class M >
QUESO::InvLogitGaussianJointPdf< V, M >::InvLogitGaussianJointPdf ( const char *  prefix,
const BoxSubset< V, M > &  domainBoxSubset,
const V &  lawExpVector,
const V &  lawVarVector 
)

Constructor.

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

Definition at line 33 of file InvLogitGaussianJointPdf.C.

38  :
39  BaseJointPdf<V,M>(((std::string)(prefix)+"invlogit_gau").c_str(),
40  domainBoxSubset),
43  m_diagonalCovMatrix(true),
44  m_lawCovMatrix(m_domainSet.vectorSpace().newDiagMatrix(lawVarVector)),
45  m_domainBoxSubset(domainBoxSubset)
46 {
47 }
const V & lawExpVector() const
Access to the vector of mean values of the Gaussian (not transformed) and private attribute: m_lawExp...
const BoxSubset< V, M > & m_domainBoxSubset
const VectorSet< V, M > & m_domainSet
Domain set of the scalar function.
const V & lawVarVector() const
Access to the vector of variance values and private attribute: m_lawVarVector.
template<class V , class M >
QUESO::InvLogitGaussianJointPdf< V, M >::InvLogitGaussianJointPdf ( const char *  prefix,
const BoxSubset< V, M > &  domainBoxSubset,
const V &  lawExpVector,
const M &  lawCovMatrix 
)

Constructor.

Constructs a new object, given a prefix and the image set of the vector realizer, a vector of mean values, lawExpVector (for the Gaussian, not the transformed Gaussian), and a covariance matrix, lawCovMatrix.

Definition at line 51 of file InvLogitGaussianJointPdf.C.

56  :
57  BaseJointPdf<V,M>(((std::string)(prefix)+"invlogit_gau").c_str(),
58  domainBoxSubset),
60  m_lawVarVector(domainBoxSubset.vectorSpace().newVector(INFINITY)), // FIX ME
61  m_diagonalCovMatrix(false),
63  m_domainBoxSubset(domainBoxSubset)
64 {
65 }
const V & lawExpVector() const
Access to the vector of mean values of the Gaussian (not transformed) and private attribute: m_lawExp...
const BoxSubset< V, M > & m_domainBoxSubset
const M & lawCovMatrix() const
Returns the covariance matrix; access to protected attribute m_lawCovMatrix.
template<class V , class M >
QUESO::InvLogitGaussianJointPdf< V, M >::~InvLogitGaussianJointPdf ( )

Member Function Documentation

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

Actual value of the (transformed) Gaussian PDF.

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

Implements QUESO::BaseJointPdf< V, M >.

Definition at line 91 of file InvLogitGaussianJointPdf.C.

97 {
98  double returnValue;
99 
100  returnValue = std::exp(this->lnValue(domainVector,domainDirection,gradVector,hessianMatrix,hessianEffect));
101 
102  return returnValue;
103 }
double lnValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Logarithm of the value of the (transformed) Gaussian PDF (scalar function).
template<class V , class M >
double QUESO::InvLogitGaussianJointPdf< 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 207 of file InvLogitGaussianJointPdf.C.

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

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

Returns the covariance matrix; access to protected attribute m_lawCovMatrix.

Definition at line 245 of file InvLogitGaussianJointPdf.C.

Referenced by QUESO::MetropolisHastingsSG< P_V, P_M >::alpha(), and QUESO::TransformedScaledCovMatrixTKGroup< V, M >::setPreComputingPosition().

246 {
247  return *m_lawCovMatrix;
248 }
template<class V , class M >
const V & QUESO::InvLogitGaussianJointPdf< V, M >::lawExpVector ( ) const

Access to the vector of mean values of the Gaussian (not transformed) and private attribute: m_lawExpVector.

Definition at line 77 of file InvLogitGaussianJointPdf.C.

Referenced by QUESO::MetropolisHastingsSG< P_V, P_M >::alpha().

template<class V , class M >
const V & QUESO::InvLogitGaussianJointPdf< V, M >::lawVarVector ( ) const

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

Definition at line 84 of file InvLogitGaussianJointPdf.C.

Referenced by QUESO::MetropolisHastingsSG< P_V, P_M >::alpha().

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

Logarithm of the value of the (transformed) Gaussian PDF (scalar function).

The ln(value) comes from a summation of the Gaussian density:

\[ lnValue =- \sum_i \frac{1}{\sqrt{|covMatrix|} \sqrt{2 \pi}} exp(-\frac{(domainVector_i - lawExpVector_i) * covMatrix^{-1} * (domainVector_i - lawExpVector_i) }{2} + \log \mbox{logit}'(domainVector_i), \]

where the $ covMatrix $ may recovered via this->lawVarVector(), in case of diagonal matrices or via this->m_lawCovMatrix, otherwise.

Implements QUESO::BaseJointPdf< V, M >.

Definition at line 107 of file InvLogitGaussianJointPdf.C.

113 {
114  double returnValue;
115  double lnDeterminant = 0.0;
116  V transformedDomainVector(domainVector);
117 
118  V min_domain_bounds(this->m_domainBoxSubset.minValues());
119  V max_domain_bounds(this->m_domainBoxSubset.maxValues());
120 
121  double lnjacobian = 0.0;
122  for (unsigned int i = 0; i < domainVector.sizeLocal(); i++) {
123  double min_val = min_domain_bounds[i];
124  double max_val = max_domain_bounds[i];
125 
126  if (boost::math::isfinite(min_val) &&
127  boost::math::isfinite(max_val)) {
128 
129  if (domainVector[i] == min_val || domainVector[i] == max_val) {
130  // Exit early if we can
131  return -INFINITY;
132  }
133 
134  // Left- and right-hand sides are finite. Do full transform.
135  transformedDomainVector[i] = std::log(domainVector[i] - min_val) -
136  std::log(max_val - domainVector[i]);
137 
138  lnjacobian += std::log(max_val - min_val) -
139  std::log(domainVector[i] - min_val) -
140  std::log(max_val - domainVector[i]);
141  }
142  else if (boost::math::isfinite(min_val) &&
143  !boost::math::isfinite(max_val)) {
144 
145  if (domainVector[i] == min_val) {
146  // Exit early if we can
147  return -INFINITY;
148  }
149 
150  // Left-hand side finite, but right-hand side is not.
151  // Do only left-hand transform.
152  transformedDomainVector[i] = std::log(domainVector[i] - min_val);
153 
154  lnjacobian += -std::log(domainVector[i] - min_val);
155  }
156  else if (!boost::math::isfinite(min_val) &&
157  boost::math::isfinite(max_val)) {
158 
159  if (domainVector[i] == max_val) {
160  // Exit early if we can
161  return -INFINITY;
162  }
163 
164  // Right-hand side is finite, but left-hand side is not.
165  // Do only right-hand transform.
166  transformedDomainVector[i] = -std::log(max_val - domainVector[i]);
167 
168  lnjacobian += -std::log(max_val - domainVector[i]);
169  }
170  else {
171  // No transform.
172  transformedDomainVector[i] = domainVector[i];
173  }
174  }
175 
176  V diffVec(transformedDomainVector - this->lawExpVector());
177  if (m_diagonalCovMatrix) {
178  returnValue = ((diffVec * diffVec) /
179  this->lawVarVector()).sumOfComponents();
180  if (m_normalizationStyle == 0) {
181  unsigned int iMax = this->lawVarVector().sizeLocal();
182  for (unsigned int i = 0; i < iMax; ++i) {
183  lnDeterminant += log(this->lawVarVector()[i]);
184  }
185  }
186  }
187  else {
188  V tmpVec = this->m_lawCovMatrix->invertMultiply(diffVec);
189  returnValue = (diffVec * tmpVec).sumOfComponents();
190  if (m_normalizationStyle == 0) {
191  lnDeterminant = this->m_lawCovMatrix->lnDeterminant();
192  }
193  }
194  if (m_normalizationStyle == 0) {
195  returnValue += ((double) this->lawVarVector().sizeLocal()) * log(2 * M_PI);
196  returnValue += lnDeterminant;
197  }
198  returnValue *= -0.5;
199  returnValue += m_logOfNormalizationFactor;
200  returnValue += lnjacobian;
201 
202  return returnValue;
203 }
unsigned int m_normalizationStyle
Definition: JointPdf.h:99
const V & lawExpVector() const
Access to the vector of mean values of the Gaussian (not transformed) and private attribute: m_lawExp...
double m_logOfNormalizationFactor
Definition: JointPdf.h:100
const BoxSubset< V, M > & m_domainBoxSubset
const V & lawVarVector() const
Access to the vector of variance values and private attribute: m_lawVarVector.
template<class V , class M >
void QUESO::InvLogitGaussianJointPdf< V, M >::updateLawCovMatrix ( const M &  newLawCovMatrix)

Updates the lower triangular matrix from Cholesky decomposition of the covariance matrix to the new value newLowerCholLawCovMatrix.

This method deletes old expected values (allocated at construction or last call to this method).

Definition at line 236 of file InvLogitGaussianJointPdf.C.

237 {
238  // delete old expected values (allocated at construction or last call to this function)
239  delete m_lawCovMatrix;
240  m_lawCovMatrix = new M(newLawCovMatrix);
241 }
template<class V , class M >
void QUESO::InvLogitGaussianJointPdf< V, M >::updateLawExpVector ( const V &  newLawExpVector)

Updates the mean of the Gaussian (not transformed) with the new value newLawExpVector.

This method deletes old expected values (allocated at construction or last call to this method).

Definition at line 227 of file InvLogitGaussianJointPdf.C.

228 {
229  // delete old expected values (allocated at construction or last call to this function)
230  delete m_lawExpVector;
231  m_lawExpVector = new V(newLawExpVector);
232 }

Member Data Documentation

template<class V = GslVector, class M = GslMatrix>
bool QUESO::InvLogitGaussianJointPdf< V, M >::m_diagonalCovMatrix
private

Definition at line 150 of file InvLogitGaussianJointPdf.h.

template<class V = GslVector, class M = GslMatrix>
const BoxSubset<V, M>& QUESO::InvLogitGaussianJointPdf< V, M >::m_domainBoxSubset
private

Definition at line 153 of file InvLogitGaussianJointPdf.h.

template<class V = GslVector, class M = GslMatrix>
const M* QUESO::InvLogitGaussianJointPdf< V, M >::m_lawCovMatrix
private

Definition at line 151 of file InvLogitGaussianJointPdf.h.

template<class V = GslVector, class M = GslMatrix>
V* QUESO::InvLogitGaussianJointPdf< V, M >::m_lawExpVector
private

Definition at line 148 of file InvLogitGaussianJointPdf.h.

template<class V = GslVector, class M = GslMatrix>
V* QUESO::InvLogitGaussianJointPdf< V, M >::m_lawVarVector
private

Definition at line 149 of file InvLogitGaussianJointPdf.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