queso-0.51.1
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, class M>
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 45 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 }
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:104
std::vector< double > m_scales
Definition: TKGroup.h:102
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
const BaseEnvironment & m_env
Definition: TKGroup.h:99
void setRVsWithZeroMean()
Sets the mean of the underlying Gaussian RVs to zero.
unsigned int displayVerbosity() const
Definition: Environment.C:436
std::vector< const V * > m_preComputingPositions
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 237 of file TransformedScaledCovMatrixTKGroup.C.

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

238 {
240  return;
241 }
virtual void clearPreComputingPositions()
Clears the pre-computing positions m_preComputingPositions[stageId].
Definition: TKGroup.C:121
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 275 of file TransformedScaledCovMatrixTKGroup.C.

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

276 {
278  return;
279 }
virtual void print(std::ostream &os) const
TODO: Prints the transition kernel.
Definition: TKGroup.C:135
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::InvLogitGaussianVectorRV< V, M >::updateLawExpVector(), and UQ_FATAL_TEST_MACRO.

80 {
81  UQ_FATAL_TEST_MACRO(m_rvs.size() == 0,
82  m_env.worldRank(),
83  "TransformedScaledCovMatrixTKGroup<V,M>::rv1()",
84  "m_rvs.size() = 0");
85 
86  UQ_FATAL_TEST_MACRO(m_rvs[0] == NULL, // Yes, '0', because that is the id used below
87  m_env.worldRank(),
88  "TransformedScaledCovMatrixTKGroup<V,M>::rv1()",
89  "m_rvs[0] == NULL");
90 
92  m_env.worldRank(),
93  "TransformedScaledCovMatrixTKGroup<V,M>::rv1()",
94  "m_preComputingPositions.size() <= stageId");
95 
97  m_env.worldRank(),
98  "TransformedScaledCovMatrixTKGroup<V,M>::rv1()",
99  "m_preComputingPositions[stageId] == NULL");
100 
101  if ((m_env.subDisplayFile() ) &&
102  (m_env.displayVerbosity() >= 10)) {
103  *m_env.subDisplayFile() << "In TransformedScaledCovMatrixTKGroup<V,M>::rv1()"
104  << ", stageId = " << stageId
105  << ": about to call m_rvs[0]->updateLawExpVector()"
106  << ", vector = " << *m_preComputingPositions[stageId] // FIX ME: might demand parallelism
107  << std::endl;
108  }
109 
110  InvLogitGaussianVectorRV<V, M> * invlogit_gaussian =
111  dynamic_cast<InvLogitGaussianVectorRV<V, M> * >(m_rvs[0]);
112 
113  V transformedPreComputingPositions(*m_preComputingPositions[stageId]);
115  transformedPreComputingPositions);
116 
117  invlogit_gaussian->updateLawExpVector(transformedPreComputingPositions);
118 
119  return (*invlogit_gaussian);
120 }
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:104
void transformToGaussianSpace(const V &physicalPoint, V &transformedPoint) const
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 BaseEnvironment & m_env
Definition: TKGroup.h:99
unsigned int displayVerbosity() const
Definition: Environment.C:436
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
std::vector< const V * > m_preComputingPositions
Definition: TKGroup.h:103
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 124 of file TransformedScaledCovMatrixTKGroup.C.

References QUESO::InvLogitGaussianVectorRV< V, M >::updateLawExpVector(), and UQ_FATAL_TEST_MACRO.

