queso-0.53.0
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 = GslVector, class M = GslMatrix>
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 51 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 36 of file InvLogitGaussianVectorRealizer.C.

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

41  : BaseVectorRealizer<V, M>(((std::string)(prefix)+"invlogit_gau").c_str(),
42  unifiedImageBoxSubset, std::numeric_limits<unsigned int>::max()),
43  m_unifiedLawExpVector(new V(lawExpVector)),
45  unifiedImageBoxSubset.vectorSpace().newVector(INFINITY)), // FIX ME
46  m_lowerCholLawCovMatrix(new M(lowerCholLawCovMatrix)),
47  m_matU(NULL),
48  m_vecSsqrt(NULL),
49  m_matVt(NULL),
50  m_unifiedImageBoxSubset(unifiedImageBoxSubset)
51 {
52  *m_unifiedLawExpVector = lawExpVector;
53 }
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 56 of file InvLogitGaussianVectorRealizer.C.

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

63  : BaseVectorRealizer<V, M>(((std::string)(prefix)+"invlogit_gau").c_str(),
64  unifiedImageBoxSubset, std::numeric_limits<unsigned int>::max()),
65  m_unifiedLawExpVector(new V(lawExpVector)),
67  unifiedImageBoxSubset.vectorSpace().newVector( INFINITY)), // FIX ME
69  m_matU(new M(matU)),
70  m_vecSsqrt(new V(vecSsqrt)),
71  m_matVt(new M(matVt)),
72  m_unifiedImageBoxSubset(unifiedImageBoxSubset)
73 {
74  *m_unifiedLawExpVector = lawExpVector; // ????
75 }
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 104 of file InvLogitGaussianVectorRealizer.C.

References queso_error_msg.

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

154 {
155  // delete old expected values (allocated at construction or last call to this function)
156  delete m_unifiedLawExpVector;
157 
158  m_unifiedLawExpVector = new V(newLawExpVector);
159 }
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 163 of file InvLogitGaussianVectorRealizer.C.

165 {
166  // delete old expected values (allocated at construction or last call to this function)
168  delete m_matU;
169  delete m_vecSsqrt;
170  delete m_matVt;
171 
172  m_lowerCholLawCovMatrix = new M(newLowerCholLawCovMatrix);
173  m_matU = NULL;
174  m_vecSsqrt = NULL;
175  m_matVt = NULL;
176 }
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 180 of file InvLogitGaussianVectorRealizer.C.

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

Member Data Documentation

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

Definition at line 121 of file InvLogitGaussianVectorRealizer.h.

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

Definition at line 122 of file InvLogitGaussianVectorRealizer.h.

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

Definition at line 124 of file InvLogitGaussianVectorRealizer.h.

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

Definition at line 132 of file InvLogitGaussianVectorRealizer.h.

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

Definition at line 120 of file InvLogitGaussianVectorRealizer.h.

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

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