queso-0.51.1
List of all members
QUESO::InvLogitGaussianVectorRV< V, M > Class Template Reference

A class representing a (transformed) Gaussian vector RV with bounds. More...

#include <InvLogitGaussianVectorRV.h>

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

Public Member Functions

Constructor/Destructor methods
 InvLogitGaussianVectorRV (const char *prefix, const BoxSubset< V, M > &imageBoxSubset, const V &lawExpVector, const V &lawVarVector)
 Constructor. More...
 
 InvLogitGaussianVectorRV (const char *prefix, const BoxSubset< V, M > &imageBoxSubset, const V &lawExpVector, const M &lawCovMatrix)
 Constructor. More...
 
virtual ~InvLogitGaussianVectorRV ()
 Virtual destructor. More...
 
Statistical methods
void updateLawExpVector (const V &newLawExpVector)
 Updates the vector that contains the mean values for the underlying Gaussian. More...
 
void updateLawCovMatrix (const M &newLawCovMatrix)
 Updates the covariance matrix. More...
 
I/O methods
void print (std::ostream &os) const
 TODO: Prints the vector RV. More...
 
- Public Member Functions inherited from QUESO::BaseVectorRV< V, M >
 BaseVectorRV (const char *prefix, const VectorSet< V, M > &imageSet)
 Constructor. More...
 
virtual ~BaseVectorRV ()
 Virtual destructor. More...
 
const BaseEnvironmentenv () const
 QUESO environment; access to private attribute m_env. More...
 
const VectorSet< V, M > & imageSet () const
 Image set of the vector RV; access to private attribute m_imageSet. More...
 
const BaseJointPdf< V, M > & pdf () const
 Posterior Density Function of the vector RV; access to private attribute m_pdf. More...
 
const BaseVectorRealizer< V, M > & realizer () const
 Finds a realization (sample) of the PDF of this vector RV; access to private attribute m_realizer. More...
 
const BaseVectorCdf< V, M > & subCdf () const
 Finds the Cumulative Distribution Function of this vector RV, considering only the sub-sequence of data; access to private attribute m_subCdf. More...
 
const BaseVectorCdf< V, M > & unifiedCdf () const
 Finds the Cumulative Distribution Function of this vector RV, considering the unified sequence of data; access to private attribute m_unifiedCdf. More...
 
const BaseVectorMdf< V, M > & mdf () const
 Finds the Mass Density Function of this vector RV; access to private attribute m_mdf. More...
 

Additional Inherited Members

- Protected Attributes inherited from QUESO::BaseVectorRV< V, M >
const BaseEnvironmentm_env
 
std::string m_prefix
 
const VectorSet< V, M > & m_imageSet
 
BaseJointPdf< V, M > * m_pdf
 
BaseVectorRealizer< V, M > * m_realizer
 
const BaseVectorCdf< V, M > * m_subCdf
 
const BaseVectorCdf< V, M > * m_unifiedCdf
 
const BaseVectorMdf< V, M > * m_mdf
 

Detailed Description

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

A class representing a (transformed) Gaussian vector RV with bounds.

This class allows the user to compute the value of a (transoformed) Gaussian PDF and to generate realizations (samples) from it.

Definition at line 42 of file InvLogitGaussianVectorRV.h.

Constructor & Destructor Documentation

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

Constructor.

Construct a (transformed) Gaussian vector RV with mean lawExpVector (of the Gaussian, not the transformed Gaussian) and diagonal covariance matrix lawVarVector whose variates live in imageBoxSubset.

Definition at line 35 of file InvLogitGaussianVectorRV.C.

References QUESO::BaseEnvironment::displayVerbosity(), QUESO::BaseVectorRV< V, M >::m_env, QUESO::BaseVectorRV< V, M >::m_imageSet, QUESO::BaseVectorRV< V, M >::m_mdf, QUESO::BaseVectorRV< V, M >::m_pdf, QUESO::BaseVectorRV< V, M >::m_prefix, QUESO::BaseVectorRV< V, M >::m_realizer, QUESO::BaseVectorRV< V, M >::m_subCdf, QUESO::BaseVectorRV< V, M >::m_unifiedCdf, QUESO::BaseEnvironment::subDisplayFile(), UQ_FATAL_TEST_MACRO, and QUESO::BaseEnvironment::worldRank().

