queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
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 >:
QUESO::BaseVectorRealizer< V, M >

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 35 of file InvLogitGaussianVectorRealizer.C.

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

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

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

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

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 103 of file InvLogitGaussianVectorRealizer.C.

References QUESO::queso_isfinite().

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

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

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

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

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 Tue Jun 5 2018 19:49:31 for queso-0.57.1 by  doxygen 1.8.5