125 {
126  UQ_FATAL_TEST_MACRO(m_rvs.size() < stageIds.size(),
127  m_env.worldRank(),
128  "TransformedScaledCovMatrixTKGroup<V,M>::rv2()",
129  "m_rvs.size() < stageIds.size()");
130 
131  UQ_FATAL_TEST_MACRO(m_rvs[stageIds.size()-1] == NULL,
132  m_env.worldRank(),
133  "TransformedScaledCovMatrixTKGroup<V,M>::rv2()",
134  "m_rvs[stageIds.size()-1] == NULL");
135 
136  UQ_FATAL_TEST_MACRO(m_preComputingPositions.size() <= stageIds[0],
137  m_env.worldRank(),
138  "TransformedScaledCovMatrixTKGroup<V,M>::rv2()",
139  "m_preComputingPositions.size() <= stageIds[0]");
140 
141  UQ_FATAL_TEST_MACRO(m_preComputingPositions[stageIds[0]] == NULL,
142  m_env.worldRank(),
143  "TransformedScaledCovMatrixTKGroup<V,M>::rv2()",
144  "m_preComputingPositions[stageIds[0]] == NULL");
145 
146  if ((m_env.subDisplayFile() ) &&
147  (m_env.displayVerbosity() >= 10)) {
148  *m_env.subDisplayFile() << "In TransformedScaledCovMatrixTKGroup<V,M>::rv2()"
149  << ", stageIds.size() = " << stageIds.size()
150  << ", stageIds[0] = " << stageIds[0]
151  << ": about to call m_rvs[stageIds.size()-1]->updateLawExpVector()"
152  << ", vector = " << *m_preComputingPositions[stageIds[0]] // FIX ME: might demand parallelism
153  << std::endl;
154  }
155 
156  InvLogitGaussianVectorRV<V, M> * invlogit_gaussian =
157  dynamic_cast<InvLogitGaussianVectorRV<V, M> * >(m_rvs[stageIds.size()-1]);
158 
159  V transformedPreComputingPositions(*m_preComputingPositions[stageIds[0]]);
161  transformedPreComputingPositions);
162 
163  invlogit_gaussian->updateLawExpVector(transformedPreComputingPositions);
164 
165  return (*invlogit_gaussian);
166 }
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:104
void transformToGaussianSpace(const V &physicalPoint, V &transformedPoint) const
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 BaseEnvironment & m_env
Definition: TKGroup.h:99
unsigned int displayVerbosity() const
Definition: Environment.C:436
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
std::vector< const V * > m_preComputingPositions
Definition: TKGroup.h:103
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 198 of file TransformedScaledCovMatrixTKGroup.C.

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

199 {
200  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
201  *m_env.subDisplayFile() << "Entering TransformedScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()"
202  << ": position = " << position
203  << ", stageId = " << stageId
204  << std::endl;
205  }
206 
208  //setRVsWithZeroMean();
209 
210  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
211  *m_env.subDisplayFile() << "In TransformedScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()"
212  << ", position = " << position
213  << ", stageId = " << stageId
214  << ": preComputingPos = " << *m_preComputingPositions[stageId];
215  if (stageId < m_scales.size()) {
216  *m_env.subDisplayFile() << ", factor = " << 1./m_scales[stageId]/m_scales[stageId];
217  }
218  if (stageId < m_rvs.size()) {
219  const InvLogitGaussianJointPdf<V,M>* pdfPtr = dynamic_cast< const InvLogitGaussianJointPdf<V,M>* >(&(m_rvs[stageId]->pdf()));
220  *m_env.subDisplayFile() << ", rvCov = " << pdfPtr->lawCovMatrix(); // FIX ME: might demand parallelism
221  }
222  *m_env.subDisplayFile() << std::endl;
223  }
224 
225  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
226  *m_env.subDisplayFile() << "Leaving TransformedScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()"
227  << ": position = " << position
228  << ", stageId = " << stageId
229  << std::endl;
230  }
231 
232  return true;
233 }
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:104
std::vector< double > m_scales
Definition: TKGroup.h:102
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
const BaseEnvironment & m_env
Definition: TKGroup.h:99
unsigned int displayVerbosity() const
Definition: Environment.C:436
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:102
std::vector< const V * > m_preComputingPositions
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 247 of file TransformedScaledCovMatrixTKGroup.C.

References UQ_FATAL_TEST_MACRO.

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

