Empirical
|
A versatile and non-patterned pseudo-random-number generator (Mersenne Twister). More...
#include <ce_random.h>
Public Member Functions | |
constexpr | Random (const int _seed=-1) |
~Random ()=default | |
constexpr int | GetSeed () const |
constexpr int | GetOriginalSeed () const |
constexpr void | ResetSeed (const int _seed) |
constexpr double | GetDouble () |
constexpr double | GetDouble (const double max) |
constexpr double | GetDouble (const double min, const double max) |
constexpr uint32_t | GetUInt (const uint32_t max) |
constexpr uint32_t | GetUInt (const uint32_t min, const uint32_t max) |
constexpr int32_t | GetInt (const int max) |
constexpr int32_t | GetInt (const int min, const int max) |
constexpr bool | P (const double _p) |
constexpr double | GetRandNormal () |
constexpr double | GetRandNormal (const double mean, const double std) |
constexpr uint32_t | GetRandPoisson (const double mean) |
constexpr uint32_t | GetRandPoisson (const double n, double p) |
constexpr uint32_t | GetFullRandBinomial (const double n, const double p) |
constexpr uint32_t | GetRandBinomial (const double n, const double p) |
Random (const int _seed=-1) | |
~Random () | |
int | GetSeed () const |
int | GetOriginalSeed () const |
void | ResetSeed (const int _seed) |
double | GetDouble () |
double | GetDouble (const double max) |
double | GetDouble (const double min, const double max) |
double | GetDouble (const Range< double > range) |
template<typename T > | |
uint32_t | GetUInt (const T max) |
template<typename T > | |
uint64_t | GetUInt64 (const T max) |
template<typename T1 , typename T2 > | |
uint32_t | GetUInt (const T1 min, const T2 max) |
template<typename T > | |
uint32_t | GetUInt (const Range< T > range) |
int | GetInt (const int max) |
int | GetInt (const int min, const int max) |
int | GetInt (const Range< int > range) |
bool | P (const double p) |
double | GetRandNormal () |
double | GetRandNormal (const double mean, const double std) |
uint32_t | GetRandPoisson (const double n, double p) |
uint32_t | GetRandPoisson (const double mean) |
uint32_t | GetFullRandBinomial (const double n, const double p) |
uint32_t | GetRandBinomial (const double n, const double p) |
Protected Member Functions | |
constexpr void | init () |
constexpr uint32_t | Get () |
void | init () |
int32_t | Get () |
Protected Attributes | |
int | seed |
Current random number seed. More... | |
int | original_seed |
Orignal random number seed when object was first created. More... | |
int | inext |
First position in use in internal state. More... | |
int | inextp |
Second position in use in internal state. More... | |
int | ma [56] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } |
Internal state of RNG. More... | |
double | expRV |
Static Protected Attributes | |
static const uint32_t | _BINOMIAL_TO_NORMAL = 50 |
static const uint32_t | _BINOMIAL_TO_POISSON = 1000 |
static const uint32_t | _RAND_MBIG = 1000000000 |
static const uint32_t | _RAND_MSEED = 161803398 |
static const int32_t | _BINOMIAL_TO_NORMAL = 50 |
static const int32_t | _BINOMIAL_TO_POISSON = 1000 |
static const int32_t | _RAND_MBIG = 1000000000 |
static const int32_t | _RAND_MSEED = 161803398 |
A versatile and non-patterned pseudo-random-number generator (Mersenne Twister).
|
inline |
Set up the random generator object.
_seed | The seed of the random number generator. A negative seed means that the random number generator gets its seed from the actual system time. |
|
default |
|
inline |
Set up the random generator object.
_seed | The seed of the random number generator. A negative seed means that the random number generator gets its seed from a combination of the actual system time and the memory position of the random number generator. |
|
inline |
|
inlineprotected |
|
inlineprotected |
|
inline |
Generate a double between 0.0 and 1.0
|
inline |
Generate a double between 0 and a given number.
max | The upper bound for the random numbers (will never be returned). |
|
inline |
Generate a double between 0.0 and 1.0
|
inline |
Generate a double out of a given interval.
min | The lower bound for the random numbers. |
max | The upper bound for the random numbers (will never be returned). |
|
inline |
Generate a double between 0 and a given number.
max | The upper bound for the random numbers (will never be returned). |
|
inline |
Generate a double out of a given interval.
range | The upper and lower bounds for the random numbers [lower, upper) |
|
inline |
Generate a double out of a given interval.
min | The lower bound for the random numbers. |
max | The upper bound for the random numbers (will never be returned). |
|
inline |
Generate a random variable drawn from a Binomial distribution.
This function is exact, but slow.
|
inline |
Generate a random variable drawn from a Binomial distribution.
This function is exact, but slow.
|
inline |
Generate an int out of an interval.
min | The lower bound for the random numbers. |
max | The upper bound for the random numbers (will never be returned). |
|
inline |
|
inline |
Generate an int out of an interval.
min | The lower bound for the random numbers. |
max | The upper bound for the random numbers (will never be returned). |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Generate a random variable drawn from a Binomial distribution.
This function is faster than Random::GetFullRandBinomial(), but uses some approximations.
|
inline |
Generate a random variable drawn from a Binomial distribution.
This function is faster than Random::GetFullRandBinomial(), but uses some approximations.
|
inline |
Generate a random variable drawn from a unit normal distribution.
|
inline |
Generate a random variable drawn from a distribution with given mean and standard deviation.
|
inline |
Generate a random variable drawn from a unit normal distribution.
|
inline |
Generate a random variable drawn from a distribution with given mean and standard deviation.
|
inline |
Generate a random variable drawn from a Poisson distribution.
mean | The mean of the distribution. |
|
inline |
Generate a random variable drawn from a Poisson distribution.
|
inline |
Generate a random variable drawn from a Poisson distribution.
|
inline |
Generate a random variable drawn from a Poisson distribution.
mean | The mean of the distribution. |
|
inline |
|
inline |
|
inline |
Generate an uint32_t.
max | The upper bound for the random numbers (will never be returned). |
|
inline |
Generate an uint32_t.
max | The upper bound for the random numbers (will never be returned). |
|
inline |
Generate an uint32_t out of an interval.
min | The lower bound for the random numbers. |
max | The upper bound for the random numbers (will never be returned). |
|
inline |
Generate an uint32_t out of an interval.
min | The lower bound for the random numbers. |
max | The upper bound for the random numbers (will never be returned). |
|
inline |
Generate a uint32_t out of a given interval.
range | The upper and lower bounds for the random numbers [lower, upper) |
|
inline |
Generate an uint64_t.
max | The upper bound for the random numbers (will never be returned). |
|
inlineprotected |
|
inlineprotected |
|
inline |
|
inline |
Tests a random value [0,1) against a given probability p, and returns true of false.
p | The probability of the result being "true". |
|
inline |
Starts a new sequence of pseudo random numbers.
new_seed | The seed for the new sequence. A negative seed means that the random number generator gets its seed from the actual system time and the process ID. |
|
inline |
Starts a new sequence of pseudo random numbers.
new_seed | The seed for the new sequence. A negative seed means that the random number generator gets its seed from the actual system time and the process ID. |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
protected |
|
protected |
First position in use in internal state.
|
protected |
Second position in use in internal state.
|
protected |
Internal state of RNG.
|
protected |
Orignal random number seed when object was first created.
|
protected |
Current random number seed.