queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
QUESO::BasicPdfsCXX11 Class Reference

Base class for basic PDFs using C++ math functions. More...

#include <BasicPdfsCXX11.h>

Inheritance diagram for QUESO::BasicPdfsCXX11:
QUESO::BasicPdfsBase

Public Member Functions

Constructor/Destructor methods
 BasicPdfsCXX11 (int worldRank)
 Constructor. More...
 
 ~BasicPdfsCXX11 ()
 Destructor. More...
 
Mathematical methods
double betaPdfActualValue (double x, double alpha, double beta) const
 Actual value of the Beta PDF. More...
 
double gammaPdfActualValue (double x, double a, double b) const
 Actual value of the Gamma PDF. More...
 
- Public Member Functions inherited from QUESO::BasicPdfsBase
 BasicPdfsBase (int worldRank)
 Constructor. More...
 
virtual ~BasicPdfsBase ()
 Virtual destructor. More...
 

Private Member Functions

 BasicPdfsCXX11 ()
 Default constructor. More...
 

Additional Inherited Members

- Protected Attributes inherited from QUESO::BasicPdfsBase
int m_worldRank
 

Detailed Description

Base class for basic PDFs using C++ math functions.

Todo:
This class will acommodate the definition of a Joint PDF using C++11 math functions to bootstrap our own PDF evaluations since std::random doesn't have PDF evaluations. It will ultimately be called by BaseJointPdf and/or its derived classes (via m_env.basicPdfs()) during the construction of Joint PDFs.

Definition at line 51 of file BasicPdfsCXX11.h.

Constructor & Destructor Documentation

QUESO::BasicPdfsCXX11::BasicPdfsCXX11 ( int  worldRank)

Constructor.

Definition at line 33 of file BasicPdfsCXX11.C.

34  :
35  BasicPdfsBase(worldRank)
36 {
37 }
BasicPdfsBase()
Default constructor.
Definition: BasicPdfsBase.C:29
QUESO::BasicPdfsCXX11::~BasicPdfsCXX11 ( )

Destructor.

Definition at line 39 of file BasicPdfsCXX11.C.

40 {
41 }
QUESO::BasicPdfsCXX11::BasicPdfsCXX11 ( )
private

Default constructor.

Member Function Documentation

double QUESO::BasicPdfsCXX11::betaPdfActualValue ( double  x,
double  alpha,
double  beta 
) const
virtual

Actual value of the Beta PDF.

Implements QUESO::BasicPdfsBase.

Definition at line 44 of file BasicPdfsCXX11.C.

45 {
46  // C++11 doesn't have a beta distribution, so we just implement one.
47 
48  double ln_gamma_apb;
49  double ln_gamma_a;
50  double ln_gamma_b;
51 
52  if (x < 0 || x > 1) { // Outside the support; return zero.
53  return 0.0;
54  }
55  else {
56  if (x == 0.0 || x == 1.0) { // On the boundary
57  if (alpha > 1.0 && beta > 1.0) { // Not blowing up
58  return 0.0;
59  }
60  else { // Might be blowing up, so let it.
61  ln_gamma_apb = std::lgamma(alpha + beta);
62  ln_gamma_a = std::lgamma(alpha);
63  ln_gamma_b = std::lgamma(beta);
64 
65  return std::exp(ln_gamma_apb - ln_gamma_a - ln_gamma_b) *
66  std::pow(x, alpha - 1) * std::pow(1 - x, beta - 1);
67  }
68  }
69  else { // Compute beta pdf in log space.
70  ln_gamma_apb = std::lgamma(alpha + beta);
71  ln_gamma_a = std::lgamma(alpha);
72  ln_gamma_b = std::lgamma(beta);
73 
74  return std::exp(ln_gamma_apb - ln_gamma_a - ln_gamma_b +
75  (alpha - 1) * std::log(x) + (beta - 1) * std::log1p(-x));
76  }
77  }
78 }
double QUESO::BasicPdfsCXX11::gammaPdfActualValue ( double  x,
double  a,
double  b 
) const
virtual

Actual value of the Gamma PDF.

Implements QUESO::BasicPdfsBase.

Definition at line 81 of file BasicPdfsCXX11.C.

82 {
83  if (x < 0) { // Out of bounds.
84  return 0;
85  }
86  else {
87  if (x == 0.0) { // On the boundary.
88  if (a > 1.0) { // Not blowing up.
89  return 0.0;
90  }
91  else {
92  double ln_gamma_a = std::lgamma(a);
93  return std::exp(-ln_gamma_a - a * std::log(b)) * std::pow(x, a - 1) *
94  std::exp(- x / b);
95  }
96  }
97  else {
98  double ln_gamma_a = std::lgamma(a);
99  return std::exp(-ln_gamma_a - a * std::log(b) + (a - 1) * std::log(x) -
100  (x / b));
101  }
102  }
103 }

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

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