queso-0.53.0
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 = GslVector, class M = GslMatrix>
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 48 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 35 of file GammaVectorRealizer.C.

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

40  :
41  BaseVectorRealizer<V,M>(((std::string)(prefix)+"gen").c_str(),unifiedImageSet,std::numeric_limits<unsigned int>::max()),
42  m_a(a),
43  m_b(b)
44 {
45  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
46  *m_env.subDisplayFile() << "Entering GammaVectorRealizer<V,M>::constructor()"
47  << ": prefix = " << m_prefix
48  << std::endl;
49  }
50 
51  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
52  *m_env.subDisplayFile() << "Leaving GammaVectorRealizer<V,M>::constructor()"
53  << ": prefix = " << m_prefix
54  << std::endl;
55  }
56 }
unsigned int displayVerbosity() const
Definition: Environment.C:396
const BaseEnvironment & m_env
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
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 59 of file GammaVectorRealizer.C.

60 {
61 }

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 65 of file GammaVectorRealizer.C.

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

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

Member Data Documentation

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

Definition at line 80 of file GammaVectorRealizer.h.

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

Definition at line 81 of file GammaVectorRealizer.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