|
FML
|
This is a class for having a unified interface for random numbers in the library. More...
#include <RandomGenerator.h>
Inherited by FML::RANDOM::GSLRandomGenerator.
Public Member Functions | |
| RandomGenerator ()=default | |
| virtual | ~RandomGenerator ()=default |
| RandomGenerator (unsigned int seed) | |
| Construct and initialize random number generator. | |
| RandomGenerator (std::vector< unsigned int > seed) | |
| Construct and initialize random number generator. | |
| void | set_normal_sigma (double _sigma) |
| Set the standard deviation sigma used when generating a normal distributed random number. | |
| double | get_normal_sigma () const |
| The standard deviation used for normal distributed random numbers. | |
| std::string | get_name () const |
| The name of the generator. | |
| virtual std::unique_ptr< RandomGenerator > | clone () const |
| Make a clone of the state of the random number generator. | |
| virtual void | set_seed (std::vector< unsigned int > seed) |
| Set the seed (vector of numbers as some rngs have a large state) | |
| virtual void | set_seed (unsigned int seed) |
| Set the seed (single number) | |
| virtual double | generate_uniform () |
| Generate a random number uniformly distributed in [0,1) | |
| virtual double | generate_normal () |
| Generate a random number with a normal distribution N(0,sigma) where sigma by default is 1. | |
Protected Attributes | |
| std::vector< unsigned int > | Seed |
| std_random_generator_type | generator |
| std::uniform_real_distribution< double > | uniform_dist {0.0, 1.0} |
| std::normal_distribution< double > | normal_dist {0.0, 1.0} |
| std::string | name {STDRANDOM_NAME} |
| double | sigma = 1.0 |
This is a class for having a unified interface for random numbers in the library.
If you want to use a different RNG other than c++ random (fiducial: mt19937) or GSL then make a class that inherits from this class and implement the 3-4 methods it has.
Definition at line 36 of file RandomGenerator.h.
|
default |
|
virtualdefault |
|
inline |
Construct and initialize random number generator.
Definition at line 51 of file RandomGenerator.h.
|
inline |
Construct and initialize random number generator.
Definition at line 54 of file RandomGenerator.h.
|
inlinevirtual |
Make a clone of the state of the random number generator.
Reimplemented in FML::RANDOM::GSLRandomGenerator.
Definition at line 69 of file RandomGenerator.h.
|
inlinevirtual |
Generate a random number with a normal distribution N(0,sigma) where sigma by default is 1.
NB: std::normal_distribution is implementation defined, so the numbers differ between standard libraries (e.g. GCC's libstdc++ and Clang's libc++ on Mac) for the same seed. Use the GSL generator for numbers that are the same everywhere.
Reimplemented in FML::RANDOM::GSLRandomGenerator.
Definition at line 95 of file RandomGenerator.h.
|
inlinevirtual |
Generate a random number uniformly distributed in [0,1)
Reimplemented in FML::RANDOM::GSLRandomGenerator.
Definition at line 89 of file RandomGenerator.h.
|
inline |
|
inline |
The standard deviation used for normal distributed random numbers.
Definition at line 63 of file RandomGenerator.h.
|
inline |
Set the standard deviation sigma used when generating a normal distributed random number.
Definition at line 57 of file RandomGenerator.h.
|
inlinevirtual |
Set the seed (vector of numbers as some rngs have a large state)
Reimplemented in FML::RANDOM::GSLRandomGenerator.
Definition at line 72 of file RandomGenerator.h.
|
inlinevirtual |
Set the seed (single number)
Reimplemented in FML::RANDOM::GSLRandomGenerator.
Definition at line 83 of file RandomGenerator.h.
|
protected |
Definition at line 39 of file RandomGenerator.h.
|
protected |
Definition at line 42 of file RandomGenerator.h.
|
protected |
Definition at line 41 of file RandomGenerator.h.
|
protected |
Definition at line 38 of file RandomGenerator.h.
|
protected |
Definition at line 44 of file RandomGenerator.h.
|
protected |
Definition at line 40 of file RandomGenerator.h.