queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
GenericJointPdf.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // QUESO - a library to support the Quantification of Uncertainty
5 // for Estimation, Simulation and Optimization
6 //
7 // Copyright (C) 2008-2017 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 #include <queso/GenericJointPdf.h>
26 #include <queso/GslVector.h>
27 #include <queso/GslMatrix.h>
28 
29 namespace QUESO {
30 
31 // Default constructor -----------------------------
32 template<class V, class M>
34  const char* prefix,
35  const BaseScalarFunction<V,M>& scalarFunction)
36  :
37  BaseJointPdf<V,M>(((std::string)(prefix)+"gen").c_str(),scalarFunction.domainSet()),
38  m_scalarFunction(scalarFunction)
39 {
40 }
41 // Destructor ---------------------------------------
42 template<class V, class M>
44 {
45 }
46 // Math methods -------------------------------------
47 template<class V, class M>
48 double
50  const V& domainVector,
51  const V* domainDirection,
52  V* gradVector,
53  M* hessianMatrix,
54  V* hessianEffect) const
55 {
56  return ((exp(m_logOfNormalizationFactor))*m_scalarFunction.actualValue(domainVector,domainDirection,gradVector,hessianMatrix,hessianEffect)); // [PDF-01]
57 }
58 // --------------------------------------------------
59 template<class V, class M>
60 double
62  const V& domainVector,
63  const V* domainDirection,
64  V* gradVector,
65  M* hessianMatrix,
66  V* hessianEffect) const
67 {
68  return (m_logOfNormalizationFactor + m_scalarFunction.lnValue(domainVector,domainDirection,gradVector,hessianMatrix,hessianEffect)); // [PDF-01]
69 }
70 // --------------------------------------------------
71 template<class V, class M>
72 double
73 GenericJointPdf<V,M>::computeLogOfNormalizationFactor(unsigned int numSamples, bool updateFactorInternally) const
74 {
75  double value = 0.;
76 
77  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
78  *m_env.subDisplayFile() << "Entering GenericJointPdf<V,M>::computeLogOfNormalizationFactor()"
79  << std::endl;
80  }
81  value = BaseJointPdf<V,M>::commonComputeLogOfNormalizationFactor(numSamples, updateFactorInternally);
82  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
83  *m_env.subDisplayFile() << "Leaving GenericJointPdf<V,M>::computeLogOfNormalizationFactor()"
84  << ", m_logOfNormalizationFactor = " << m_logOfNormalizationFactor
85  << std::endl;
86  }
87 
88  return value;
89 }
90 
91 } // End namespace QUESO
92 
A templated (base) class for handling scalar functions.
GenericJointPdf(const char *prefix, const BaseScalarFunction< V, M > &scalarFunction)
Default constructor.
double lnValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Logarithm of the value of the scalar function. Deprecated.
double actualValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Actual value of the PDF (scalar function).
double commonComputeLogOfNormalizationFactor(unsigned int numSamples, bool updateFactorInternally) const
Common method (to the derived classes) to compute the logarithm of the normalization factor...
Definition: JointPdf.C:115
A templated (base) class for handling joint PDFs.
Definition: JointPdf.h:55
double computeLogOfNormalizationFactor(unsigned int numSamples, bool updateFactorInternally) const
Computes the logarithm of the normalization factor. See template specialization.
~GenericJointPdf()
Destructor.
A class for handling generic joint PDFs.

Generated on Tue Jun 5 2018 19:48:55 for queso-0.57.1 by  doxygen 1.8.5