queso-0.53.0
Protected Attributes | List of all members
QUESO::BetaJointPdf< V, M > Class Template Reference

A class for handling Beta joint PDFs. More...

#include <BetaJointPdf.h>

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

Public Member Functions

Constructor/Destructor methods
 BetaJointPdf (const char *prefix, const VectorSet< V, M > &domainSet, const V &alpha, const V &beta)
 Constructor. More...
 
 ~BetaJointPdf ()
 Destructor. More...
 
Math methods
double actualValue (const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
 Actual value of the Beta PDF. More...
 
double lnValue (const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
 Logarithm of the value of the Beta PDF. More...
 
double computeLogOfNormalizationFactor (unsigned int numSamples, bool updateFactorInternally) const
 Computes the logarithm of the normalization factor. More...
 
- Public Member Functions inherited from QUESO::BaseJointPdf< V, M >
 BaseJointPdf (const char *prefix, const VectorSet< V, M > &domainSet)
 Default constructor. More...
 
virtual ~BaseJointPdf ()
 Destructor. More...
 
virtual void setNormalizationStyle (unsigned int value) const
 Sets a value to be used in the normalization style (stored in the protected attribute m_normalizationStyle.) More...
 
void setLogOfNormalizationFactor (double value) const
 Sets a logarithmic value to be used in the normalization factor (stored in the protected attribute m_normalizationStyle.) More...
 
- Public Member Functions inherited from QUESO::BaseScalarFunction< V, M >
 BaseScalarFunction (const char *prefix, const VectorSet< V, M > &domainSet)
 Default constructor. More...
 
virtual ~BaseScalarFunction ()
 Destructor. More...
 
const VectorSet< V, M > & domainSet () const
 Access to the protected attribute m_domainSet: domain set of the scalar function. More...
 

Protected Attributes

m_alpha
 
m_beta
 
- Protected Attributes inherited from QUESO::BaseJointPdf< V, M >
unsigned int m_normalizationStyle
 
double m_logOfNormalizationFactor
 
- Protected Attributes inherited from QUESO::BaseScalarFunction< V, M >
const BaseEnvironmentm_env
 
std::string m_prefix
 
const VectorSet< V, M > & m_domainSet
 Domain set of the scalar function. More...
 

Additional Inherited Members

- Protected Member Functions inherited from QUESO::BaseJointPdf< V, M >
double commonComputeLogOfNormalizationFactor (unsigned int numSamples, bool updateFactorInternally) const
 Common method (to the derived classes) to compute the logarithm of the normalization factor. More...
 

Detailed Description

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

A class for handling Beta joint PDFs.

This class allows the mathematical definition of a Beta Joint PDF.

Definition at line 49 of file BetaJointPdf.h.

Constructor & Destructor Documentation

template<class V , class M >
QUESO::BetaJointPdf< V, M >::BetaJointPdf ( const char *  prefix,
const VectorSet< V, M > &  domainSet,
const V &  alpha,
const V &  beta 
)

Constructor.

Constructs a new object of the class, given a prefix, the domain set, and the parameters alpha and beta of the Beta PDF.

Definition at line 33 of file BetaJointPdf.C.

References QUESO::BaseEnvironment::displayVerbosity(), QUESO::BaseScalarFunction< V, M >::m_env, QUESO::BaseScalarFunction< V, M >::m_prefix, and QUESO::BaseEnvironment::subDisplayFile().

38  :
39  BaseJointPdf<V,M>(((std::string)(prefix)+"uni").c_str(),domainSet),
40  m_alpha(alpha),
41  m_beta (beta)
42 {
43  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
44  *m_env.subDisplayFile() << "Entering BetaJointPdf<V,M>::constructor()"
45  << ": prefix = " << m_prefix
46  << std::endl;
47  }
48 
49  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
50  *m_env.subDisplayFile() << "Leaving BetaJointPdf<V,M>::constructor()"
51  << ": prefix = " << m_prefix
52  << std::endl;
53  }
54 }
unsigned int displayVerbosity() const
Definition: Environment.C:396
const BaseEnvironment & m_env
const VectorSet< V, M > & domainSet() const
Access to the protected attribute m_domainSet: domain set of the scalar function. ...
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
template<class V , class M >
QUESO::BetaJointPdf< V, M >::~BetaJointPdf ( )

Destructor.

Definition at line 57 of file BetaJointPdf.C.

58 {
59 }

Member Function Documentation

template<class V , class M >
double QUESO::BetaJointPdf< V, M >::actualValue ( const V &  domainVector,
const V *  domainDirection,
V *  gradVector,
M *  hessianMatrix,
V *  hessianEffect 
) const
virtual

Actual value of the Beta PDF.

This routine calls method lnValue() and returns the exponent of the returning value of such method.

Implements QUESO::BaseJointPdf< V, M >.

Definition at line 63 of file BetaJointPdf.C.

References queso_require_equal_to_msg, and queso_require_msg.

