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

A class for handling sampling from (transformed) Gaussian probability density distributions with bounds. More...

#include <InvLogitGaussianVectorRealizer.h>

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

Public Member Functions

Constructor/Destructor methods
 InvLogitGaussianVectorRealizer (const char *prefix, const BoxSubset< V, M > &unifiedImageBoxSubset, const V &lawExpVector, const M &lowerCholLawCovMatrix)
 Constructor. More...
 
 InvLogitGaussianVectorRealizer (const char *prefix, const BoxSubset< V, M > &unifiedImageBoxSubset, const V &lawExpVector, const M &matU, const V &vecSsqrt, const M &matVt)
 Constructor. More...
 
 ~InvLogitGaussianVectorRealizer ()
 Destructor. More...
 
Realization-related methods
const V & unifiedLawExpVector () const
 Access to the vector of mean values of the Gaussian and private attribute: m_unifiedLawExpVector. More...
 
const V & unifiedLawVarVector () const
 Access to the vector of variance values and private attribute: m_unifiedLawVarVector. More...
 
void realization (V &nextValues) const
 Draws a realization. More...
 
void updateLawExpVector (const V &newLawExpVector)
 Updates the mean of the Gaussian with the new value newLawExpVector. More...
 
void updateLowerCholLawCovMatrix (const M &newLowerCholLawCovMatrix)
 Updates the lower triangular matrix from Cholesky decomposition of the covariance matrix to the new value newLowerCholLawCovMatrix. More...
 
void updateLowerCholLawCovMatrix (const M &matU, const V &vecSsqrt, const M &matVt)
 Updates the SVD matrices from SVD decomposition of the covariance matrix to the new values: matU, vecSsqrt, and matVt. More...
 
- Public Member Functions inherited from QUESO::BaseVectorRealizer< V, M >
 BaseVectorRealizer (const char *prefix, const VectorSet< V, M > &unifiedImageSet, unsigned int subPeriod)
 Default constructor. More...
 
virtual ~BaseVectorRealizer ()
 Virtual destructor. More...
 
const VectorSet< V, M > & unifiedImageSet () const
 Image set where the realizations lie. Access to protected attribute m_unifiedImageSet. More...
 
unsigned int subPeriod () const
 Sub-period of the realization. Access to protected attribute m_subPeriod. More...
 

Private Attributes

V * m_unifiedLawExpVector
 
V * m_unifiedLawVarVector
 
M * m_lowerCholLawCovMatrix
 
M * m_matU
 
V * m_vecSsqrt
 
M * m_matVt
 
const BoxSubset< V, M > & m_unifiedImageBoxSubset
 

Additional Inherited Members

- Protected Attributes inherited from QUESO::BaseVectorRealizer< V, M >
const BaseEnvironmentm_env
 
std::string m_prefix
 
const VectorSet< V, M > & m_unifiedImageSet
 
unsigned int m_subPeriod
 

Detailed Description

template<class V, class M>
class QUESO::InvLogitGaussianVectorRealizer< V, M >

A class for handling sampling from (transformed) Gaussian probability density distributions with bounds.

To get a realization from a transformed Gaussian (i.e. with bounds), an inverse logit transform is applied. I.e., samples are $ f(X) $ where $ X $ is drawn from a Gaussian and where

\[ f(x) = \frac{b \exp(x) + a}{1 + \exp(x)}. \]

This will produce a sample in the closed interval [a, b].

Definition at line 48 of file InvLogitGaussianVectorRealizer.h.

Constructor & Destructor Documentation

template<class V , class M >
QUESO::InvLogitGaussianVectorRealizer< V, M >::InvLogitGaussianVectorRealizer ( const char *  prefix,
const BoxSubset< V, M > &  unifiedImageBoxSubset,
const V &  lawExpVector,
const M &  lowerCholLawCovMatrix 
)

Constructor.

Constructs a new object, given a prefix and the image set of the vector realizer, a vector of mean values, lawExpVector (of the Gaussian, not the transformed Gaussian), and a lower triangular matrix resulting from Cholesky decomposition of the covariance matrix, lowerCholLawCovMatrix.

Definition at line 34 of file InvLogitGaussianVectorRealizer.C.

References QUESO::InvLogitGaussianVectorRealizer< V, M >::m_unifiedLawExpVector.

