queso-0.53.0
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 = GslVector, class M = GslMatrix>
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 45 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_require_greater_msg, and QUESO::BaseEnvironment::subDisplayFile().

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  queso_require_greater_msg(lawVarVector.getMinValue(), 0.0, "Covariance matrix is not symmetric positive definite.");
50 
51  m_pdf = new InvLogitGaussianJointPdf<V,M>(m_prefix.c_str(),
52  dynamic_cast<const BoxSubset<V, M> & >(m_imageSet), lawExpVector,
53  lawVarVector);
54 
55  V cholDiag(lawVarVector);
56  cholDiag.cwSqrt();
57  M lowerCholLawCovMatrix(cholDiag);
58  lowerCholLawCovMatrix.zeroUpper(false);
59 
60  m_realizer = new InvLogitGaussianVectorRealizer<V,M>(m_prefix.c_str(),
61  dynamic_cast<const BoxSubset<V, M> & >(m_imageSet), lawExpVector,
62  lowerCholLawCovMatrix);
63 
64  m_subCdf = NULL; // FIX ME: complete code
65  m_unifiedCdf = NULL; // FIX ME: complete code
66  m_mdf = NULL; // FIX ME: complete code
67 
68  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
69  *m_env.subDisplayFile() << "Leaving InvLogitGaussianVectorRV<V,M>::constructor() [1]"
70  << ": prefix = " << m_prefix
71  << std::endl;
72  }
73 }
unsigned int displayVerbosity() const
Definition: Environment.C:396
const VectorSet< V, M > & m_imageSet
Definition: VectorRV.h:117
BaseJointPdf< V, M > * m_pdf
Definition: VectorRV.h:118
std::string m_prefix
Definition: VectorRV.h:116
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
const BaseVectorCdf< V, M > * m_unifiedCdf
Definition: VectorRV.h:121
const BaseEnvironment & m_env
Definition: VectorRV.h:115
const BaseVectorMdf< V, M > * m_mdf
Definition: VectorRV.h:122
#define queso_require_greater_msg(expr1, expr2, msg)
Definition: asserts.h:88
const BaseVectorCdf< V, M > * m_subCdf
Definition: VectorRV.h:120
BaseVectorRealizer< V, M > * m_realizer
Definition: VectorRV.h:119
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 76 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_require_msg, and QUESO::BaseEnvironment::subDisplayFile().

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

Virtual destructor.

Definition at line 132 of file InvLogitGaussianVectorRV.C.

133 {
134  delete m_mdf;
135  delete m_unifiedCdf;
136  delete m_subCdf;
137  delete m_realizer;
138  delete m_pdf;
139 }
BaseJointPdf< V, M > * m_pdf
Definition: VectorRV.h:118
const BaseVectorCdf< V, M > * m_unifiedCdf
Definition: VectorRV.h:121
const BaseVectorMdf< V, M > * m_mdf
Definition: VectorRV.h:122
const BaseVectorCdf< V, M > * m_subCdf
Definition: VectorRV.h:120
BaseVectorRealizer< V, M > * m_realizer
Definition: VectorRV.h:119

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 192 of file InvLogitGaussianVectorRV.C.

193 {
194  os << "InvLogitGaussianVectorRV<V,M>::print() says, 'Please implement me.'" << std::endl;
195  return;
196 }
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 156 of file InvLogitGaussianVectorRV.C.

References queso_require_msg.

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

157 {
158  // We are sure that m_pdf (and m_realizer, etc) point to associated Gaussian
159  // classes, so all is well
160  (dynamic_cast<InvLogitGaussianJointPdf<V,M> * >(m_pdf))->updateLawCovMatrix(
161  newLawCovMatrix);
162 
163  M newLowerCholLawCovMatrix(newLawCovMatrix);
164  int iRC = newLowerCholLawCovMatrix.chol();
165  newLowerCholLawCovMatrix.zeroUpper(false);
166  if (iRC) {
167  std::cerr << "In InvLogitGaussianVectorRV<V,M>::updateLawCovMatrix(): chol failed, will use svd\n";
168  if (m_env.subDisplayFile()) {
169  *m_env.subDisplayFile() << "In InvLogitGaussianVectorRV<V,M>::updateLawCovMatrix(): chol failed; will use svd; newLawCovMatrix contents are\n";
170  *m_env.subDisplayFile() << newLawCovMatrix; // FIX ME: might demand parallelism
171  *m_env.subDisplayFile() << std::endl;
172  }
173  M matU (newLawCovMatrix);
174  M matVt(m_imageSet.vectorSpace().zeroVector());
175  V vecS (m_imageSet.vectorSpace().zeroVector());
176  iRC = newLawCovMatrix.svd(matU,vecS,matVt);
177  queso_require_msg(!(iRC), "Cholesky decomposition of covariance matrix failed.");
178 
179  vecS.cwSqrt();
180  (dynamic_cast<InvLogitGaussianVectorRealizer<V, M> * >(m_realizer))->
181  updateLowerCholLawCovMatrix(matU, vecS, matVt);
182  }
183  else {
184  (dynamic_cast<InvLogitGaussianVectorRealizer<V, M> * >(m_realizer))->
185  updateLowerCholLawCovMatrix(newLowerCholLawCovMatrix);
186  }
187  return;
188 }
const VectorSet< V, M > & m_imageSet
Definition: VectorRV.h:117
BaseJointPdf< V, M > * m_pdf
Definition: VectorRV.h:118
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
const BaseEnvironment & m_env
Definition: VectorRV.h:115
BaseVectorRealizer< V, M > * m_realizer
Definition: VectorRV.h:119
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 143 of file InvLogitGaussianVectorRV.C.

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

144 {
145  // We are sure that m_pdf (and m_realizer, etc) point to associated Gaussian
146  // classes, so all is well
147  (dynamic_cast<InvLogitGaussianJointPdf<V, M> * >(m_pdf))->updateLawExpVector(
148  newLawExpVector);
149  (dynamic_cast<InvLogitGaussianVectorRealizer<V, M> * >(m_realizer))->
150  updateLawExpVector(newLawExpVector);
151  return;
152 }
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:118
BaseVectorRealizer< V, M > * m_realizer
Definition: VectorRV.h:119

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