queso-0.53.0
RngGsl.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-2015 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 UQ_RNG_GSL_H
26 #define UQ_RNG_GSL_H
27 
28 #include <queso/RngBase.h>
29 #include <gsl/gsl_rng.h>
30 
31 
45 extern unsigned long int gsl_rng_default_seed;
46 
47 namespace QUESO {
48 
49 class RngGsl : public RngBase
50 {
51 public:
52 
54 
55  /* Uses GSL with the generator of type: gsl_rng_ranlxd2. This is the second, of a total of three
57  luxury random numbers, all an extension of a second-generation version of the ranlux algorithm of
58  Lüscher. The period of the generator is about 10^171. The algorithm has mathematically proven
59  properties and can provide truly decorrelated numbers at a known level of randomness. The higher
60  luxury levels provide increased decorrelation between samples as an additional safety margin.*/
61  RngGsl(int seed, int worldRank);
62 
64  ~RngGsl();
66 
68 
69  void resetSeed (int newSeed);
71 
73 
77  double uniformSample () const;
78 
81 
86  double gaussianSample(double stdDev) const;
87 
89 
93  double betaSample (double alpha, double beta) const;
94 
96 
100  double gammaSample (double a, double b) const;
101 
103  const gsl_rng* rng () const;
104 
105 protected:
107  RngGsl();
108 
110 
111  gsl_rng* m_rng;
112 };
113 
114 } // End namespace QUESO
115 
116 #endif // UQ_RNG_GSL_H
double uniformSample() const
Samples a value from a uniform distribution. Support: [0,1] or [a,b].
Definition: RngGsl.C:75
double gammaSample(double a, double b) const
Samples a value from a Gamma distribution. Support: [0,infinity).
Definition: RngGsl.C:96
gsl_rng * m_rng
GSL random number generator.
Definition: RngGsl.h:111
~RngGsl()
Destructor.
Definition: RngGsl.C:55
double gaussianSample(double stdDev) const
Definition: RngGsl.C:82
void resetSeed(int newSeed)
Resets the seed with value newSeed.
Definition: RngGsl.C:62
int seed() const
Sets the seed.
Definition: RngBase.C:43
const gsl_rng * rng() const
GSL random number generator.
Definition: RngGsl.C:102
Class for random number generation (base class for either GSL or Boost RNG).
Definition: RngBase.h:45
RngGsl()
Default Constructor: it should not be used.
double betaSample(double alpha, double beta) const
Samples a value from a Beta distribution. Support: [0,1].
Definition: RngGsl.C:89
unsigned long int gsl_rng_default_seed

Generated on Thu Jun 11 2015 13:52:31 for queso-0.53.0 by  doxygen 1.8.5