queso-0.53.0
List of all members
QUESO::RngBoost Class Reference

#include <RngBoost.h>

Inheritance diagram for QUESO::RngBoost:
Inheritance graph
[legend]
Collaboration diagram for QUESO::RngBoost:
Collaboration graph
[legend]

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 47 of file RngBoost.h.

Constructor & Destructor Documentation

RngBoost::RngBoost ( int  seed,
int  worldRank 
)

Constructor with seed.

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

Definition at line 31 of file RngBoost.C.

References resetSeed().

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

Destructor.

Definition at line 45 of file RngBoost.C.

46 {
47  //this function does nothing
48 }
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 79 of file RngBoost.C.

References m_rng.

80 {
81  static boost::uniform_01<boost::mt19937> zeroone(m_rng);
82  boost::math::beta_distribution<double> beta_dist(alpha, beta);
83  return quantile(beta_dist, zeroone());
84 }
boost::mt19937 m_rng
Random number generator from class boost::mt19937.
Definition: RngBoost.h:110
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 88 of file RngBoost.C.

References m_rng.

89 {
90  static boost::uniform_01<boost::mt19937> zeroone(m_rng);
91  boost::math::gamma_distribution<double> gamma_dist(a,b);
92  return quantile(gamma_dist, zeroone());
93 }
boost::mt19937 m_rng
Random number generator from class boost::mt19937.
Definition: RngBoost.h:110
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 69 of file RngBoost.C.

References m_rng.

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

Resets the seed with value newSeed.

Reimplemented from QUESO::RngBase.

Definition at line 52 of file RngBoost.C.

References m_rng.

Referenced by RngBoost().

53 {
54  m_rng.seed(newSeed);
55 
56  return;
57 }
boost::mt19937 m_rng
Random number generator from class boost::mt19937.
Definition: RngBoost.h:110
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 61 of file RngBoost.C.

References m_rng.

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

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 110 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 Thu Jun 11 2015 13:52:34 for queso-0.53.0 by  doxygen 1.8.5