queso-0.57.0
RngCXX11.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // QUESO - a library to support the Quantification of Uncertainty
5 // for Estimation, Simulation and Optimization
6 //
7 // Copyright (C) 2008-2017 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 #ifndef QUESO_RNGCXX11_H
26 #define QUESO_RNGCXX11_H
27 
28 #include <queso/Defines.h>
29 
30 #ifdef QUESO_HAVE_CXX11
31 
32 #include <queso/RngBase.h>
33 #include <random>
34 
46 namespace QUESO {
47 
48 class RngCXX11 : public RngBase
49 {
50 public:
52 
53  /*
55  * Uses std::random with a generator of type: mt19937. The widely used
56  * Mersenne Twister random number generator.
57  */
58  RngCXX11(int seed, int worldRank);
59 
61  ~RngCXX11();
63 
65 
66  void resetSeed(int newSeed);
68 
70 
76  double uniformSample() const;
77 
80 
88  double gaussianSample(double stdDev) const;
89 
91 
101  double betaSample(double alpha, double beta) const;
102 
104 
110  double gammaSample(double a, double b) const;
111 
112 private:
114  RngCXX11();
115 
117  mutable std::mt19937 m_rng;
118 };
119 
120 } // End namespace QUESO
121 
122 #endif // QUESO_HAVE_CXX11
123 
124 #endif // QUESO_RNGCXX11_H
~RngCXX11()
Destructor.
Definition: RngCXX11.C:39
int seed() const
Sets the seed.
Definition: RngBase.C:42
std::mt19937 m_rng
The internal random number generator. Mersenne Twister generator.
Definition: RngCXX11.h:117
double gammaSample(double a, double b) const
Samples a value from a Gamma distribution. Support: [0,infinity).
Definition: RngCXX11.C:79
Class for random number generation (base class for either GSL or Boost RNG).
Definition: RngBase.h:45
double uniformSample() const
Samples a value from a uniform distribution. Support: [0,1) or [a,b).
Definition: RngCXX11.C:51
RngCXX11()
Default Constructor: it should not be used.
double gaussianSample(double stdDev) const
Definition: RngCXX11.C:58
void resetSeed(int newSeed)
Resets the seed with value newSeed.
Definition: RngCXX11.C:44
double betaSample(double alpha, double beta) const
Samples a value from a Beta distribution. Support: [0,1].
Definition: RngCXX11.C:65

Generated on Sat Apr 22 2017 14:04:35 for queso-0.57.0 by  doxygen 1.8.5