25 #include <queso/TransformedScaledCovMatrixTKGroup.h> 
   26 #include <queso/InvLogitGaussianJointPdf.h> 
   27 #include <queso/GslVector.h> 
   28 #include <queso/GslMatrix.h> 
   32 template<
class V, 
class M>
 
   36     const std::vector<double> & scales,
 
   38   : 
BaseTKGroup<V, M>(prefix, boxSubset.vectorSpace(), scales),
 
   39     m_boxSubset(boxSubset),
 
   40     m_originalCovMatrix(covMatrix)
 
   49                            << 
": m_scales.size() = "                << 
m_scales.size()
 
   51                            << 
", m_rvs.size() = "                   << 
m_rvs.size()
 
   65 template<
class V, 
class M>
 
   70 template<
class V, 
class M>
 
   77 template<
class V, 
class M>
 
   87   queso_require_msg(m_preComputingPositions[stageId], 
"m_preComputingPositions[stageId] == NULL");
 
   89   if ((m_env.subDisplayFile()        ) &&
 
   90       (m_env.displayVerbosity() >= 10)) {
 
   91     *m_env.subDisplayFile() << 
"In TransformedScaledCovMatrixTKGroup<V,M>::rv1()" 
   92                             << 
", stageId = " << stageId
 
   93                             << 
": about to call m_rvs[0]->updateLawExpVector()" 
   94                             << 
", vector = " << *m_preComputingPositions[stageId] 
 
  101   V transformedPreComputingPositions(*m_preComputingPositions[stageId]);
 
  102   transformToGaussianSpace(*m_preComputingPositions[stageId],
 
  103       transformedPreComputingPositions);
 
  107   return (*invlogit_gaussian);
 
  110 template<
class V, 
class M>
 
  120   queso_require_msg(m_preComputingPositions[stageIds[0]], 
"m_preComputingPositions[stageIds[0]] == NULL");
 
  122   if ((m_env.subDisplayFile()        ) &&
 
  123       (m_env.displayVerbosity() >= 10)) {
 
  124     *m_env.subDisplayFile() << 
"In TransformedScaledCovMatrixTKGroup<V,M>::rv2()" 
  125                             << 
", stageIds.size() = " << stageIds.size()
 
  126                             << 
", stageIds[0] = "     << stageIds[0]
 
  127                             << 
": about to call m_rvs[stageIds.size()-1]->updateLawExpVector()" 
  128                             << 
", vector = " << *m_preComputingPositions[stageIds[0]] 
 
  135   V transformedPreComputingPositions(*m_preComputingPositions[stageIds[0]]);
 
  136   transformToGaussianSpace(*m_preComputingPositions[stageIds[0]],
 
  137       transformedPreComputingPositions);
 
  141   return (*invlogit_gaussian);
 
  144 template<
class V, 
class M>
 
  148   for (
unsigned int i = 0; i < m_scales.size(); ++i) {
 
  149     double factor = 1./m_scales[i]/m_scales[i];
 
  150     if ((m_env.subDisplayFile()        ) &&
 
  151         (m_env.displayVerbosity() >= 10)) {
 
  152       *m_env.subDisplayFile() << 
"In TransformedScaledCovMatrixTKGroup<V,M>::updateLawCovMatrix()" 
  153                               << 
", m_scales.size() = " << m_scales.size()
 
  155                               << 
", m_scales[i] = "     << m_scales[i]
 
  156                               << 
", factor = "          << factor
 
  157                               << 
": about to call m_rvs[i]->updateLawCovMatrix()" 
  158                               << 
", covMatrix = \n" << factor*covMatrix 
 
  172 template<
class V, 
class M>
 
  176   if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
 
  177     *m_env.subDisplayFile() << 
"Entering TransformedScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()" 
  178                            << 
": position = " << position
 
  179                            << 
", stageId = "  << stageId
 
  186   if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
 
  187     *m_env.subDisplayFile() << 
"In TransformedScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()" 
  188                            << 
", position = "        << position
 
  189                            << 
", stageId = "         << stageId
 
  190                            << 
": preComputingPos = " << *m_preComputingPositions[stageId];
 
  191     if (stageId < m_scales.size()) {
 
  192       *m_env.subDisplayFile() << 
", factor = " << 1./m_scales[stageId]/m_scales[stageId];
 
  194     if (stageId < m_rvs.size()) {
 
  196       *m_env.subDisplayFile() << 
", rvCov = " << pdfPtr->
lawCovMatrix(); 
 
  198     *m_env.subDisplayFile() << std::endl;
 
  201   if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
 
  202     *m_env.subDisplayFile() << 
"Leaving TransformedScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()" 
  203                            << 
": position = " << position
 
  204                            << 
", stageId = "  << stageId
 
  211 template<
class V, 
class M>
 
  221 template<
class V, 
class M>
 
  229   for (
unsigned int i = 0; i < m_scales.size(); ++i) {
 
  230     double factor = 1./m_scales[i]/m_scales[i];
 
  233         m_boxSubset, m_vectorSpace->zeroVector(),
 
  234         factor*m_originalCovMatrix);
 
  240 template<
class V, 
class M>
 
  248 template<
class V, 
class M>
 
  251     const V & physicalPoint, V & transformedPoint)
 const 
  253   V min_domain_bounds(this->m_boxSubset.minValues());
 
  254   V max_domain_bounds(this->m_boxSubset.maxValues());
 
  256   for (
unsigned int i = 0; i < transformedPoint.sizeLocal(); i++) {
 
  257     double min_val = min_domain_bounds[i];
 
  258     double max_val = max_domain_bounds[i];
 
  260     if (boost::math::isfinite(min_val) &&
 
  261         boost::math::isfinite(max_val)) {
 
  263         transformedPoint[i] = std::log(physicalPoint[i] - min_val) -
 
  264             std::log(max_val - physicalPoint[i]);
 
  266     else if (boost::math::isfinite(min_val) &&
 
  267              !boost::math::isfinite(max_val)) {
 
  270       transformedPoint[i] = std::log(physicalPoint[i] - min_val);
 
  272     else if (!boost::math::isfinite(min_val) &&
 
  273              boost::math::isfinite(max_val)) {
 
  276       transformedPoint[i] = -std::log(max_val - physicalPoint[i]);
 
  280       transformedPoint[i] = physicalPoint[i];
 
unsigned int displayVerbosity() const 
 
virtual void print(std::ostream &os) const 
TODO: Prints the transition kernel. 
 
const InvLogitGaussianVectorRV< V, M > & rv(unsigned int stageId) const 
InvLogitGaussian increment property to construct a transition kernel. 
 
void setRVsWithZeroMean()
Sets the mean of the underlying Gaussian RVs to zero. 
 
bool symmetric() const 
Whether or not the matrix is symmetric. Always 'false'. 
 
~TransformedScaledCovMatrixTKGroup()
Destructor. 
 
This base class allows the representation of a transition kernel. 
 
void clearPreComputingPositions()
Clears the pre-computing positions m_preComputingPositions[stageId]. 
 
void transformToGaussianSpace(const V &physicalPoint, V &transformedPoint) const 
 
A class representing a (transformed) Gaussian vector RV with bounds. 
 
#define queso_require_not_equal_to_msg(expr1, expr2, msg)
 
virtual bool setPreComputingPosition(const V &position, unsigned int stageId)
Sets the pre-computing positions m_preComputingPositions[stageId] with a new vector of size position...
 
#define queso_require_msg(asserted, msg)
 
void updateLawExpVector(const V &newLawExpVector)
Updates the vector that contains the mean values for the underlying Gaussian. 
 
#define queso_require_equal_to_msg(expr1, expr2, msg)
 
const BaseEnvironment & m_env
 
#define queso_require_greater_equal_msg(expr1, expr2, msg)
 
virtual void clearPreComputingPositions()
Clears the pre-computing positions m_preComputingPositions[stageId]. 
 
const M & lawCovMatrix() const 
Returns the covariance matrix; access to protected attribute m_lawCovMatrix. 
 
std::ofstream * subDisplayFile() const 
Access function for m_subDisplayFile (displays file on stream). 
 
This class represents a transition kernel with a scaled covariance matrix on hybrid bounded/unbounded...
 
std::vector< const V * > m_preComputingPositions
 
TransformedScaledCovMatrixTKGroup(const char *prefix, const BoxSubset< V, M > &boxSubset, const std::vector< double > &scales, const M &covMatrix)
Default constructor. 
 
void updateLawCovMatrix(const M &newLawCovMatrix)
Updates the covariance matrix. 
 
void print(std::ostream &os) const 
TODO: Prints the transition kernel. 
 
Class representing a subset of a vector space shaped like a hypercube. 
 
std::vector< BaseVectorRV< V, M > * > m_rvs
 
std::vector< double > m_scales
 
void updateLawCovMatrix(const M &covMatrix)
Scales the covariance matrix of the underlying Gaussian distribution. 
 
bool setPreComputingPosition(const V &position, unsigned int stageId)
Sets the pre-computing positions m_preComputingPositions[stageId] with a new vector of size position...
 
#define queso_require_greater_msg(expr1, expr2, msg)
 
A class for handling hybrid (transformed) Gaussians with bounds.