Class for random number generator.
More...
#include <RNG.hpp>
Class for random number generator.
This class is used to set a seed for the random number generator and get a random integer or a random double between two values.
http://madrabbit.org/~ray/code/xorshf96.c with period 2^96-1
Definition at line 70 of file RNG.hpp.
◆ result_type
◆ getPrivateSeed()
Get private values.
Definition at line 148 of file RNG.hpp.
◆ getSeed()
static int RNG::getSeed |
( |
| ) |
|
|
inlinestatic |
Get current seed.
- Returns
- An integer in [0,UINT32_MAX].
Definition at line 82 of file RNG.hpp.
◆ max()
◆ min()
◆ normalRand()
static double RNG::normalRand |
( |
double |
Mean = 0 , |
|
|
double |
Var = 1 |
|
) |
| |
|
static |
Get a random number approaching a normal distribution N(Mean,Var) as double.
A series of Nsample random numbers Xi in the interval [-sqrt(3*Var);+sqrt(3*Var)] is used -> E[Xi] = 0, Var(Xi) = var.
See http://en.wikipedia.org/wiki/Central_limit_theorem
- Parameters
-
Mean | Mean of the target normal distribution – IN. |
Var | Variance of the target normal distribution – IN. |
- Returns
- A random number.
◆ normalRandMean0()
static double RNG::normalRandMean0 |
( |
double |
Var = 1 , |
|
|
int |
Nsample = 12 |
|
) |
| |
|
static |
Get a random number using a normal distribution centered on 0.
Get a random number approaching a normal distribution (N(0,Var)) as double
- Parameters
-
Var | Variance of the target normal distribution – IN. |
Nsample | Number of samples for averaging – IN. |
- Returns
- A double in the interval [-sqrt(3*Var);+sqrt(3*Var)].
◆ operator()()
Functor to get a random integer.
- Returns
- An integer in the interval [0,UINT32_MAX].
Definition at line 103 of file RNG.hpp.
◆ rand() [1/2]
Get a random integer.
- Returns
- An integer in the interval [0,UINT32_MAX].
◆ rand() [2/2]
static double RNG::rand |
( |
double |
a, |
|
|
double |
b |
|
) |
| |
|
inlinestatic |
Get a random number having a normal distribution as double.
- Parameters
-
a | Lower bound – IN. |
b | Upper bound – IN. |
- Returns
- A double in the interval [a,b].
Definition at line 111 of file RNG.hpp.
◆ resetPrivateSeedToDefault()
static void RNG::resetPrivateSeedToDefault |
( |
| ) |
|
|
inlinestatic |
Reset seed to its default value.
Definition at line 140 of file RNG.hpp.
◆ setPrivateSeed()
Reset seed to given values.
Used to set back RNG in a known state.
Definition at line 159 of file RNG.hpp.
◆ setSeed()
static void RNG::setSeed |
( |
int |
s | ) |
|
|
static |
◆ _s
◆ _x
◆ _y
◆ _z
Current values for the random number generator.
Definition at line 169 of file RNG.hpp.
◆ x_def
◆ y_def
◆ z_def
Initial values for the random number generator.
Definition at line 168 of file RNG.hpp.
The documentation for this class was generated from the following file:
- /home/nomad/Git/nomad/src/Math/RNG.hpp