queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
QUESO::LogNormalVectorRV< V, M > Class Template Reference

A class representing a LogNormal vector RV. More...

#include <LogNormalVectorRV.h>

Inheritance diagram for QUESO::LogNormalVectorRV< V, M >:
QUESO::BaseVectorRV< V, M >

Public Member Functions

Constructor/Destructor methods
 LogNormalVectorRV (const char *prefix, const VectorSet< V, M > &imageSet, const V &lawExpVector, const V &lawVarVector)
 Constructor. More...
 
virtual ~LogNormalVectorRV ()
 Virtual destructor. 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 >
virtual double estimateENT_ANN () const
 
 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...
 
bool has_realizer () const
 Returns true iff this RV has the ability to produce realizations (samples) 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 Marginal 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::LogNormalVectorRV< V, M >

A class representing a LogNormal vector RV.

This class allows the user to compute the value of a LogNormal PDF and to generate realizations (samples) from it.
The probability density function of a log-normal distribution is:

\[ f(x|\mu,\sigma) = \frac{1}{x \sigma \sqrt{2 \pi}}\, e^{-\frac{(\ln x - \mu)^2}{2\sigma^2}}, x>0 \]

where the parameters denoted \( \mu \) and \( \sigma \) are, respectively, the mean and standard deviation of the variable's natural logarithm; and x>0.

Definition at line 57 of file LogNormalVectorRV.h.

Constructor & Destructor Documentation

template<class V , class M >
QUESO::LogNormalVectorRV< V, M >::LogNormalVectorRV ( const char *  prefix,
const VectorSet< V, M > &  imageSet,
const V &  lawExpVector,
const V &  lawVarVector 
)

Constructor.

Construct a LogNormal vector RV with mean lawExpVector and diagonal covariance matrix lawVarVector whose variates live in imageSet.

Definition at line 35 of file LogNormalVectorRV.C.

References QUESO::BaseEnvironment::displayVerbosity(), QUESO::BaseVectorRV< V, M >::imageSet(), 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::BoxSubset< V, M >::maxValues(), QUESO::BoxSubset< V, M >::minValues(), and QUESO::BaseEnvironment::subDisplayFile().

