queso-0.53.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
QUESO::TransformedScaledCovMatrixTKGroup< V, M > Class Template Reference

This class represents a transition kernel with a scaled covariance matrix on hybrid bounded/unbounded state spaces. More...

#include <TransformedScaledCovMatrixTKGroup.h>

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

Public Member Functions

void transformToGaussianSpace (const V &physicalPoint, V &transformedPoint) const
 
Constructor/Destructor methods
 TransformedScaledCovMatrixTKGroup (const char *prefix, const BoxSubset< V, M > &boxSubset, const std::vector< double > &scales, const M &covMatrix)
 Default constructor. More...
 
 ~TransformedScaledCovMatrixTKGroup ()
 Destructor. More...
 
Statistical/Mathematical methods
bool symmetric () const
 Whether or not the matrix is symmetric. Always 'false'. More...
 
const InvLogitGaussianVectorRV
< V, M > & 
rv (unsigned int stageId) const
 InvLogitGaussian increment property to construct a transition kernel. More...
 
const InvLogitGaussianVectorRV
< V, M > & 
rv (const std::vector< unsigned int > &stageIds)
 InvLogitGaussian increment property to construct a transition kernel. More...
 
void updateLawCovMatrix (const M &covMatrix)
 Scales the covariance matrix of the underlying Gaussian distribution. More...
 
Misc methods
bool setPreComputingPosition (const V &position, unsigned int stageId)
 Sets the pre-computing positions m_preComputingPositions[stageId] with a new vector of size position. More...
 
void clearPreComputingPositions ()
 Clears the pre-computing positions m_preComputingPositions[stageId]. More...
 
I/O methods
void print (std::ostream &os) const
 TODO: Prints the transition kernel. More...
 
- Public Member Functions inherited from QUESO::BaseTKGroup< V, M >
 BaseTKGroup ()
 Default constructor. More...
 
 BaseTKGroup (const char *prefix, const VectorSpace< V, M > &vectorSpace, const std::vector< double > &scales)
 Constructor. More...
 
virtual ~BaseTKGroup ()
 Destructor. More...
 
const BaseEnvironmentenv () const
 QUESO's environment. More...
 
const V & preComputingPosition (unsigned int stageId) const
 Pre-computing position; access to protected attribute *m_preComputingPositions[stageId]. More...
 

Private Member Functions

void setRVsWithZeroMean ()
 Sets the mean of the underlying Gaussian RVs to zero. More...
 

Private Attributes

const BoxSubset< V, M > & m_boxSubset
 
m_originalCovMatrix
 

Additional Inherited Members

- Protected Attributes inherited from QUESO::BaseTKGroup< V, M >
const EmptyEnvironmentm_emptyEnv
 
const BaseEnvironmentm_env
 
std::string m_prefix
 
const VectorSpace< V, M > * m_vectorSpace
 
std::vector< double > m_scales
 
std::vector< const V * > m_preComputingPositions
 
std::vector< BaseVectorRV< V,
M > * > 
m_rvs
 

Detailed Description

template<class V = GslVector, class M = GslMatrix>
class QUESO::TransformedScaledCovMatrixTKGroup< V, M >

This class represents a transition kernel with a scaled covariance matrix on hybrid bounded/unbounded state spaces.

The unbounded directions utilise a standard Gaussian proposal. The bounded or half-bounded directions utilise a transformed Gaussian proposal, so that no realizations are generated outside of the state space.

Definition at line 48 of file TransformedScaledCovMatrixTKGroup.h.

Constructor & Destructor Documentation

template<class V , class M >
QUESO::TransformedScaledCovMatrixTKGroup< V, M >::TransformedScaledCovMatrixTKGroup ( const char *  prefix,
const BoxSubset< V, M > &  boxSubset,
const std::vector< double > &  scales,
const M &  covMatrix 
)

Default constructor.

Definition at line 33 of file TransformedScaledCovMatrixTKGroup.C.

References QUESO::BaseEnvironment::displayVerbosity(), QUESO::BaseTKGroup< V, M >::m_env, QUESO::TransformedScaledCovMatrixTKGroup< V, M >::m_originalCovMatrix, QUESO::BaseTKGroup< V, M >::m_preComputingPositions, QUESO::BaseTKGroup< V, M >::m_rvs, QUESO::BaseTKGroup< V, M >::m_scales, QUESO::TransformedScaledCovMatrixTKGroup< V, M >::setRVsWithZeroMean(), and QUESO::BaseEnvironment::subDisplayFile().

