queso-0.51.1
List of all members
QUESO::GammaVectorRealizer< V, M > Class Template Reference

A class for handling sampling from a Gamma probability density distribution. More...

#include <GammaVectorRealizer.h>

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

Public Member Functions

Constructor/Destructor methods
 GammaVectorRealizer (const char *prefix, const VectorSet< V, M > &unifiedImageSet, const V &a, const V &b)
 Constructor. More...
 
 ~GammaVectorRealizer ()
 Destructor. More...
 
- Public Member Functions inherited from QUESO::BaseVectorRealizer< V, M >
 BaseVectorRealizer (const char *prefix, const VectorSet< V, M > &unifiedImageSet, unsigned int subPeriod)
 Default constructor. More...
 
virtual ~BaseVectorRealizer ()
 Virtual destructor. More...
 
const VectorSet< V, M > & unifiedImageSet () const
 Image set where the realizations lie. Access to protected attribute m_unifiedImageSet. More...
 
unsigned int subPeriod () const
 Sub-period of the realization. Access to protected attribute m_subPeriod. More...
 

Realization-related methods

m_a
 
m_b
 
void realization (V &nextValues) const
 Draws a realization. More...
 

Additional Inherited Members

- Protected Attributes inherited from QUESO::BaseVectorRealizer< V, M >
const BaseEnvironmentm_env
 
std::string m_prefix
 
const VectorSet< V, M > & m_unifiedImageSet
 
unsigned int m_subPeriod
 

Detailed Description

template<class V, class M>
class QUESO::GammaVectorRealizer< V, M >

A class for handling sampling from a Gamma probability density distribution.

This class handles sampling from a Gamma probability density distribution, of parameters a and b.

Definition at line 45 of file GammaVectorRealizer.h.

Constructor & Destructor Documentation

template<class V , class M >
QUESO::GammaVectorRealizer< V, M >::GammaVectorRealizer ( const char *  prefix,
const VectorSet< V, M > &  unifiedImageSet,
const V &  a,
const V &  b 
)

Constructor.

Constructs a new object, given a prefix, the image set of the vector realizer, and the Gamma distribution parameters a and b, which are assigned to private attributes m_alpha and m_beta.

Definition at line 33 of file GammaVectorRealizer.C.

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

38  :
39  BaseVectorRealizer<V,M>(((std::string)(prefix)+"gen").c_str(),unifiedImageSet,std::numeric_limits<unsigned int>::max()),
40  m_a(a),
41  m_b(b)
42 {
43  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
44  *m_env.subDisplayFile() << "Entering GammaVectorRealizer<V,M>::constructor()"
45  << ": prefix = " << m_prefix
46  << std::endl;
47  }
48 
49  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
50  *m_env.subDisplayFile() << "Leaving GammaVectorRealizer<V,M>::constructor()"
51  << ": prefix = " << m_prefix
52  << std::endl;
53  }
54 }
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
const BaseEnvironment & m_env
unsigned int displayVerbosity() const
Definition: Environment.C:436
const VectorSet< V, M > & unifiedImageSet() const
Image set where the realizations lie. Access to protected attribute m_unifiedImageSet.
template<class V , class M >
QUESO::GammaVectorRealizer< V, M >::~GammaVectorRealizer ( )

Destructor.

Definition at line 57 of file GammaVectorRealizer.C.

58 {
59 }

Member Function Documentation

template<class V , class M >
void QUESO::GammaVectorRealizer< V, M >::realization ( V &  nextValues) const
virtual

Draws a realization.

This function draws a realization of a Gamma distribution and saves it in nextValues. It internally checks whether the image set, where the realization should be drawn, belongs to the interval (0, infinity) - which is the range where Gamma distribution is defined over.

Implements QUESO::BaseVectorRealizer< V, M >.

Definition at line 63 of file GammaVectorRealizer.C.

References QUESO::BoxSubset< V, M >::maxValues(), QUESO::BoxSubset< V, M >::minValues(), and UQ_FATAL_TEST_MACRO.

64 {
65  // nextValues.cwSetGamma(m_a,m_b);
66 
67 // begin kemelli 2013-April-22 :
68  const BoxSubset<V,M>* imageBox = dynamic_cast<const BoxSubset<V,M>* >(&this->m_unifiedImageSet);
69 // double biggerOfMaxValues = imageBox->maxValues().getMaxValue();
70  double smallerOfMaxValues = imageBox->maxValues().getMinValue();
71  double smallerOfMinValues = imageBox->minValues().getMinValue();
72 
73  // Gamma dist belongs to (0,inf)
74  if( smallerOfMinValues < 0 ) //(biggerOfMinValues < 0) ||
75  {
76  std::cerr << "In GammaVectorRealizer<V,M>::realization()\n"
77  << "Gamma distribution is only defined in (0, infinity).\n"
78  << "The data provided is: \n"
79  << *imageBox
80  << "Sampling will not cover all interval.\n"
81  << std::endl;
82 
83 
84  UQ_FATAL_TEST_MACRO(smallerOfMaxValues < 0,
85  m_env.worldRank(),
86  "GammaVectorRealizer<V,M>::realization()",
87  "invalid input: Gamma distribution is only defined in (0, infinity), and min(m_maxValues)<0. ");
88 
89  // UQ_FATAL_TEST_MACRO(biggerOfMaxValues < 0,
90  // m_env.worldRank(),
91  // "GammaVectorRealizer<V,M>::realization()",
92  // "invalid input: Gamma distribution is only defined in (0, infinity). ");
93 
94  }
95 
96  // end kemelli 2013-April-22
97 
98  // begin kemelli 2013-April-18 :
99  bool outOfSupport = true;
100  do {
101 
102  nextValues.cwSetGamma(m_a,m_b);
103  outOfSupport = !(this->m_unifiedImageSet.contains(nextValues));
104 
105  } while (outOfSupport);
106 
107  // end kemelli 2013-April-18 :
108 
109  return;
110 }
const VectorSet< V, M > & m_unifiedImageSet
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
const BaseEnvironment & m_env
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223

Member Data Documentation

template<class V, class M>
V QUESO::GammaVectorRealizer< V, M >::m_a
private

Definition at line 77 of file GammaVectorRealizer.h.

template<class V, class M>
V QUESO::GammaVectorRealizer< V, M >::m_b
private

Definition at line 78 of file GammaVectorRealizer.h.


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

Generated on Thu Apr 23 2015 19:26:17 for queso-0.51.1 by  doxygen 1.8.5