40  : BaseVectorRV<V, M>(((std::string)(prefix)+"invlogit_gau").c_str(),
41  imageBoxSubset)
42 {
43  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
44  *m_env.subDisplayFile() << "Entering InvLogitGaussianVectorRV<V,M>::constructor() [1]"
45  << ": prefix = " << m_prefix
46  << std::endl;
47  }
48 
49  UQ_FATAL_TEST_MACRO((lawVarVector.getMinValue() <= 0.0),
50  m_env.worldRank(),
51  "InvLogitGaussianVectorRV<V,M>::constructor() [1]",
52  "Covariance matrix is not symmetric positive definite.");
53 
54  m_pdf = new InvLogitGaussianJointPdf<V,M>(m_prefix.c_str(),
55  dynamic_cast<const BoxSubset<V, M> & >(m_imageSet), lawExpVector,
56  lawVarVector);
57 
58  V cholDiag(lawVarVector);
59  cholDiag.cwSqrt();
60  M lowerCholLawCovMatrix(cholDiag);
61  lowerCholLawCovMatrix.zeroUpper(false);
62 
63  m_realizer = new InvLogitGaussianVectorRealizer<V,M>(m_prefix.c_str(),
64  dynamic_cast<const BoxSubset<V, M> & >(m_imageSet), lawExpVector,
65  lowerCholLawCovMatrix);
66 
67  m_subCdf = NULL; // FIX ME: complete code
68  m_unifiedCdf = NULL; // FIX ME: complete code
69  m_mdf = NULL; // FIX ME: complete code
70 
71  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
72  *m_env.subDisplayFile() << "Leaving InvLogitGaussianVectorRV<V,M>::constructor() [1]"
73  << ": prefix = " << m_prefix
74  << std::endl;
75  }
76 }
const BaseVectorCdf< V, M > * m_unifiedCdf
Definition: VectorRV.h:118
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
const VectorSet< V, M > & m_imageSet
Definition: VectorRV.h:114
const BaseEnvironment & m_env
Definition: VectorRV.h:112
const BaseVectorCdf< V, M > * m_subCdf
Definition: VectorRV.h:117
BaseVectorRealizer< V, M > * m_realizer
Definition: VectorRV.h:116
unsigned int displayVerbosity() const
Definition: Environment.C:436
const BaseVectorMdf< V, M > * m_mdf
Definition: VectorRV.h:119
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
std::string m_prefix
Definition: VectorRV.h:113
BaseJointPdf< V, M > * m_pdf
Definition: VectorRV.h:115
template<class V , class M >
QUESO::InvLogitGaussianVectorRV< V, M >::InvLogitGaussianVectorRV ( const char *  prefix,
const BoxSubset< V, M > &  imageBoxSubset,
const V &  lawExpVector,
const M &  lawCovMatrix 
)

Constructor.

Construct a (transformed) Gaussian vector RV with mean lawExpVector (of the Gaussian, not the transformed Gaussian) and covariance matrix lawCovMatrix whose variates live in imageBoxSubset.

Definition at line 79 of file InvLogitGaussianVectorRV.C.

References QUESO::BaseEnvironment::displayVerbosity(), QUESO::BaseVectorRV< V, M >::m_env, QUESO::BaseVectorRV< V, M >::m_imageSet, QUESO::BaseVectorRV< V, M >::m_mdf, QUESO::BaseVectorRV< V, M >::m_pdf, QUESO::BaseVectorRV< V, M >::m_prefix, QUESO::BaseVectorRV< V, M >::m_realizer, QUESO::BaseVectorRV< V, M >::m_subCdf, QUESO::BaseVectorRV< V, M >::m_unifiedCdf, QUESO::BaseEnvironment::subDisplayFile(), UQ_FATAL_TEST_MACRO, and QUESO::BaseEnvironment::worldRank().