38  : BaseTKGroup<V, M>(prefix, boxSubset.vectorSpace(), scales),
39  m_boxSubset(boxSubset),
40  m_originalCovMatrix(covMatrix)
41 {
42  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
43  *m_env.subDisplayFile() << "Entering TransformedScaledCovMatrixTKGroup<V,M>::constructor()"
44  << std::endl;
45  }
46 
47  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
48  *m_env.subDisplayFile() << "In TransformedScaledCovMatrixTKGroup<V,M>::constructor()"
49  << ": m_scales.size() = " << m_scales.size()
50  << ", m_preComputingPositions.size() = " << m_preComputingPositions.size()
51  << ", m_rvs.size() = " << m_rvs.size()
52  << ", m_originalCovMatrix = " << m_originalCovMatrix
53  << std::endl;
54  }
55 
56  // Set RVs to have zero mean in the Gaussian space
58 
59  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
60  *m_env.subDisplayFile() << "Leaving TransformedScaledCovMatrixTKGroup<V,M>::constructor()"
61  << std::endl;
62  }
63 }
unsigned int displayVerbosity() const
Definition: Environment.C:396
void setRVsWithZeroMean()
Sets the mean of the underlying Gaussian RVs to zero.
const BaseEnvironment & m_env
Definition: TKGroup.h:100
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
std::vector< const V * > m_preComputingPositions
Definition: TKGroup.h:104
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:105
std::vector< double > m_scales
Definition: TKGroup.h:103

Destructor.

Definition at line 66 of file TransformedScaledCovMatrixTKGroup.C.

67 {
68 }

Member Function Documentation

template<class V , class M >
void QUESO::TransformedScaledCovMatrixTKGroup< V, M >::clearPreComputingPositions ( )
virtual

Clears the pre-computing positions m_preComputingPositions[stageId].

Reimplemented from QUESO::BaseTKGroup< V, M >.

Definition at line 213 of file TransformedScaledCovMatrixTKGroup.C.

References QUESO::BaseTKGroup< V, M >::clearPreComputingPositions().

214 {
216  return;
217 }
virtual void clearPreComputingPositions()
Clears the pre-computing positions m_preComputingPositions[stageId].
Definition: TKGroup.C:109
template<class V , class M >
void QUESO::TransformedScaledCovMatrixTKGroup< V, M >::print ( std::ostream &  os) const
virtual

TODO: Prints the transition kernel.

Todo:
: implement me!

Reimplemented from QUESO::BaseTKGroup< V, M >.

Definition at line 242 of file TransformedScaledCovMatrixTKGroup.C.

References QUESO::BaseTKGroup< V, M >::print().

243 {
245  return;
246 }
virtual void print(std::ostream &os) const
TODO: Prints the transition kernel.
Definition: TKGroup.C:123
template<class V , class M >
const InvLogitGaussianVectorRV< V, M > & QUESO::TransformedScaledCovMatrixTKGroup< V, M >::rv ( unsigned int  stageId) const
virtual

InvLogitGaussian increment property to construct a transition kernel.

Implements QUESO::BaseTKGroup< V, M >.

Definition at line 79 of file TransformedScaledCovMatrixTKGroup.C.

References queso_require_greater_msg, queso_require_msg, queso_require_not_equal_to_msg, and QUESO::InvLogitGaussianVectorRV< V, M >::updateLawExpVector().

80 {
81  queso_require_not_equal_to_msg(m_rvs.size(), 0, "m_rvs.size() = 0");
82 
83  queso_require_msg(m_rvs[0], "m_rvs[0] == NULL");
84 
85  queso_require_greater_msg(m_preComputingPositions.size(), stageId, "m_preComputingPositions.size() <= stageId");
86 
87  queso_require_msg(m_preComputingPositions[stageId], "m_preComputingPositions[stageId] == NULL");
88 
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] // FIX ME: might demand parallelism
95  << std::endl;
96  }
97 
98  InvLogitGaussianVectorRV<V, M> * invlogit_gaussian =
99  dynamic_cast<InvLogitGaussianVectorRV<V, M> * >(m_rvs[0]);
100 
101  V transformedPreComputingPositions(*m_preComputingPositions[stageId]);
103  transformedPreComputingPositions);
104 
105  invlogit_gaussian->updateLawExpVector(transformedPreComputingPositions);
106 
107  return (*invlogit_gaussian);
108 }
unsigned int displayVerbosity() const
Definition: Environment.C:396
#define queso_require_not_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:86
const BaseEnvironment & m_env
Definition: TKGroup.h:100
#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
std::vector< const V * > m_preComputingPositions
Definition: TKGroup.h:104
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:105
void transformToGaussianSpace(const V &physicalPoint, V &transformedPoint) const
#define queso_require_greater_msg(expr1, expr2, msg)
Definition: asserts.h:88
template<class V , class M >
const InvLogitGaussianVectorRV< V, M > & QUESO::TransformedScaledCovMatrixTKGroup< V, M >::rv ( const std::vector< unsigned int > &  stageIds)
virtual

