25 #include <queso/InvLogitGaussianVectorRV.h>
26 #include <queso/InvLogitGaussianVectorRealizer.h>
27 #include <queso/InvLogitGaussianJointPdf.h>
28 #include <queso/GslVector.h>
29 #include <queso/GslMatrix.h>
34 template<
class V,
class M>
38 const V & lawExpVector,
39 const V & lawVarVector)
40 :
BaseVectorRV<V, M>(((std::string)(prefix)+
"invlogit_gau").c_str(),
49 queso_require_greater_msg(lawVarVector.getMinValue(), 0.0,
"Covariance matrix is not symmetric positive definite.");
55 V cholDiag(lawVarVector);
57 M lowerCholLawCovMatrix(cholDiag);
58 lowerCholLawCovMatrix.zeroUpper(
false);
62 lowerCholLawCovMatrix);
75 template<
class V,
class M>
79 const V & lawExpVector,
80 const M & lawCovMatrix)
81 :
BaseVectorRV<V, M>(((std::string)(prefix)+
"invlogit_gau").c_str(),
92 lawExpVector, lawCovMatrix);
94 M lowerCholLawCovMatrix(lawCovMatrix);
95 int iRC = lowerCholLawCovMatrix.chol();
96 lowerCholLawCovMatrix.zeroUpper(
false);
98 std::cerr <<
"In InvLogitGaussianVectorRV<V,M>::constructor() [2]: chol failed, will use svd\n";
100 *
m_env.
subDisplayFile() <<
"In InvLogitGaussianVectorRV<V,M>::constructor() [2]: chol failed; will use svd; lawCovMatrix contents are\n";
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.");
131 template<
class V,
class M>
141 template<
class V,
class M>
150 updateLawExpVector(newLawExpVector);
154 template<
class V,
class M>
163 M newLowerCholLawCovMatrix(newLawCovMatrix);
164 int iRC = newLowerCholLawCovMatrix.chol();
165 newLowerCholLawCovMatrix.zeroUpper(
false);
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;
171 *m_env.subDisplayFile() << std::endl;
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.");
181 updateLowerCholLawCovMatrix(matU, vecS, matVt);
185 updateLowerCholLawCovMatrix(newLowerCholLawCovMatrix);
190 template <
class V,
class M>
194 os <<
"InvLogitGaussianVectorRV<V,M>::print() says, 'Please implement me.'" << std::endl;
void print(std::ostream &os) const
TODO: Prints the vector RV.
A class representing a (transformed) Gaussian vector RV with bounds.
InvLogitGaussianVectorRV(const char *prefix, const BoxSubset< V, M > &imageBoxSubset, const V &lawExpVector, const V &lawVarVector)
Constructor.
const BaseVectorCdf< V, M > * m_unifiedCdf
void updateLawCovMatrix(const M &newLawCovMatrix)
Updates the covariance matrix.
const BaseEnvironment & m_env
A class for handling sampling from (transformed) Gaussian probability density distributions with boun...
BaseVectorRealizer< V, M > * m_realizer
Class representing a subset of a vector space shaped like a hypercube.
virtual ~InvLogitGaussianVectorRV()
Virtual destructor.
A class for handling hybrid (transformed) Gaussians with bounds.
BaseJointPdf< V, M > * m_pdf
A templated base class for handling vector RV.
const BaseVectorCdf< V, M > * m_subCdf
unsigned int displayVerbosity() const
const VectorSet< V, M > & m_imageSet
const BaseVectorMdf< V, M > * m_mdf
void updateLawExpVector(const V &newLawExpVector)
Updates the vector that contains the mean values for the underlying Gaussian.
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).