|
STK++ 0.9.13
|
class for the Base random generator. More...
#include <STK_RandBase.h>

Public Member Functions | |
| RandBase (Real const &glimit=3.442619855899, Real const &gvol=9.91256303526217e-3, int gsize=128) | |
| Default constructor. | |
| RandBase (int oneSeed, Real const &glimit=3.442619855899, Real const &gvol=9.91256303526217e-3, int gsize=128) | |
| Initialize with a simple int seed. | |
| template<class TContainer1D > | |
| RandBase (TContainer1D const &bigSeed, Real const &glimit=3.442619855899, Real const &gvol=9.91256303526217e-3, int gsize=128) | |
| Initialize with a seed Array. | |
| ~RandBase () | |
| destructor. | |
| int | randDiscreteUnif () |
| Pseudo-random int uniform generator. | |
| Real | randUnif () |
| pseudo-random uniform generator. | |
| Real | operator() () |
| Real | rand () |
| real number in [0,1] | |
| Real | rand (Real const &n) |
| real number in [0,n] | |
| Real | randExc () |
| real number in [0,1) | |
| Real | randExc (Real const &n) |
| real number in [0,n) | |
| Real | randDblExc () |
| real number in (0,1) | |
| Real | randDblExc (Real const &n) |
| real number in (0,n) | |
| Real | randGauss (Real const &mu=0, Real const &sigma=1) |
| Pseudo-random gaussian generator of the gaussian probability law: | |
| Real | randExp () |
| Pseudo-random exponential generator. | |
Private Member Functions | |
| void | gaussInit () |
| Initialization of the Zigourrat method. | |
Private Attributes | |
| const int | gsize_ |
| Number of box for the gaussian ziggourat method. | |
| Real const | glimit_ |
| limit of the bottom box. | |
| Real const | gvol_ |
| volume of each box and of the remaining tail. | |
| Real * | kn |
| kn holds coordinates, such that each rectangle has same area. | |
| Real * | wn |
| Real * | fn |
Additional Inherited Members | |
Protected Types inherited from MTRand | |
| enum | { M = 397 } |
| enum | { N = 624 } |
| enum | { SAVE = N + 1 } |
| typedef unsigned long | uint32 |
| unsigned integer type, at least 32 bits | |
Protected Member Functions inherited from MTRand | |
| void | initialize (const uint32 seed) |
| Initialize generator state with seed See Knuth TAOCP Vol 2, 3rd Ed, p.106 for multiplier. | |
| void | reload () |
| Generate N new values in state Made disposeer and faster by Matthew Bellew (matth.nosp@m.ew.b.nosp@m.ellew.nosp@m.@hom.nosp@m.e.com) | |
| uint32 | hiBit (const uint32 &u) const |
| High bit. | |
| uint32 | loBit (const uint32 &u) const |
| low bit. | |
| uint32 | loBits (const uint32 &u) const |
| low bits. | |
| uint32 | mixBits (const uint32 &u, const uint32 &v) const |
| mixed bits. | |
| uint32 | twist (const uint32 &m, const uint32 &s0, const uint32 &s1) const |
| twisted values. | |
| MTRand (const uint32 &oneSeed) | |
| Initialize with a simple uint32. | |
| MTRand (uint32 *const bigSeed, uint32 const seedLength=N) | |
| Initialize with a an array. | |
| MTRand () | |
| auto-initialize with /dev/urandom or time() and clock() | |
| double | rand () |
| real number in [0,1] | |
| double | rand (const double &n) |
| real number in [0,n] | |
| double | randExc () |
| real number in [0,1) | |
| double | randExc (const double &n) |
| real number in [0,n) | |
| double | randDblExc () |
| real number in (0,1) | |
| double | randDblExc (const double &n) |
| real number in (0,n) | |
| uint32 | randInt () |
| integer in [0,2^32-1] | |
| double | operator() () |
| same as rand(). | |
| uint32 | randInt (const uint32 &n) |
| integer in [0,n] for n < 2^32 | |
| double | rand53 () |
| Access to 53-bit random numbers (capacity of IEEE double precision). | |
| double | randNorm (const double &mean, const double &variance) |
| Access to nonuniform random number distributions. | |
| void | seed (const uint32 oneSeed) |
| Re-seeding functions with same behavior as initializers. | |
| void | seed (uint32 *const bigSeed, const uint32 seedLength) |
| Re-seeding functions with same behavior as initializers. | |
| void | seed () |
| Re-seeding functions with same behavior as initializers. | |
| void | save (uint32 *saveArray) const |
| Saving and loading generator state. | |
| void | load (uint32 *const loadArray) |
| Saving and loading generator state. | |
Static Protected Member Functions inherited from MTRand | |
| static uint32 | hash (time_t t, clock_t c) |
| Get a uint32 from t and c Better than uint32(x) in case x is floating point in [0,1] Based on code by Lawrence Kirby (fred@.nosp@m.gene.nosp@m.sis.d.nosp@m.emon.nosp@m..co.u.nosp@m.k) | |
Protected Attributes inherited from MTRand | |
| uint32 | state [N] |
| internal state | |
| uint32 * | pNext |
| Next value to get from state. | |
| int | left |
| number of values left before reload needed | |
class for the Base random generator.
This class inherit from MTRand which should not be used directly. Using RandBase, one get a Type safe generator for use in STK++ applications.
This class furnish :
For the exponential Law we remove the old method and use directly the inverse pdf method.
Definition at line 131 of file STK_RandBase.h.
|
inline |
Default constructor.
auto-initialize with /dev/urandom or time() and clock().
| glimit | maximal value of the boxes in the ziggourat method |
| gvol | volume of each box in the ziggourat method |
| gsize | number of boxes |
Definition at line 262 of file STK_RandBase.h.
References gaussInit().
|
inline |
Initialize with a simple int seed.
| oneSeed | seed of the generator |
| glimit | maximal value of the boxes in the ziggourat method |
| gvol | volume of each box in the ziggourat method |
| gsize | number of boxes |
Definition at line 257 of file STK_RandBase.h.
References gaussInit().
|
inline |
Initialize with a seed Array.
| bigSeed | seed of the generator |
| glimit | maximal value of the boxes in the ziggourat method |
| gvol | volume of each box in the ziggourat method |
| gsize | number of boxes |
Definition at line 163 of file STK_RandBase.h.
References gaussInit(), and MTRand::seed().
|
inline |
destructor.
Definition at line 267 of file STK_RandBase.h.
|
inlineprivate |
Initialization of the Zigourrat method.
Definition at line 324 of file STK_RandBase.h.
References fn, glimit_, gsize_, gvol_, kn, and wn.
Referenced by RandBase(), RandBase(), and RandBase().
|
inline |
Definition at line 204 of file STK_RandBase.h.
References MTRand::operator()().
|
inline |
|
inline |
real number in (0,1)
Definition at line 214 of file STK_RandBase.h.
References MTRand::randDblExc().
Referenced by randUnif().
real number in (0,n)
Definition at line 216 of file STK_RandBase.h.
References MTRand::randDblExc().
|
inline |
Pseudo-random int uniform generator.
![\[
f(x) = 1/(n+1), \quad 0\leq x \leq n
\]](form_272.png)
Return a [0,n] uniform integer number for n < 2^32 using the Mersenne Twister method. This is a wrapper of the MTRand class.
Definition at line 192 of file STK_RandBase.h.
References MTRand::randInt().
|
inline |
|
inline |
Pseudo-random exponential generator.
![\[
f(x) = \exp\left\{ -x \right\}.
\]](form_275.png)
Definition at line 320 of file STK_RandBase.h.
References randUnif().
Referenced by randGauss().
Pseudo-random gaussian generator of the gaussian probability law:
![\[ f(x) = \frac{1}{\sqrt{2\pi}}
\exp\left\{-\frac{x^2}{2}\right\}.
\]](form_274.png)
| mu | mean of the gaussian distribution |
| sigma | standard deviation of the gaussian distribution |
Definition at line 281 of file STK_RandBase.h.
References fn, glimit_, kn, randExp(), MTRand::randInt(), randUnif(), STK::sign(), and wn.
|
inline |
pseudo-random uniform generator.
This is a wrapper of the MTRand class.
![\[
f(x) = 1, \qquad 0< x <1
\]](form_273.png)
Definition at line 201 of file STK_RandBase.h.
References randDblExc().
Referenced by randExp(), and randGauss().
|
private |
Definition at line 250 of file STK_RandBase.h.
Referenced by gaussInit(), randGauss(), and ~RandBase().
limit of the bottom box.
Definition at line 243 of file STK_RandBase.h.
Referenced by gaussInit(), and randGauss().
Number of box for the gaussian ziggourat method.
[0] is bottom box and [size_-1] is top box.
Definition at line 241 of file STK_RandBase.h.
Referenced by gaussInit().
volume of each box and of the remaining tail.
Definition at line 245 of file STK_RandBase.h.
Referenced by gaussInit().
|
private |
kn holds coordinates, such that each rectangle has same area.
wn holds kn[i+1]/kn[i]. fn holds exp(-0.5 * kn[i] * kn[i]).
Definition at line 250 of file STK_RandBase.h.
Referenced by gaussInit(), randGauss(), and ~RandBase().
|
private |
Definition at line 250 of file STK_RandBase.h.
Referenced by gaussInit(), randGauss(), and ~RandBase().