Template class to easily generate random generators using the boost::random distributions and generators.
More...
#include <math/RandomGenerator.h>
|
| RandomGenerator () |
| Generates the random generator with default parameters for the random distribution. More...
|
|
| RandomGenerator (const Distribution &dist) |
| Generates the random generator with the parameters provided by the given distribution. More...
|
|
| RandomGenerator (const RandomGenerator &other) |
| Copy constructor that copies the distribution but initializes the random generator engine from the scratch, since engines cannot be copied. More...
|
|
RandomGenerator & | operator= (const Distribution &dist) |
| Assigns the given distribution (respectively its parameters) to this random generator. More...
|
|
RandomGenerator & | operator= (const RandomGenerator &other) |
| Assignment operator that copies the distribution but not the random generator engine, since engines cannot be copied. More...
|
|
result_type | operator() () |
| Draws a sample from the random distribution. More...
|
|
void | seed () |
| Seeds the random generator using the current system time. More...
|
|
void | seed (uint32 value) |
| Seeds the random generator with the given seed. More...
|
|
Distribution * | operator-> () |
| Provides direct access to the underlying random distribution. More...
|
|
const Distribution * | operator-> () const |
| Provides direct access to the underlying random distribution. More...
|
|
Distribution & | distribution () |
| Provides direct access to the underlying random distribution. More...
|
|
const Distribution & | distribution () const |
| Provides direct access to the underlying random distribution. More...
|
|
Engine & | engine () |
| Provides direct access to the underlying random generator engine. More...
|
|
const Engine & | engine () const |
| Provides direct access to the underlying random generator engine. More...
|
|
template<typename Distribution, typename Engine = boost::mt19937>
class mira::RandomGenerator< Distribution, Engine >
Template class to easily generate random generators using the boost::random distributions and generators.
The template takes two template parameters:
- A random distribution, e.g. NormalRandomDistribution or the boost random distributions
- The random generator engine, e.g. boost random engines, by default the Mersenne Twister (19937) is used.
Example:
RandomGenerator<boost::uniform_01<>> rnd;
for(int i=0; i<100; ++i)
double random_number=rnd();
There are also some predefined random generators:
◆ result_type
◆ RandomGenerator() [1/3]
Generates the random generator with default parameters for the random distribution.
The random generator is seeded with the default seed. Use the seed() method to set a different seed or to use the system time to generate a seed.
◆ RandomGenerator() [2/3]
Generates the random generator with the parameters provided by the given distribution.
The random generator is seeded with the default seed. Use the seed() method to set a different seed or to use the system time to generate a seed.
◆ RandomGenerator() [3/3]
Copy constructor that copies the distribution but initializes the random generator engine from the scratch, since engines cannot be copied.
Therfore, the copied generator has the same distribution including paramters etc, but produces a different random sequence unless it is called with the same seed.
◆ operator=() [1/2]
Assigns the given distribution (respectively its parameters) to this random generator.
◆ operator=() [2/2]
Assignment operator that copies the distribution but not the random generator engine, since engines cannot be copied.
Therfore, the copied generator has the same distribution including paramters etc, but produces a different random sequence unless it is called with the same seed.
◆ operator()()
Draws a sample from the random distribution.
◆ seed() [1/2]
Seeds the random generator using the current system time.
Hence, after calling this method, the random generator will generate different sequences of random numbers each time.
◆ seed() [2/2]
void seed |
( |
uint32 |
value | ) |
|
|
inline |
Seeds the random generator with the given seed.
The random generator will produce the same sequence of random numbers if the same seed is used.
◆ operator->() [1/2]
Distribution* operator-> |
( |
| ) |
|
|
inline |
Provides direct access to the underlying random distribution.
◆ operator->() [2/2]
const Distribution* operator-> |
( |
| ) |
const |
|
inline |
Provides direct access to the underlying random distribution.
◆ distribution() [1/2]
Distribution& distribution |
( |
| ) |
|
|
inline |
Provides direct access to the underlying random distribution.
◆ distribution() [2/2]
const Distribution& distribution |
( |
| ) |
const |
|
inline |
Provides direct access to the underlying random distribution.
◆ engine() [1/2]
Provides direct access to the underlying random generator engine.
◆ engine() [2/2]
const Engine& engine |
( |
| ) |
const |
|
inline |
Provides direct access to the underlying random generator engine.
The documentation for this class was generated from the following file: