#include <trng.h>
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<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 |
the half of the maximum value that the random number gernerator's method rand() can return. |
Definition at line 133 of file trng.h.
|
Returns a pointer to a zero terminated string containing the pseudo random number generator's name.
|
|
The pseudo random number generator's parameters are set to some default values. |
|
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.
|
|
This is the generator's core method. It calculates the next pseudo random number. It's an integer number
Definition at line 191 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 199 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 225 of file trng.h. Referenced by TRNG::RNG< LCG32 >::uniforml(). |
|
|
|
Definition at line 243 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 283 of file trng.h. Referenced by TRNG::RNG< LCG32 >::exp_dist(). |
|
|
|
Definition at line 303 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 354 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 395 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 478 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 556 of file trng.h. Referenced by TRNG::RNG< LCG32 >::binomial_dist(). |
|
The ![]()
Definition at line 581 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 603 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 935 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 972 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. |