InvLogitGaussian increment property to construct a transition kernel.

Implements QUESO::BaseTKGroup< V, M >.

Definition at line 112 of file TransformedScaledCovMatrixTKGroup.C.

References queso_require_greater_equal_msg, queso_require_greater_msg, queso_require_msg, and QUESO::InvLogitGaussianVectorRV< V, M >::updateLawExpVector().

113 {
114  queso_require_greater_equal_msg(m_rvs.size(), stageIds.size(), "m_rvs.size() < stageIds.size()");
115 
116  queso_require_msg(m_rvs[stageIds.size()-1], "m_rvs[stageIds.size()-1] == NULL");
117 
118  queso_require_greater_msg(m_preComputingPositions.size(), stageIds[0], "m_preComputingPositions.size() <= stageIds[0]");
119 
120  queso_require_msg(m_preComputingPositions[stageIds[0]], "m_preComputingPositions[stageIds[0]] == NULL");
121 
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]] // FIX ME: might demand parallelism
129  << std::endl;
130  }
131 
132  InvLogitGaussianVectorRV<V, M> * invlogit_gaussian =
133  dynamic_cast<InvLogitGaussianVectorRV<V, M> * >(m_rvs[stageIds.size()-1]);
134 
135  V transformedPreComputingPositions(*m_preComputingPositions[stageIds[0]]);
137  transformedPreComputingPositions);
138 
139  invlogit_gaussian->updateLawExpVector(transformedPreComputingPositions);
140 
141  return (*invlogit_gaussian);
142 }
unsigned int displayVerbosity() const
Definition: Environment.C:396
const BaseEnvironment & m_env
Definition: TKGroup.h:100
#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
std::vector< const V * > m_preComputingPositions
Definition: TKGroup.h:104
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:105
#define queso_require_greater_equal_msg(expr1, expr2, msg)
Definition: asserts.h:90
void transformToGaussianSpace(const V &physicalPoint, V &transformedPoint) const
#define queso_require_greater_msg(expr1, expr2, msg)
Definition: asserts.h:88
template<class V , class M >
bool QUESO::TransformedScaledCovMatrixTKGroup< V, M >::setPreComputingPosition ( const V &  position,
unsigned int  stageId 
)
virtual

Sets the pre-computing positions m_preComputingPositions[stageId] with a new vector of size position.

The vector position is in physical space. This is then transformed using transformToGaussianSpace to map to a point in Gaussian space where we can, for example, update the mean of the underlying Gaussian RV.

Reimplemented from QUESO::BaseTKGroup< V, M >.

Definition at line 174 of file TransformedScaledCovMatrixTKGroup.C.

References QUESO::InvLogitGaussianJointPdf< V, M >::lawCovMatrix(), and QUESO::BaseTKGroup< V, M >::setPreComputingPosition().

175 {
176  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
177  *m_env.subDisplayFile() << "Entering TransformedScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()"
178  << ": position = " << position
179  << ", stageId = " << stageId
180  << std::endl;
181  }
182 
184  //setRVsWithZeroMean();
185 
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];
193  }
194  if (stageId < m_rvs.size()) {
195  const InvLogitGaussianJointPdf<V,M>* pdfPtr = dynamic_cast< const InvLogitGaussianJointPdf<V,M>* >(&(m_rvs[stageId]->pdf()));
196  *m_env.subDisplayFile() << ", rvCov = " << pdfPtr->lawCovMatrix(); // FIX ME: might demand parallelism
197  }
198  *m_env.subDisplayFile() << std::endl;
199  }
200 
201  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
202  *m_env.subDisplayFile() << "Leaving TransformedScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()"
203  << ": position = " << position
204  << ", stageId = " << stageId
205  << std::endl;
206  }
207 
208  return true;
209 }
unsigned int displayVerbosity() const
Definition: Environment.C:396
virtual bool setPreComputingPosition(const V &position, unsigned int stageId)
Sets the pre-computing positions m_preComputingPositions[stageId] with a new vector of size position...
Definition: TKGroup.C:96
const BaseEnvironment & m_env
Definition: TKGroup.h:100
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
std::vector< const V * > m_preComputingPositions
Definition: TKGroup.h:104
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:105
std::vector< double > m_scales
Definition: TKGroup.h:103
template<class V , class M >
void QUESO::TransformedScaledCovMatrixTKGroup< V, M >::setRVsWithZeroMean ( )
private

Sets the mean of the underlying Gaussian RVs to zero.

Definition at line 223 of file TransformedScaledCovMatrixTKGroup.C.

References queso_require_equal_to_msg, queso_require_msg, and queso_require_not_equal_to_msg.

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