40  :
41  BaseVectorRV<V,M>(((std::string)(prefix)+"gau").c_str(),imageSet)
42 {
43  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
44  *m_env.subDisplayFile() << "Entering LogNormalVectorRV<V,M>::constructor() [1]"
45  << ": prefix = " << m_prefix
46  << std::endl;
47  }
48 
49 // begin kemelli 2013-April-23 --------------------------
50 // LogNormal dist is defined only in (0,inf)
51 
52  const BoxSubset<V,M>* imageBox = dynamic_cast<const BoxSubset<V,M>* >(&imageSet);
53  double smallerOfMaxValues = imageBox->maxValues().getMinValue();
54  double smallerOfMinValues = imageBox->minValues().getMinValue();
55 
56  if( smallerOfMinValues < 0 )
57  {
58  std::cerr << "In LogNormalVectorRV<V,M>::constructor()\n"
59  << "LogNormal distribution is only defined in (0, infinity).\n"
60  << "The data provided is: \n"
61  << *imageBox
62  << "Sampling will not cover all interval.\n"
63  << std::endl;
64 
65 
66  queso_require_greater_equal_msg(smallerOfMaxValues, 0, "invalid input: LogNormal distribution is only defined in (0, infinity), and min(m_maxValues)<0");
67 
68  }
69 // end kemelli 2013-April-23 --------------------------
70 
71  m_pdf = new LogNormalJointPdf<V,M>(m_prefix.c_str(),
72  m_imageSet,
73  lawExpVector,
74  lawVarVector);
75 
76  M lowerCholLawCovMatrix(lawVarVector);
77  int iRC = lowerCholLawCovMatrix.chol();
78  lowerCholLawCovMatrix.zeroUpper(false);
79  if (iRC) {
80  std::cerr << "In LogNormalVectorRV<V,M>::constructor() [1]: chol failed, will use svd\n";
81  if (m_env.subDisplayFile()) {
82  *m_env.subDisplayFile() << "In LogNormalVectorRV<V,M>::constructor() [1]: chol failed; will use svd; lawVarVector contents are\n";
83  *m_env.subDisplayFile() << lawVarVector; // FIX ME: might demand parallelism
84  *m_env.subDisplayFile() << std::endl;
85  }
86  M matLaw(lawVarVector);
87  M matU (lawVarVector);
88  M matVt (m_imageSet.vectorSpace().zeroVector());
89  V vecS (m_imageSet.vectorSpace().zeroVector());
90  iRC = matLaw.svd(matU,vecS,matVt);
91  queso_require_msg(!(iRC), "Cholesky decomposition of covariance matrix failed.");
92 
93  vecS.cwSqrt();
94  m_realizer = new LogNormalVectorRealizer<V,M>(m_prefix.c_str(),
95  m_imageSet,
96  lawExpVector,
97  matU,
98  vecS, // already square rooted
99  matVt);
100  }
101  else {
102  m_realizer = new LogNormalVectorRealizer<V,M>(m_prefix.c_str(),
103  m_imageSet,
104  lawExpVector,
105  lowerCholLawCovMatrix);
106  }
107 
108  m_subCdf = NULL; // FIX ME: complete code
109  m_unifiedCdf = NULL; // FIX ME: complete code
110  m_mdf = NULL; // FIX ME: complete code
111 
112  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
113  *m_env.subDisplayFile() << "Leaving LogNormalVectorRV<V,M>::constructor() [1]"
114  << ": prefix = " << m_prefix
115  << std::endl;
116  }
117 }
std::string m_prefix
Definition: VectorRV.h:118
const BaseVectorCdf< V, M > * m_unifiedCdf
Definition: VectorRV.h:123
const BaseEnvironment & m_env
Definition: VectorRV.h:117
const VectorSet< V, M > & imageSet() const
Image set of the vector RV; access to private attribute m_imageSet.
Definition: VectorRV.C:83
BaseVectorRealizer< V, M > * m_realizer
Definition: VectorRV.h:121
BaseJointPdf< V, M > * m_pdf
Definition: VectorRV.h:120
const BaseVectorCdf< V, M > * m_subCdf
Definition: VectorRV.h:122
unsigned int displayVerbosity() const
Definition: Environment.C:450
const VectorSet< V, M > & m_imageSet
Definition: VectorRV.h:119
const BaseVectorMdf< V, M > * m_mdf
Definition: VectorRV.h:124
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
template<class V , class M >
QUESO::LogNormalVectorRV< V, M >::~LogNormalVectorRV ( )
virtual

Virtual destructor.

Definition at line 120 of file LogNormalVectorRV.C.

121 {
122  delete m_mdf;
123  delete m_unifiedCdf;
124  delete m_subCdf;
125  delete m_realizer;
126  delete m_pdf;
127 }
const BaseVectorCdf< V, M > * m_unifiedCdf
Definition: VectorRV.h:123
BaseVectorRealizer< V, M > * m_realizer
Definition: VectorRV.h:121
BaseJointPdf< V, M > * m_pdf
Definition: VectorRV.h:120
const BaseVectorCdf< V, M > * m_subCdf
Definition: VectorRV.h:122
const BaseVectorMdf< V, M > * m_mdf
Definition: VectorRV.h:124

Member Function Documentation

template<class V , class M >
void QUESO::LogNormalVectorRV< V, M >::print ( std::ostream &  os) const
virtual

TODO: Prints the vector RV.

Todo:
: implement me!

Implements QUESO::BaseVectorRV< V, M >.

Definition at line 131 of file LogNormalVectorRV.C.

132 {
133  os << "LogNormalVectorRV<V,M>::print() says, 'Please implement me.'" << std::endl;
134  return;
135 }

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

Generated on Tue Jun 5 2018 19:49:33 for queso-0.57.1 by  doxygen 1.8.5