#include <trng.h>
Public Methods | |
const char * | name (void) |
Name of Pseudo random number generator. 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) |
Pseudo random number. More... | |
double | tent_dist (const double a=1.0) |
Pseudo random 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<class t_function> double | rejection (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. | |
long | max_val2 |
Half of the maximum value that method rand() of the random number gernerator can return. |
Definition at line 135 of file trng.h.
|
Returns a pointer to a zero terminated string containing the name of pseudo random number generator.
|
|
The parameters of the pseudo random number generator are set to some default values. |
|
The state of the pseudo random number generator 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.
|
|
This is core method of the generator. It calculates the next pseudo random number. It is an integer number
Definition at line 193 of file trng.h. Referenced by TRNG::RNG< LCG32 >::boolean(), TRNG::RNG< LCG32 >::uniformcc(), TRNG::RNG< LCG32 >::uniformco(), TRNG::RNG< LCG32 >::uniformoc(), and TRNG::RNG< LCG32 >::uniformoo(). |
|
Definition at line 201 of file trng.h. Referenced by TRNG::RNG< LCG32 >::boolean(), TRNG::RNG< LCG32 >::uniformcc(), TRNG::RNG< LCG32 >::uniformco(), TRNG::RNG< LCG32 >::uniformoc(), and TRNG::RNG< LCG32 >::uniformoo(). |
|
|
|
|
|
Definition at line 227 of file trng.h. Referenced by TRNG::RNG< LCG32 >::uniforml(). |
|
|
|
Definition at line 245 of file trng.h. Referenced by TRNG::RNG< LCG32 >::binomial_dist(), TRNG::RNG< LCG32 >::binomial_dist_tab(), TRNG::RNG< LCG32 >::discrete_dist(), TRNG::RNG< LCG32 >::Gamma_dist(), TRNG::RNG< LCG32 >::poisson_dist(), TRNG::RNG< LCG32 >::rejection(), TRNG::RNG< LCG32 >::spherical2d(), TRNG::RNG< LCG32 >::spherical3d(), TRNG::RNG< LCG32 >::spherical4d(), and TRNG::RNG< LCG32 >::uniform(). |
|
|
|
|
|
|
|
Definition at line 285 of file trng.h. Referenced by TRNG::RNG< LCG32 >::exp_dist(). |
|
|
|
Definition at line 305 of file trng.h. Referenced by TRNG::RNG< LCG32 >::Gamma_dist(), TRNG::RNG< LCG32 >::geometric_dist(), TRNG::RNG< LCG32 >::laplace_dist(), TRNG::RNG< LCG32 >::normal_dist(), and TRNG::RNG< LCG32 >::tent_dist(). |
|
|
|
|
|
|
|
A normal distributed random variate has a probability density ![]() This method uses the polar (Box-Mueller) method.
Definition at line 356 of file trng.h. Referenced by TRNG::RNG< LCG32 >::Student_t_dist(). |
|
A exponential distributed random variate has a probability density ![]() One random number is used to get one random number with exponential distribution.
Definition at line 389 of file trng.h. Referenced by TRNG::RNG< LCG32 >::Student_t_dist(). |
|
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.
Definition at line 472 of file trng.h. Referenced by TRNG::RNG< LCG32 >::Beta_dist(), TRNG::RNG< LCG32 >::chi_square_dist(), TRNG::RNG< LCG32 >::Gamma_dist(), and TRNG::RNG< LCG32 >::poisson_dist(). |
|
A Beta distributed random number has a probability density ![]()
Definition at line 550 of file trng.h. Referenced by TRNG::RNG< LCG32 >::binomial_dist(). |
|
The ![]()
Definition at line 575 of file trng.h. Referenced by TRNG::RNG< LCG32 >::Student_t_dist(). |
|
The binomial distribution is a discrete distribution with ![]() The implemetation is adopted from the GNU scientific library.
Definition at line 597 of file trng.h. Referenced by TRNG::RNG< LCG32 >::poisson_dist(). |
|
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
|
|
The pseudo random number generator jumps
Definition at line 929 of file trng.h. Referenced by TRNG::RNG< LCG32 >::jump(). |
|
The pseudo random number generator jumps
|
|
The pseudo random number generator jumps
Definition at line 966 of file trng.h. Referenced by TRNG::RNG< LCG32 >::jump(), and TRNG::RNG< LCG32 >::jump2(). |
|
The pseudo random number generator jumps
|
|
The status of the pseudo random number generator is saved into a vector.
|
|
The status of the pseudo random number generator is restored from a vector.
|
|
This numerical value determins the random number generator type. |