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

#include <RngBoost.h>

Inheritance diagram for QUESO::RngBoost:
QUESO::RngBase

Public Member Functions

Constructor/Destructor methods
 RngBoost (int seed, int worldRank)
 Constructor with seed. More...
 
 ~RngBoost ()
 Destructor. More...
 
- Public Member Functions inherited from QUESO::RngBase
 RngBase (int seed, int worldRank)
 Constructor with seed. More...
 
virtual ~RngBase ()
 Virtual destructor. More...
 
int seed () const
 Sets the seed. More...
 

Sampling methods

boost::mt19937 m_rng
 Random number generator from class boost::mt19937. More...
 
void resetSeed (int newSeed)
 Resets the seed with value newSeed. More...
 
double uniformSample () const
 Samples a value from a uniform distribution. Support: [0,1] or [a,b]. More...
 
double gaussianSample (double stdDev) const
 
double betaSample (double alpha, double beta) const
 Samples a value from a Beta distribution. Support: [0,1]. More...
 
double gammaSample (double a, double b) const
 Samples a value from a Gamma distribution. Support: [0,infinity). More...
 
 RngBoost ()
 Default Constructor: it should not be used. More...
 

Additional Inherited Members

- Protected Attributes inherited from QUESO::RngBase
int m_seed
 Seed. More...
 
int m_worldRank
 Rank of processor. More...
 

Detailed Description

Definition at line 46 of file RngBoost.h.

Constructor & Destructor Documentation

RngBoost::RngBoost ( int  seed,
int  worldRank 
)

Constructor with seed.

Constructor with seed ------------------------—.

Definition at line 33 of file RngBoost.C.

References resetSeed().

34  :
35  RngBase(seed,worldRank)
36  //m_rng(seed)
37 {
38  resetSeed(seed);
39 //TODO Find a suitable test for here; Kemelli todo
40 
41 // m_worldRank,
42 // "RngBoos::constructor()",
43 // "Kemelli todo: boost rng");
44 }
int seed() const
Sets the seed.
Definition: RngBase.C:42
void resetSeed(int newSeed)
Resets the seed with value newSeed.
Definition: RngBoost.C:54
RngBase()
Default Constructor: it should not be used.
RngBoost::~RngBoost ( )

Destructor.

Definition at line 47 of file RngBoost.C.

48 {
49  //this function does nothing
50 }
QUESO::RngBoost::RngBoost ( )
private

Default Constructor: it should not be used.

Member Function Documentation

double RngBoost::betaSample ( double  alpha,
double  beta 
) const
virtual

Samples a value from a Beta distribution. Support: [0,1].

The Beta Distribution is a continuous probability distribution; it has two free parameters, which are labeled alpha and beta. The beta distribution is used as a prior distribution for binomial proportions in Bayesian analysis (Evans et al. 2000, p. 34). Uses boost::math::beta_distribution<double> beta_dist(alpha, beta). Support (domain): [0,1].

Implements QUESO::RngBase.

Definition at line 81 of file RngBoost.C.

References m_rng.

82 {
83  static boost::uniform_01<boost::mt19937> zeroone(m_rng);
84  boost::math::beta_distribution<double> beta_dist(alpha, beta);
85  return quantile(beta_dist, zeroone());
86 }
boost::mt19937 m_rng
Random number generator from class boost::mt19937.
Definition: RngBoost.h:109
double RngBoost::gammaSample ( double  a,
double  b 
) const
virtual

Samples a value from a Gamma distribution. Support: [0,infinity).

The Gamma Distribution is a continuous probability distribution; it has two free parameters, which may be labeled: a shape parameter a and an inverse scale parameter b, called a rate parameter. The parameterization with a and b is more common in Bayesian statistics, where the gamma distribution is used as a conjugate prior distribution for various types of inverse scale (aka rate) parameters. Uses boost::math::gamma_distribution<double> gamma_dist(a,b). Support (domain): [0,infinity).

Implements QUESO::RngBase.

Definition at line 90 of file RngBoost.C.

References m_rng.

91 {
92  static boost::uniform_01<boost::mt19937> zeroone(m_rng);
93  boost::math::gamma_distribution<double> gamma_dist(a,b);
94  return quantile(gamma_dist, zeroone());
95 }
boost::mt19937 m_rng
Random number generator from class boost::mt19937.
Definition: RngBoost.h:109
double RngBoost::gaussianSample ( double  stdDev) const
virtual

Samples a value from a Gaussian distribution with standard deviation given by stdDev. Support: (-infinity, infinity).

The parameter mu (mean or expectation of the distribution) in this Gaussian sample isn't present, and thus, needs to be provided. e.g., in the form of a sum. The parameter stdDev is its standard deviation; its variance is therefore stdDev^2. A random variable with a Gaussian distribution is said to be normally distributed and is called a normal deviate. Uses boost::math::normal_distribution<double> gaussian_dist(mean, stdDev) Support (domain): (-infinity, infinity).

Implements QUESO::RngBase.

Definition at line 71 of file RngBoost.C.

References m_rng.

72 {
73  double mean = 0.; //it will be added conveniently later
74  static boost::uniform_01<boost::mt19937> zeroone(m_rng);
75  boost::math::normal_distribution<double> gaussian_dist(mean, stdDev);
76  return quantile(gaussian_dist, zeroone());
77 }
boost::mt19937 m_rng
Random number generator from class boost::mt19937.
Definition: RngBoost.h:109
void RngBoost::resetSeed ( int  newSeed)
virtual

Resets the seed with value newSeed.

Reimplemented from QUESO::RngBase.

Definition at line 54 of file RngBoost.C.

References m_rng.

Referenced by RngBoost().

55 {
56  m_rng.seed(newSeed);
57 
58  return;
59 }
boost::mt19937 m_rng
Random number generator from class boost::mt19937.
Definition: RngBoost.h:109
double RngBoost::uniformSample ( ) const
virtual

Samples a value from a uniform distribution. Support: [0,1] or [a,b].

This function samples from continuous uniform distribution on the range [0,1). It is possible to scale this distribution so the support is defined by the two parameters, a and b, which are its minimum and maximum values. Support: -infinity < a < x< b< infinity. Uses boost::uniform_01<boost::mt19937> zeroone(m_rng).

Implements QUESO::RngBase.

Definition at line 63 of file RngBoost.C.

References m_rng.

64 {
65  static boost::uniform_01<boost::mt19937> zeroone(m_rng);
66  return zeroone();
67 }
boost::mt19937 m_rng
Random number generator from class boost::mt19937.
Definition: RngBoost.h:109

Member Data Documentation

boost::mt19937 QUESO::RngBoost::m_rng
private

Random number generator from class boost::mt19937.

mt19937 are models for a pseudo-random number generator. Here it is cannot be static, as it has not been initialized yet. mt19937 has length cycle of 2^(19937)-1, requires approximately 625*sizeof(uint32_t) of memory, has relatively high speed (93% of the fastest available in Boost library), and provides good uniform distribution in up to 623 dimensions.

Definition at line 109 of file RngBoost.h.

Referenced by betaSample(), gammaSample(), gaussianSample(), resetSeed(), and uniformSample().


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

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