25 #include <queso/LogNormalJointPdf.h> 
   26 #include <queso/GslVector.h> 
   27 #include <queso/GslMatrix.h> 
   32 template<
class V,
class M>
 
   36   const V&                     lawExpVector,
 
   37   const V&                     lawVarVector)
 
   39   BaseJointPdf<V,M>(((std::string)(prefix)+
"gau").c_str(),domainSet),
 
   40   m_lawExpVector     (new V(lawExpVector)),
 
   41   m_lawVarVector     (new V(lawVarVector)),
 
   42   m_diagonalCovMatrix(true)
 
   65 template<
class V,
class M>
 
   68   delete m_lawVarVector;
 
   69   delete m_lawExpVector;
 
   72 template <
class V, 
class M>
 
   76   return *m_lawExpVector;
 
   79 template <
class V, 
class M>
 
   83   return *m_lawVarVector;
 
   86 template<
class V, 
class M>
 
   89   const V& domainVector,
 
   90   const V* domainDirection,
 
   93         V* hessianEffect)
 const 
   95   if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 55)) {
 
   96     *m_env.subDisplayFile() << 
"Entering LogNormalJointPdf<V,M>::actualValue()" 
   97                             << 
", meanVector = "               << *m_lawExpVector
 
   98                             << 
": domainVector = "             << domainVector
 
   99                             << 
", domainVector.sizeLocal() = " << domainVector.sizeLocal()
 
  100                             << 
", this->m_domainSet.vectorSpace().dimLocal() = " << this->m_domainSet.vectorSpace().dimLocal()
 
  104   UQ_FATAL_TEST_MACRO(domainVector.sizeLocal() != this->m_domainSet.vectorSpace().dimLocal(),
 
  106                       "LogNormalJointPdf<V,M>::actualValue()",
 
  111                       "LogNormalJointPdf<V,M>::actualValue()",
 
  112                       "incomplete code for gradVector, hessianMatrix and hessianEffect calculations");
 
  114   double returnValue = 0.;
 
  116   V zeroVector(domainVector);
 
  117   zeroVector.cwSet(0.);
 
  118   if (domainVector.atLeastOneComponentSmallerOrEqualThan(zeroVector)) {
 
  121   else if (this->m_domainSet.contains(domainVector) == 
false) { 
 
  125     returnValue = std::exp(this->lnValue(domainVector,domainDirection,gradVector,hessianMatrix,hessianEffect));
 
  129   if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 55)) {
 
  130     *m_env.subDisplayFile() << 
"Leaving LogNormalJointPdf<V,M>::actualValue()" 
  131                             << 
", meanVector = "   << *m_lawExpVector
 
  132                             << 
": domainVector = " << domainVector
 
  133                             << 
", returnValue = "  << returnValue
 
  140 template<
class V, 
class M>
 
  143   const V& domainVector,
 
  144   const V* domainDirection,
 
  147         V* hessianEffect)
 const 
  149   if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 55)) {
 
  150     *m_env.subDisplayFile() << 
"Entering LogNormalJointPdf<V,M>::lnValue()" 
  151                             << 
", meanVector = "   << *m_lawExpVector
 
  152                             << 
": domainVector = " << domainVector
 
  158                       "LogNormalJointPdf<V,M>::lnValue()",
 
  159                       "incomplete code for gradVector, hessianMatrix and hessianEffect calculations");
 
  161   if (domainDirection) {}; 
 
  163   double returnValue = 0.;
 
  165   V zeroVector(domainVector);
 
  166   zeroVector.cwSet(0.);
 
  167   if (domainVector.atLeastOneComponentSmallerOrEqualThan(zeroVector)) {
 
  168     returnValue = -INFINITY;
 
  170   else if (this->m_domainSet.contains(domainVector) == 
false) { 
 
  171     returnValue = -INFINITY;
 
  174     if (m_diagonalCovMatrix) {
 
  175       V diffVec(zeroVector);
 
  176       for (
unsigned int i = 0; i < domainVector.sizeLocal(); ++i) {
 
  177         diffVec[i] = std::log(domainVector[i]) - this->lawExpVector()[i];
 
  179       returnValue = ((diffVec*diffVec)/this->lawVarVector()).sumOfComponents();
 
  181       if (m_normalizationStyle == 0) {
 
  182         for (
unsigned int i = 0; i < domainVector.sizeLocal(); ++i) {
 
  183           returnValue -= std::log(domainVector[i] * std::sqrt(2. * M_PI * this->lawVarVector()[i])); 
 
  190                           "LogNormalJointPdf<V,M>::lnValue()",
 
  191                           "situation with a non-diagonal covariance matrix makes no sense");
 
  193     returnValue += m_logOfNormalizationFactor; 
 
  196   if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 55)) {
 
  197     *m_env.subDisplayFile() << 
"Leaving LogNormalJointPdf<V,M>::lnValue()" 
  198                             << 
", meanVector = "   << *m_lawExpVector
 
  199                             << 
": domainVector = " << domainVector
 
  200                             << 
", returnValue = "  << returnValue
 
  207 template<
class V, 
class M>
 
  213   if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
 
  214     *m_env.subDisplayFile() << 
"Entering LogNormalJointPdf<V,M>::computeLogOfNormalizationFactor()" 
  218   if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
 
  219     *m_env.subDisplayFile() << 
"Leaving LogNormalJointPdf<V,M>::computeLogOfNormalizationFactor()" 
  220                             << 
", m_logOfNormalizationFactor = " << m_logOfNormalizationFactor
 
LogNormalJointPdf(const char *prefix, const VectorSet< V, M > &domainSet, const V &lawExpVector, const V &lawVarVector)
Constructor. 
 
A class for handling Log-Normal joint PDFs. 
 
A templated class for handling sets. 
 
std::ofstream * subDisplayFile() const 
Access function for m_subDisplayFile (displays file on stream). 
 
const V & lawVarVector() const 
Access to the vector of variance values and private attribute: m_lawVarVector. 
 
double lnValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const 
Logarithm of the value of the Log-Normal PDF (scalar function). 
 
double actualValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const 
Actual value of the Log-Normal PDF (scalar function). 
 
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
 
double computeLogOfNormalizationFactor(unsigned int numSamples, bool updateFactorInternally) const 
Computes the logarithm of the normalization factor. 
 
A templated (base) class for handling joint PDFs. 
 
double commonComputeLogOfNormalizationFactor(unsigned int numSamples, bool updateFactorInternally) const 
Common method (to the derived classes) to compute the logarithm of the normalization factor...
 
unsigned int displayVerbosity() const 
 
~LogNormalJointPdf()
Destructor. 
 
const BaseEnvironment & m_env
 
const V & lawExpVector() const 
Access to the vector of mean values and private attribute: m_lawExpVector.