queso-0.52.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  RngGsl();
57 
59  /* Uses GSL with the generator of type: gsl_rng_ranlxd2. This is the second, of a total of three
60  luxury random numbers, all an extension of a second-generation version of the ranlux algorithm of
61  Lüscher. The period of the generator is about 10^171. The algorithm has mathematically proven
62  properties and can provide truly decorrelated numbers at a known level of randomness. The higher
63  luxury levels provide increased decorrelation between samples as an additional safety margin.*/
64  RngGsl(int seed, int worldRank);
65 
67  ~RngGsl();
69 
71 
72  void resetSeed (int newSeed);
74 
76 
80  double uniformSample () const;
81 
84 
89  double gaussianSample(double stdDev) const;
90 
92 
96  double betaSample (double alpha, double beta) const;
97 
99 
103  double gammaSample (double a, double b) const;
104 
106  const gsl_rng* rng () const;
107 
108 protected:
110 
111  gsl_rng* m_rng;
112 };
113 
114 } // End namespace QUESO
115 
116 #endif // UQ_RNG_GSL_H
Class for random number generation (base class for either GSL or Boost RNG).
Definition: RngBase.h:45
const gsl_rng * rng() const
GSL random number generator.
Definition: RngGsl.C:119
~RngGsl()
Destructor.
Definition: RngGsl.C:69
RngGsl()
Default Constructor: it should not be used.
Definition: RngGsl.C:32
int seed() const
Sets the seed.
Definition: RngBase.C:54
double betaSample(double alpha, double beta) const
Samples a value from a Beta distribution. Support: [0,1].
Definition: RngGsl.C:106
double gaussianSample(double stdDev) const
Definition: RngGsl.C:99
double gammaSample(double a, double b) const
Samples a value from a Gamma distribution. Support: [0,infinity).
Definition: RngGsl.C:113
double uniformSample() const
Samples a value from a uniform distribution. Support: [0,1] or [a,b].
Definition: RngGsl.C:92
gsl_rng * m_rng
GSL random number generator.
Definition: RngGsl.h:111
void resetSeed(int newSeed)
Resets the seed with value newSeed.
Definition: RngGsl.C:76
unsigned long int gsl_rng_default_seed

Generated on Thu Apr 23 2015 19:30:54 for queso-0.52.0 by  doxygen 1.8.5