39  : BaseVectorRealizer<V, M>(((std::string)(prefix)+"invlogit_gau").c_str(),
40  unifiedImageBoxSubset, std::numeric_limits<unsigned int>::max()),
41  m_unifiedLawExpVector(new V(lawExpVector)),
43  unifiedImageBoxSubset.vectorSpace().newVector(INFINITY)), // FIX ME
44  m_lowerCholLawCovMatrix(new M(lowerCholLawCovMatrix)),
45  m_matU(NULL),
46  m_vecSsqrt(NULL),
47  m_matVt(NULL),
48  m_unifiedImageBoxSubset(unifiedImageBoxSubset)
49 {
50  *m_unifiedLawExpVector = lawExpVector;
51 }
template<class V , class M >
QUESO::InvLogitGaussianVectorRealizer< V, M >::InvLogitGaussianVectorRealizer ( const char *  prefix,
const BoxSubset< V, M > &  unifiedImageBoxSubset,
const V &  lawExpVector,
const M &  matU,
const V &  vecSsqrt,
const M &  matVt 
)

Constructor.

Constructs a new object, given a prefix and the image set of the vector realizer, a vector of mean values, lawExpVector (of the Gaussian, not the transformed Gaussian), and a set of two matrices and one vector resulting from the Single Value Decomposition of the covariance matrix, matU, vecSsqrt and matVt.

Definition at line 54 of file InvLogitGaussianVectorRealizer.C.

References QUESO::InvLogitGaussianVectorRealizer< V, M >::m_unifiedLawExpVector.

61  : BaseVectorRealizer<V, M>(((std::string)(prefix)+"invlogit_gau").c_str(),
62  unifiedImageBoxSubset, std::numeric_limits<unsigned int>::max()),
63  m_unifiedLawExpVector(new V(lawExpVector)),
65  unifiedImageBoxSubset.vectorSpace().newVector( INFINITY)), // FIX ME
67  m_matU(new M(matU)),
68  m_vecSsqrt(new V(vecSsqrt)),
69  m_matVt(new M(matVt)),
70  m_unifiedImageBoxSubset(unifiedImageBoxSubset)
71 {
72  *m_unifiedLawExpVector = lawExpVector; // ????
73 }
template<class V , class M >
QUESO::InvLogitGaussianVectorRealizer< V, M >::~InvLogitGaussianVectorRealizer ( )

Member Function Documentation

template<class V , class M >
void QUESO::InvLogitGaussianVectorRealizer< V, M >::realization ( V &  nextValues) const
virtual

Draws a realization.

This function draws a realization of a (transformed) Gaussian distribution with mean m_unifiedLawExpVector and variance m_unifiedLawVarVector and saves it in nextValues.

Implements QUESO::BaseVectorRealizer< V, M >.

Definition at line 102 of file InvLogitGaussianVectorRealizer.C.

References queso_error_msg.

103 {
104  V iidGaussianVector(m_unifiedImageSet.vectorSpace().zeroVector());
105 
106  iidGaussianVector.cwSetGaussian(0.0, 1.0);
107 
109  nextValues = (*m_unifiedLawExpVector) +
110  (*m_lowerCholLawCovMatrix) * iidGaussianVector;
111  }
112  else if (m_matU && m_vecSsqrt && m_matVt) {
113  nextValues = (*m_unifiedLawExpVector) +
114  (*m_matU) * ((*m_vecSsqrt) * ((*m_matVt) * iidGaussianVector));
115  }
116  else {
117  queso_error_msg("GaussianVectorRealizer<V,M>::realization() inconsistent internal state");
118  }
119 
120  V min_domain_bounds(this->m_unifiedImageBoxSubset.minValues());
121  V max_domain_bounds(this->m_unifiedImageBoxSubset.maxValues());
122 
123  for (unsigned int i = 0; i < nextValues.sizeLocal(); i++) {
124  double temp = std::exp(nextValues[i]);
125  double min_val = min_domain_bounds[i];
126  double max_val = max_domain_bounds[i];
127 
128  if (boost::math::isfinite(min_val) &&
129  boost::math::isfinite(max_val)) {
130  // Left- and right-hand sides are finite. Do full transform.
131  nextValues[i] = (max_val * temp + min_val) / (1.0 + temp);
132  }
133  else if (boost::math::isfinite(min_val) &&
134  !boost::math::isfinite(max_val)) {
135  // Left-hand side finite, but right-hand side is not.
136  // Do only left-hand transform.
137  nextValues[i] = temp + min_val;
138  }
139  else if (!boost::math::isfinite(min_val) &&
140  boost::math::isfinite(max_val)) {
141  // Right-hand side is finite, but left-hand side is not.
142  // Do only right-hand transform.
143  nextValues[i] = (max_val * temp - 1.0) / temp;
144  }
145  }
146 }
const VectorSet< V, M > & m_unifiedImageSet
#define queso_error_msg(msg)
Definition: asserts.h:91
template<class V , class M >
const V & QUESO::InvLogitGaussianVectorRealizer< V, M >::unifiedLawExpVector ( ) const

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

