A random number generator. More...
#include <random_number_generator.hpp>
Public Member Functions | |
T | gaussian (const T &std, const T &mu=0) |
RandomNumberGenerator (const unsigned int randSeed) | |
RandomNumberGenerator () | |
T | uniform (const T &range) |
T | uniform () |
Static Private Member Functions | |
static void | seed () |
Seed the system random number generator. |
A random number generator.
Definition at line 41 of file random_number_generator.hpp.
ecl::RandomNumberGenerator< T >::RandomNumberGenerator | ( | const unsigned int | randSeed | ) | [inline] |
Definition at line 44 of file random_number_generator.hpp.
ecl::RandomNumberGenerator< T >::RandomNumberGenerator | ( | ) | [inline] |
Definition at line 49 of file random_number_generator.hpp.
T ecl::RandomNumberGenerator< T >::gaussian | ( | const T & | std, |
const T & | mu = 0 |
||
) | [inline] |
Definition at line 64 of file random_number_generator.hpp.
static void ecl::RandomNumberGenerator< T >::seed | ( | ) | [inline, static, private] |
Seed the system random number generator.
Here we create a seed by hashing from three independent sources. This is a more robust way to get a reliable seed that allows you to get the typically para-optimal traits
1) fine grained (e.g. you want to call srand two times in a *very* short interval) 2) low chance of collisions over a long period
It also avoids having to use esoteric linux functions lick clock_gettime that aren't available on all platforms.
References:
-h ttp://stackoverflow.com/questions/322938/recommended-way-to-initialize-srand
Definition at line 111 of file random_number_generator.hpp.
T ecl::RandomNumberGenerator< T >::uniform | ( | const T & | range | ) | [inline] |
Definition at line 54 of file random_number_generator.hpp.
T ecl::RandomNumberGenerator< T >::uniform | ( | ) | [inline] |
Definition at line 59 of file random_number_generator.hpp.