224 {
225  queso_require_not_equal_to_msg(m_rvs.size(), 0, "m_rvs.size() = 0");
226 
227  queso_require_equal_to_msg(m_rvs.size(), m_scales.size(), "m_rvs.size() != m_scales.size()");
228 
229  for (unsigned int i = 0; i < m_scales.size(); ++i) {
230  double factor = 1./m_scales[i]/m_scales[i];
231  queso_require_msg(!(m_rvs[i]), "m_rvs[i] != NULL");
232  m_rvs[i] = new InvLogitGaussianVectorRV<V,M>(m_prefix.c_str(),
233  m_boxSubset, m_vectorSpace->zeroVector(),
234  factor*m_originalCovMatrix);
235  }
236 
237  return;
238 }
#define queso_require_not_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:86
const VectorSpace< V, M > * m_vectorSpace
Definition: TKGroup.h:102
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:105
std::vector< double > m_scales
Definition: TKGroup.h:103
std::string m_prefix
Definition: TKGroup.h:101
template<class V , class M >
bool QUESO::TransformedScaledCovMatrixTKGroup< V, M >::symmetric ( ) const
virtual

Whether or not the matrix is symmetric. Always 'false'.

Implements QUESO::BaseTKGroup< V, M >.

Definition at line 72 of file TransformedScaledCovMatrixTKGroup.C.

73 {
74  return false;
75 }
template<class V , class M >
void QUESO::TransformedScaledCovMatrixTKGroup< V, M >::transformToGaussianSpace ( const V &  physicalPoint,
V &  transformedPoint 
) const

Definition at line 250 of file TransformedScaledCovMatrixTKGroup.C.

252 {
253  V min_domain_bounds(this->m_boxSubset.minValues());
254  V max_domain_bounds(this->m_boxSubset.maxValues());
255 
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];
259 
260  if (boost::math::isfinite(min_val) &&
261  boost::math::isfinite(max_val)) {
262  // Left- and right-hand sides are finite. Do full transform.
263  transformedPoint[i] = std::log(physicalPoint[i] - min_val) -
264  std::log(max_val - physicalPoint[i]);
265  }
266  else if (boost::math::isfinite(min_val) &&
267  !boost::math::isfinite(max_val)) {
268  // Left-hand side finite, but right-hand side is not.
269  // Do only left-hand transform.
270  transformedPoint[i] = std::log(physicalPoint[i] - min_val);
271  }
272  else if (!boost::math::isfinite(min_val) &&
273  boost::math::isfinite(max_val)) {
274  // Right-hand side is finite, but left-hand side is not.
275  // Do only right-hand transform.
276  transformedPoint[i] = -std::log(max_val - physicalPoint[i]);
277  }
278  else {
279  // No transform.
280  transformedPoint[i] = physicalPoint[i];
281  }
282  }
283 }
template<class V , class M >
void QUESO::TransformedScaledCovMatrixTKGroup< V, M >::updateLawCovMatrix ( const M &  covMatrix)

Scales the covariance matrix of the underlying Gaussian distribution.

The covariance matrix is scaled by a factor of $ 1/scales^2 $.

Definition at line 146 of file TransformedScaledCovMatrixTKGroup.C.

References QUESO::InvLogitGaussianVectorRV< V, M >::updateLawCovMatrix().

147 {
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()
154  << ", i = " << i
155  << ", m_scales[i] = " << m_scales[i]
156  << ", factor = " << factor
157  << ": about to call m_rvs[i]->updateLawCovMatrix()"
158  << ", covMatrix = \n" << factor*covMatrix // FIX ME: might demand parallelism
159  << std::endl;
160  }
161 
162  InvLogitGaussianVectorRV<V, M> * invlogit_gaussian =
163  dynamic_cast<InvLogitGaussianVectorRV<V, M> * >(m_rvs[i]);
164 
165  invlogit_gaussian->updateLawCovMatrix(factor*covMatrix);
166  }
167 
168  return;
169 }
unsigned int displayVerbosity() const
Definition: Environment.C:396
const BaseEnvironment & m_env
Definition: TKGroup.h:100
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:105
std::vector< double > m_scales
Definition: TKGroup.h:103

Member Data Documentation

template<class V = GslVector, class M = GslMatrix>
const BoxSubset<V, M>& QUESO::TransformedScaledCovMatrixTKGroup< V, M >::m_boxSubset
private

Definition at line 116 of file TransformedScaledCovMatrixTKGroup.h.

template<class V = GslVector, class M = GslMatrix>
M QUESO::TransformedScaledCovMatrixTKGroup< V, M >::m_originalCovMatrix
private

The documentation for this class was generated from the following files:

Generated on Thu Jun 11 2015 13:52:36 for queso-0.53.0 by  doxygen 1.8.5