#include <trng.h>
Inheritance diagram for TRNG::RNG:
Public Methods | |
const char* | name (void) |
pseudo random number generator's name. More... | |
void | reset (void) |
reset the pseudo random number generator. More... | |
void | seed (long s=0l) |
seed the pseudo random number generator. More... | |
long | rand (void) |
next pseudo random number. More... | |
long | max (void) |
maximal pseudo random number. More... | |
bool | boolean (void) |
pseudo random boolean. More... | |
bool | boolean (const double p) |
pseudo random boolean. More... | |
double | uniform (void) |
pseudo random number. More... | |
double | uniform (const double a, const double b) |
pseudo random number. More... | |
double | uniformco (void) |
pseudo random number. More... | |
double | uniformco (const double a, const double b) |
pseudo random number. More... | |
double | uniformcc (void) |
pseudo random number. More... | |
double | uniformcc (const double a, const double b) |
pseudo random number. More... | |
double | uniformoc (void) |
pseudo random number. More... | |
double | uniformoc (const double a, const double b) |
pseudo random number. More... | |
double | uniformoo (void) |
pseudo random number. More... | |
double | uniformoo (const double a, const double b) |
pseudo random number. More... | |
long | uniforml (const long b) |
pseudo random number. More... | |
long | uniforml (const long a, const long b) |
pseudo random number. More... | |
double | normal_dist (const double sigma=1.0, const double mu=0.0) |
pseudo random number. More... | |
double | exp_dist (const double mu=1.0) |
pseudo random number. More... | |
double | laplace_dist (const double a=1.0) |
pseudorandom number. More... | |
double | tent_dist (const double a=1.0) |
pseudorandom number. More... | |
double | Gamma_dist (const double a, const double b) |
pseudo random number. More... | |
double | Beta_dist (const double a, const double b) |
pseudo random number. More... | |
double | chi_square_dist (const double nu) |
pseudo random number. More... | |
long | binomial_dist (long n, double p=0.5) |
pseudo random number. More... | |
long | binomial_dist_tab (long n, double p=0.5) |
pseudo random number. More... | |
double | Student_t_dist (const double nu) |
pseudo random number. More... | |
long | poisson_dist (double mu=1.0) |
pseudo random number. More... | |
long | geometric_dist (double q) |
pseudo random number. More... | |
template<classt_function> double | rejection<t_function> (t_function p, double a1, double a2, double p_max) |
pseudo random number. More... | |
long | discrete_dist (const std::vector<double> p) |
pseudo random number. More... | |
vector2d | spherical2d (void) |
pseudo random vector. More... | |
vector3d | spherical3d (void) |
pseudo random vector. More... | |
vector4d | spherical4d (void) |
pseudo random vector. More... | |
void | split (long s, long n) |
sequence splitting. More... | |
void | jump (long long s) |
sequence splitting. More... | |
void | jump (long long s, long n) |
sequence splitting. More... | |
void | jump2 (long s) |
sequence splitting. More... | |
void | jump2 (long s, long n) |
sequence splitting. More... | |
void | save_status (std::vector<long> &s) |
status saving. More... | |
void | load_status (const std::vector<long> &s) |
status restoring. More... | |
Static Public Attributes | |
const TRNG::RNG_type | type = RNG_t |
pseudo random number generator type. More... | |
Protected Attributes | |
long | max_val |
maximum value that the random number gernerator's method rand() can return. More... | |
long | max_val2 |
the half of the maximum value that the random number gernerator's method rand() can return. More... |
All the pseudo random number generators are derived form this base class. Routines for generation of uniform and nonuniform variartes are implemented in this base class. Generator specific tasks like sequence splitting or leapfrog method are implementetd by the derived classes. The method rand(), the generator's core method, has of course also to be reimplemented for every new generator.
Definition at line 126 of file trng.h.
|
Returns a pointer to a zero terminated string containing the pseudo random number generator's name.
Reimplemented in TRNG::ParkMiller, TRNG::LCG32, TRNG::LCG64, TRNG::MRG2, TRNG::MRG3, TRNG::MRG4, TRNG::CLCG2, TRNG::CLCG3, TRNG::CLCG4, TRNG::EINV, and TRNG::EINVLCG64. |
|
The pseudo random number generator's parameters are set to some default values. Reimplemented in TRNG::ParkMiller, TRNG::LCG32, TRNG::LCG64, TRNG::MRG2, TRNG::MRG3, TRNG::MRG4, TRNG::CLCG2, TRNG::CLCG3, TRNG::CLCG4, TRNG::EINV, and TRNG::EINVLCG64. |
|
The pseudo random number generator's state is set. Calling reset() and seed() with the seed value used by the initialisation will set the generator in the same state as after initialisation.
Reimplemented in TRNG::ParkMiller, TRNG::LCG32, TRNG::LCG64, TRNG::MRG2, TRNG::MRG3, TRNG::MRG4, TRNG::CLCG2, TRNG::CLCG3, TRNG::CLCG4, TRNG::EINV, and TRNG::EINVLCG64. |
|
This is the generator's core method. It calculates the next pseudo random number. It's an integer number
Reimplemented in TRNG::ParkMiller, TRNG::LCG32, TRNG::LCG64, TRNG::MRG2, TRNG::MRG3, TRNG::MRG4, TRNG::CLCG2, TRNG::CLCG3, TRNG::CLCG4, TRNG::EINV, and TRNG::EINVLCG64. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
A normal distributed random variate has a probability density ![]() This method uses the polar (Box-Mueller) method.
|
|
A exponential distributed random variate has a probability density ![]() One random number is used to get one random number with exponential distribution.
|
|
The two-sided exponential probability distribution is ![]() It is also known as the Laplace distribution. The is implementation adopted from the GNU scientific library and uses a simple transformation method. One random number is used to get one random number with Laplace distribution.
|
|
This method generates a pseudo randeom number with a tent shaped probability distribution. ![]() The implementation uses a simple transformation method. One random number is used to get one random number with a tent shaped distribution.
|
|
A gamma distributed random number has a probability density ![]() The is implemetation adopted from the GNU scientific library.
|
|
A Beta distributed random number has a probability density ![]()
|
|
The ![]()
|
|
The binomial distribution is a discrete distribution with ![]() The implemetation is adopted from the GNU scientific library.
|
|
The binomial distribution is a discrete distribution with ![]() This method's implementation uses a lookup table and is very fast if this method is called often with the same parameter set.
|
|
Student's ![]() This method's implementation is adopted from the GNU scientific library.
|
|
The probability distribution for Poisson variates is ![]() This method's implementation is adopted from the GNU scientific library.
|
|
The geometric probability distribution is ![]() This method's implementation is adopted from the GNU scientific library.
|
|
Returns a random number calculated by the rejection method. Assume your desired probability distribution is class p { public: double operator()(double x) { return 0.75*(1.0-x*x); } }; my_rng.rejection(p(), -1.0, 1.0, 0.75) ![]()
|
|
This method can be used to generate discrete random variates with an arbitrary probability distribution. The algorithm is
|
|
This method calculates a unit vector with a uniform distributed direction in two dimensions. For a vector uniform distributed inside the unit citcle multiply the vector with
|
|
This method calculates a unit vector with a uniform distributed direction in three dimensions. For a vector uniform distributed inside the unit shere multiply the vector with
|
|
This method calculates a unit vector with a uniform distributed direction in four dimensions. For a vector uniform distributed inside the unit hyper-shere multiply the vector with
|
|
The pseudo random number generator's sequence is splitted into
Reimplemented in TRNG::ParkMiller, TRNG::LCG32, TRNG::LCG64, TRNG::MRG2, TRNG::MRG3, TRNG::MRG4, TRNG::CLCG2, TRNG::CLCG3, TRNG::CLCG4, TRNG::EINV, and TRNG::EINVLCG64. |
|
The pseudo random number generator jumps
|
|
The pseudo random number generator jumps
|
|
The pseudo random number generator jumps
Reimplemented in TRNG::ParkMiller, TRNG::LCG32, TRNG::LCG64, TRNG::MRG2, TRNG::MRG3, TRNG::MRG4, TRNG::CLCG2, TRNG::CLCG3, TRNG::CLCG4, TRNG::EINV, and TRNG::EINVLCG64. |
|
The pseudo random number generator jumps
|
|
The status of the pseudo random number generator is saved into a vector.
Reimplemented in TRNG::ParkMiller, TRNG::LCG32, TRNG::LCG64, TRNG::MRG2, TRNG::MRG3, TRNG::MRG4, TRNG::CLCG2, TRNG::CLCG3, TRNG::CLCG4, TRNG::EINV, and TRNG::EINVLCG64. |
|
The status of the pseudo random number generator is restored from a vector.
Reimplemented in TRNG::ParkMiller, TRNG::LCG32, TRNG::LCG64, TRNG::MRG2, TRNG::MRG3, TRNG::MRG4, TRNG::CLCG2, TRNG::CLCG3, TRNG::CLCG4, TRNG::EINV, and TRNG::EINVLCG64. |
|
|
|
|
|
This numerical value determins the random number generator type. Reimplemented in TRNG::ParkMiller, TRNG::LCG32, TRNG::LCG64, TRNG::MRG2, TRNG::MRG3, TRNG::MRG4, TRNG::CLCG2, TRNG::CLCG3, TRNG::CLCG4, TRNG::EINV, and TRNG::EINVLCG64. |