84  : BaseVectorRV<V, M>(((std::string)(prefix)+"invlogit_gau").c_str(),
85  imageBoxSubset)
86 {
87  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
88  *m_env.subDisplayFile() << "Entering InvLogitGaussianVectorRV<V,M>::constructor() [2]"
89  << ": prefix = " << m_prefix
90  << std::endl;
91  }
92 
93  m_pdf = new InvLogitGaussianJointPdf<V, M>(m_prefix.c_str(),
94  dynamic_cast<const BoxSubset<V, M> & >(m_imageSet),
95  lawExpVector, lawCovMatrix);
96 
97  M lowerCholLawCovMatrix(lawCovMatrix);
98  int iRC = lowerCholLawCovMatrix.chol();
99  lowerCholLawCovMatrix.zeroUpper(false);
100  if (iRC) {
101  std::cerr << "In InvLogitGaussianVectorRV<V,M>::constructor() [2]: chol failed, will use svd\n";
102  if (m_env.subDisplayFile()) {
103  *m_env.subDisplayFile() << "In InvLogitGaussianVectorRV<V,M>::constructor() [2]: chol failed; will use svd; lawCovMatrix contents are\n";
104  *m_env.subDisplayFile() << lawCovMatrix; // FIX ME: might demand parallelism
105  *m_env.subDisplayFile() << std::endl;
106  }
107  M matU (lawCovMatrix);
108  M matVt(m_imageSet.vectorSpace().zeroVector());
109  V vecS (m_imageSet.vectorSpace().zeroVector());
110  iRC = lawCovMatrix.svd(matU,vecS,matVt);
112  m_env.worldRank(),
113  "InvLogitGaussianVectorRV<V,M>::constructor() [2]",
114  "Cholesky decomposition of covariance matrix failed.");
115 
116  vecS.cwSqrt();
117  m_realizer = new InvLogitGaussianVectorRealizer<V,M>(m_prefix.c_str(),
118  dynamic_cast<const BoxSubset<V, M> & >(m_imageSet), lawExpVector, matU,
119  vecS, matVt);
120  }
121  else {
122  m_realizer = new InvLogitGaussianVectorRealizer<V, M>(m_prefix.c_str(),
123  dynamic_cast<const BoxSubset<V, M> & >(m_imageSet), lawExpVector, lowerCholLawCovMatrix);
124  }
125 
126  m_subCdf = NULL; // FIX ME: complete code
127  m_unifiedCdf = NULL; // FIX ME: complete code
128  m_mdf = NULL; // FIX ME: complete code
129 
130  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
131  *m_env.subDisplayFile() << "Leaving InvLogitGaussianVectorRV<V,M>::constructor() [2]"
132  << ": prefix = " << m_prefix
133  << std::endl;
134  }
135 }
const BaseVectorCdf< V, M > * m_unifiedCdf
Definition: VectorRV.h:118
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
const VectorSet< V, M > & m_imageSet
Definition: VectorRV.h:114
const BaseEnvironment & m_env
Definition: VectorRV.h:112
const BaseVectorCdf< V, M > * m_subCdf
Definition: VectorRV.h:117
BaseVectorRealizer< V, M > * m_realizer
Definition: VectorRV.h:116
unsigned int displayVerbosity() const
Definition: Environment.C:436
const BaseVectorMdf< V, M > * m_mdf
Definition: VectorRV.h:119
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
std::string m_prefix
Definition: VectorRV.h:113
BaseJointPdf< V, M > * m_pdf
Definition: VectorRV.h:115
template<class V , class M >
QUESO::InvLogitGaussianVectorRV< V, M >::~InvLogitGaussianVectorRV ( )
virtual

Virtual destructor.

Definition at line 138 of file InvLogitGaussianVectorRV.C.

139 {
140  delete m_mdf;
141  delete m_unifiedCdf;
142  delete m_subCdf;
143  delete m_realizer;
144  delete m_pdf;
145 }
const BaseVectorCdf< V, M > * m_unifiedCdf
Definition: VectorRV.h:118
const BaseVectorCdf< V, M > * m_subCdf
Definition: VectorRV.h:117
BaseVectorRealizer< V, M > * m_realizer
Definition: VectorRV.h:116
const BaseVectorMdf< V, M > * m_mdf
Definition: VectorRV.h:119
BaseJointPdf< V, M > * m_pdf
Definition: VectorRV.h:115

Member Function Documentation