248 {
249  UQ_FATAL_TEST_MACRO(m_rvs.size() == 0,
250  m_env.worldRank(),
251  "TransformedScaledCovMatrixTKGroup<V,M>::setRVsWithZeroMean()",
252  "m_rvs.size() = 0");
253 
254  UQ_FATAL_TEST_MACRO(m_rvs.size() != m_scales.size(),
255  m_env.worldRank(),
256  "TransformedScaledCovMatrixTKGroup<V,M>::setRVsWithZeroMean()",
257  "m_rvs.size() != m_scales.size()");
258 
259  for (unsigned int i = 0; i < m_scales.size(); ++i) {
260  double factor = 1./m_scales[i]/m_scales[i];
261  UQ_FATAL_TEST_MACRO(m_rvs[i] != NULL,
262  m_env.worldRank(),
263  "TransformedScaledCovMatrixTKGroup<V,M>::setRVsWithZeroMean()",
264  "m_rvs[i] != NULL");
265  m_rvs[i] = new InvLogitGaussianVectorRV<V,M>(m_prefix.c_str(),
266  m_boxSubset, m_vectorSpace->zeroVector(),
267  factor*m_originalCovMatrix);
268  }
269 
270  return;
271 }
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:104
std::vector< double > m_scales
Definition: TKGroup.h:102
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
const VectorSpace< V, M > * m_vectorSpace
Definition: TKGroup.h:101
const BaseEnvironment & m_env
Definition: TKGroup.h:99
std::string m_prefix
Definition: TKGroup.h:100
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
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 283 of file TransformedScaledCovMatrixTKGroup.C.

285 {
286  V min_domain_bounds(this->m_boxSubset.minValues());
287  V max_domain_bounds(this->m_boxSubset.maxValues());
288 
289  for (unsigned int i = 0; i < transformedPoint.sizeLocal(); i++) {
290  double min_val = min_domain_bounds[i];
291  double max_val = max_domain_bounds[i];
292 
293  if (boost::math::isfinite(min_val) &&
294  boost::math::isfinite(max_val)) {
295  // Left- and right-hand sides are finite. Do full transform.
296  transformedPoint[i] = std::log(physicalPoint[i] - min_val) -
297  std::log(max_val - physicalPoint[i]);
298  }
299  else if (boost::math::isfinite(min_val) &&
300  !boost::math::isfinite(max_val)) {
301  // Left-hand side finite, but right-hand side is not.
302  // Do only left-hand transform.
303  transformedPoint[i] = std::log(physicalPoint[i] - min_val);
304  }
305  else if (!boost::math::isfinite(min_val) &&
306  boost::math::isfinite(max_val)) {
307  // Right-hand side is finite, but left-hand side is not.
308  // Do only right-hand transform.
309  transformedPoint[i] = -std::log(max_val - physicalPoint[i]);
310  }
311  else {
312  // No transform.
313  transformedPoint[i] = physicalPoint[i];
314  }
315  }
316 }
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 170 of file TransformedScaledCovMatrixTKGroup.C.

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

171 {
172  for (unsigned int i = 0; i < m_scales.size(); ++i) {
173  double factor = 1./m_scales[i]/m_scales[i];
174  if ((m_env.subDisplayFile() ) &&
175  (m_env.displayVerbosity() >= 10)) {
176  *m_env.subDisplayFile() << "In TransformedScaledCovMatrixTKGroup<V,M>::updateLawCovMatrix()"
177  << ", m_scales.size() = " << m_scales.size()
178  << ", i = " << i
179  << ", m_scales[i] = " << m_scales[i]
180  << ", factor = " << factor
181  << ": about to call m_rvs[i]->updateLawCovMatrix()"
182  << ", covMatrix = \n" << factor*covMatrix // FIX ME: might demand parallelism
183  << std::endl;
184  }
185 
186  InvLogitGaussianVectorRV<V, M> * invlogit_gaussian =
187  dynamic_cast<InvLogitGaussianVectorRV<V, M> * >(m_rvs[i]);
188 
189  invlogit_gaussian->updateLawCovMatrix(factor*covMatrix);
190  }
191 
192  return;
193 }
std::vector< BaseVectorRV< V, M > * > m_rvs
Definition: TKGroup.h:104
std::vector< double > m_scales
Definition: TKGroup.h:102
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
const BaseEnvironment & m_env
Definition: TKGroup.h:99
unsigned int displayVerbosity() const
Definition: Environment.C:436

Member Data Documentation

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

Definition at line 113 of file TransformedScaledCovMatrixTKGroup.h.

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

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