Definition at line 88 of file InvLogitGaussianVectorRealizer.C.

template<class V , class M >
const V & QUESO::InvLogitGaussianVectorRealizer< V, M >::unifiedLawVarVector ( ) const

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

Definition at line 95 of file InvLogitGaussianVectorRealizer.C.

template<class V , class M >
void QUESO::InvLogitGaussianVectorRealizer< V, M >::updateLawExpVector ( const V &  newLawExpVector)

Updates the mean of the Gaussian with the new value newLawExpVector.

Definition at line 150 of file InvLogitGaussianVectorRealizer.C.

152 {
153  // delete old expected values (allocated at construction or last call to this function)
154  delete m_unifiedLawExpVector;
155 
156  m_unifiedLawExpVector = new V(newLawExpVector);
157 }
template<class V , class M >
void QUESO::InvLogitGaussianVectorRealizer< V, M >::updateLowerCholLawCovMatrix ( const M &  newLowerCholLawCovMatrix)

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

The lower triangular matrix results resulting from a Cholesky decomposition of the covariance matrix. This routine deletes old expected values: m_lowerCholLawCovMatrix; m_matU, m_vecSsqrt, m_matVt.

Definition at line 161 of file InvLogitGaussianVectorRealizer.C.

163 {
164  // delete old expected values (allocated at construction or last call to this function)
166  delete m_matU;
167  delete m_vecSsqrt;
168  delete m_matVt;
169 
170  m_lowerCholLawCovMatrix = new M(newLowerCholLawCovMatrix);
171  m_matU = NULL;
172  m_vecSsqrt = NULL;
173  m_matVt = NULL;
174 }
template<class V , class M >
void QUESO::InvLogitGaussianVectorRealizer< V, M >::updateLowerCholLawCovMatrix ( const M &  matU,
const V &  vecSsqrt,
const M &  matVt 
)

Updates the SVD matrices from SVD decomposition of the covariance matrix to the new values: matU, vecSsqrt, and matVt.

The lower triangular matrix results resulting from a Cholesky decomposition of the covariance matrix. This routine deletes old expected values: m_lowerCholLawCovMatrix; m_matU, m_vecSsqrt, m_matVt.

Definition at line 178 of file InvLogitGaussianVectorRealizer.C.

182 {
183  // delete old expected values (allocated at construction or last call to this function)
185  delete m_matU;
186  delete m_vecSsqrt;
187  delete m_matVt;
188 
190  m_matU = new M(matU);
191  m_vecSsqrt = new V(vecSsqrt);
192  m_matVt = new M(matVt);
193 }

Member Data Documentation

template<class V , class M >
M* QUESO::InvLogitGaussianVectorRealizer< V, M >::m_lowerCholLawCovMatrix
private

Definition at line 118 of file InvLogitGaussianVectorRealizer.h.

template<class V , class M >
M* QUESO::InvLogitGaussianVectorRealizer< V, M >::m_matU
private

Definition at line 119 of file InvLogitGaussianVectorRealizer.h.

template<class V , class M >
M* QUESO::InvLogitGaussianVectorRealizer< V, M >::m_matVt
private

Definition at line 121 of file InvLogitGaussianVectorRealizer.h.

template<class V , class M >
const BoxSubset<V, M>& QUESO::InvLogitGaussianVectorRealizer< V, M >::m_unifiedImageBoxSubset
private

Definition at line 129 of file InvLogitGaussianVectorRealizer.h.

template<class V , class M >
V* QUESO::InvLogitGaussianVectorRealizer< V, M >::m_unifiedLawExpVector
private
template<class V , class M >
V* QUESO::InvLogitGaussianVectorRealizer< V, M >::m_unifiedLawVarVector
private

Definition at line 117 of file InvLogitGaussianVectorRealizer.h.

template<class V , class M >
V* QUESO::InvLogitGaussianVectorRealizer< V, M >::m_vecSsqrt
private

Definition at line 120 of file InvLogitGaussianVectorRealizer.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