69 {
70  queso_require_equal_to_msg(domainVector.sizeLocal(), this->m_domainSet.vectorSpace().dimLocal(), "invalid input");
71 
72  queso_require_msg(!(domainDirection || gradVector || hessianMatrix || hessianEffect), "incomplete code for gradVector, hessianMatrix and hessianEffect calculations");
73 
74  // No need to multiply by exp(m_logOfNormalizationFactor) because 'lnValue()' is called [PDF-05]
75  return exp(this->lnValue(domainVector,domainDirection,gradVector,hessianMatrix,hessianEffect));
76 }
double lnValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Logarithm of the value of the Beta PDF.
Definition: BetaJointPdf.C:80
const VectorSet< V, M > & m_domainSet
Domain set of the scalar function.
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
template<class V , class M >
double QUESO::BetaJointPdf< V, M >::computeLogOfNormalizationFactor ( unsigned int  numSamples,
bool  updateFactorInternally 
) const
virtual

Computes the logarithm of the normalization factor.

This routine calls BaseJointPdf::commonComputeLogOfNormalizationFactor().

Implements QUESO::BaseJointPdf< V, M >.

Definition at line 117 of file BetaJointPdf.C.

References QUESO::BaseJointPdf< V, M >::commonComputeLogOfNormalizationFactor().

118 {
119  double value = 0.;
120 
121  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
122  *m_env.subDisplayFile() << "Entering BetaJointPdf<V,M>::computeLogOfNormalizationFactor()"
123  << std::endl;
124  }
125  value = BaseJointPdf<V,M>::commonComputeLogOfNormalizationFactor(numSamples, updateFactorInternally);
126  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
127  *m_env.subDisplayFile() << "Leaving BetaJointPdf<V,M>::computeLogOfNormalizationFactor()"
128  << ", m_logOfNormalizationFactor = " << m_logOfNormalizationFactor
129  << std::endl;
130  }
131 
132  return value;
133 }
unsigned int displayVerbosity() const
Definition: Environment.C:396
double m_logOfNormalizationFactor
Definition: JointPdf.h:100
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:77
const BaseEnvironment & m_env
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
template<class V , class M >
double QUESO::BetaJointPdf< V, M >::lnValue ( const V &  domainVector,
const V *  domainDirection,
V *  gradVector,
M *  hessianMatrix,
V *  hessianEffect 
) const
virtual

Logarithm of the value of the Beta PDF.

If the normalization style (m_normalizationStyle) is zero, then this routine calls a environment method which handles basic PDFs, e.g. basicPdfs()->betaPdfActualValue() and adds the log of the normalization factor (m_logOfNormalizationFactor) to it; otherwise the method uses the formula: $ lnValue = \sum[ (alpha_i-1)*log(domainVector_i) + (beta_i-1)*log(1-domainVector_i)] + m_logOfNormalizationFactor $.

Implements QUESO::BaseJointPdf< V, M >.

Definition at line 80 of file BetaJointPdf.C.

References queso_require_msg.

86 {
87  queso_require_msg(!(domainDirection || gradVector || hessianMatrix || hessianEffect), "incomplete code for gradVector, hessianMatrix and hessianEffect calculations");
88 
89  double aux = 0.;
90  double result = 0.;
91  for (unsigned int i = 0; i < domainVector.sizeLocal(); ++i) {
92  if (m_normalizationStyle == 0) {
93  //aux = log(gsl_ran_beta_pdf(domainVector[i],m_alpha[i],m_beta[i]));
94  aux = log(m_env.basicPdfs()->betaPdfActualValue(domainVector[i],m_alpha[i],m_beta[i]));
95  }
96  else {
97  aux = (m_alpha[i]-1.)*log(domainVector[i]) + (m_beta[i]-1.)*log(1.-domainVector[i]);
98  }
99  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
100  *m_env.subDisplayFile() << "In BetaJointPdf<V,M>::lnValue()"
101  << ", m_normalizationStyle = " << m_normalizationStyle
102  << ": domainVector[" << i << "] = " << domainVector[i]
103  << ", m_alpha[" << i << "] = " << m_alpha[i]
104  << ", m_beta[" << i << "] = " << m_beta[i]
105  << ", log(pdf)= " << aux
106  << std::endl;
107  }
108  result += aux;
109  }
110  result += m_logOfNormalizationFactor; // [PDF-05]
111 
112  return result;
113 }
unsigned int displayVerbosity() const
Definition: Environment.C:396
unsigned int m_normalizationStyle
Definition: JointPdf.h:99
double m_logOfNormalizationFactor
Definition: JointPdf.h:100
virtual double betaPdfActualValue(double x, double alpha, double beta) const =0
TODO: Actual value of the Beta PDF (calculated via either Boost or GSL libraries). See template specialization.
const BaseEnvironment & m_env
#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
const BasicPdfsBase * basicPdfs() const
Access to Basic PDFs.
Definition: Environment.C:436

Member Data Documentation

template<class V = GslVector, class M = GslMatrix>
V QUESO::BetaJointPdf< V, M >::m_alpha
protected

Definition at line 88 of file BetaJointPdf.h.

template<class V = GslVector, class M = GslMatrix>
V QUESO::BetaJointPdf< V, M >::m_beta
protected

Definition at line 89 of file BetaJointPdf.h.


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

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