template<class V , class M >
void QUESO::InvLogitGaussianVectorRV< V, M >::print ( std::ostream &  os) const
virtual

TODO: Prints the vector RV.

Todo:
: implement me!

Implements QUESO::BaseVectorRV< V, M >.

Definition at line 201 of file InvLogitGaussianVectorRV.C.

202 {
203  os << "InvLogitGaussianVectorRV<V,M>::print() says, 'Please implement me.'" << std::endl;
204  return;
205 }
template<class V , class M >
void QUESO::InvLogitGaussianVectorRV< V, M >::updateLawCovMatrix ( const M &  newLawCovMatrix)

Updates the covariance matrix.

This method tries to use Cholesky decomposition; and if it fails, the method then calls a SVD decomposition.

Definition at line 162 of file InvLogitGaussianVectorRV.C.

References UQ_FATAL_TEST_MACRO.

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

163 {
164  // We are sure that m_pdf (and m_realizer, etc) point to associated Gaussian
165  // classes, so all is well
166  (dynamic_cast<InvLogitGaussianJointPdf<V,M> * >(m_pdf))->updateLawCovMatrix(
167  newLawCovMatrix);
168 
169  M newLowerCholLawCovMatrix(newLawCovMatrix);
170  int iRC = newLowerCholLawCovMatrix.chol();
171  newLowerCholLawCovMatrix.zeroUpper(false);
172  if (iRC) {
173  std::cerr << "In InvLogitGaussianVectorRV<V,M>::updateLawCovMatrix(): chol failed, will use svd\n";
174  if (m_env.subDisplayFile()) {
175  *m_env.subDisplayFile() << "In InvLogitGaussianVectorRV<V,M>::updateLawCovMatrix(): chol failed; will use svd; newLawCovMatrix contents are\n";
176  *m_env.subDisplayFile() << newLawCovMatrix; // FIX ME: might demand parallelism
177  *m_env.subDisplayFile() << std::endl;
178  }
179  M matU (newLawCovMatrix);
180  M matVt(m_imageSet.vectorSpace().zeroVector());
181  V vecS (m_imageSet.vectorSpace().zeroVector());
182  iRC = newLawCovMatrix.svd(matU,vecS,matVt);
184  m_env.worldRank(),
185  "InvLogitGaussianVectorRV<V,M>::updateLawCovMatrix()",
186  "Cholesky decomposition of covariance matrix failed.");
187 
188  vecS.cwSqrt();
189  (dynamic_cast<InvLogitGaussianVectorRealizer<V, M> * >(m_realizer))->
190  updateLowerCholLawCovMatrix(matU, vecS, matVt);
191  }
192  else {
193  (dynamic_cast<InvLogitGaussianVectorRealizer<V, M> * >(m_realizer))->
194  updateLowerCholLawCovMatrix(newLowerCholLawCovMatrix);
195  }
196  return;
197 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
const VectorSet< V, M > & m_imageSet
Definition: VectorRV.h:114
const BaseEnvironment & m_env
Definition: VectorRV.h:112
BaseVectorRealizer< V, M > * m_realizer
Definition: VectorRV.h:116
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
BaseJointPdf< V, M > * m_pdf
Definition: VectorRV.h:115
template<class V , class M >
void QUESO::InvLogitGaussianVectorRV< V, M >::updateLawExpVector ( const V &  newLawExpVector)

Updates the vector that contains the mean values for the underlying Gaussian.

Definition at line 149 of file InvLogitGaussianVectorRV.C.

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

150 {
151  // We are sure that m_pdf (and m_realizer, etc) point to associated Gaussian
152  // classes, so all is well
153  (dynamic_cast<InvLogitGaussianJointPdf<V, M> * >(m_pdf))->updateLawExpVector(
154  newLawExpVector);
155  (dynamic_cast<InvLogitGaussianVectorRealizer<V, M> * >(m_realizer))->
156  updateLawExpVector(newLawExpVector);
157  return;
158 }
BaseVectorRealizer< V, M > * m_realizer
Definition: VectorRV.h:116
void updateLawExpVector(const V &newLawExpVector)
Updates the vector that contains the mean values for the underlying Gaussian.
BaseJointPdf< V, M > * m_pdf
Definition: VectorRV.h:115

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