A random number generator, uniform in the range 0-1. More...
#include <yarp/math/RandScalar.h>
Inheritance diagram for yarp::math::RandScalar:Public Member Functions | |
| RandScalar (int seed) | |
| RandScalar () | |
| ~RandScalar () | |
| void | init () |
| Initialize the random generator using current time (time(0)). | |
| void | init (int seed) |
| Initialize the random generator. | |
| int | getSeed () |
| Get the seed. | |
| double | get () |
| Generate a random number from a uniform distribution. | |
| double | get (double min, double max) |
| Generate a random number from a uniform distribution within [min, max]. | |
A random number generator, uniform in the range 0-1.
This class is a simple wrapper around C++11 Mersenne Twister engine.
The generator is always initialized with a seed equal to the current time. You can reset the seed by explicitly calling Rand::init(seed).
Default generator is std::mt19937.
Definition at line 26 of file RandScalar.h.
| RandScalar::RandScalar | ( | int | seed | ) |
Definition at line 32 of file RandScalar.cpp.
| RandScalar::RandScalar | ( | ) |
Definition at line 26 of file RandScalar.cpp.
| RandScalar::~RandScalar | ( | ) |
Definition at line 39 of file RandScalar.cpp.
| double RandScalar::get | ( | ) |
Generate a random number from a uniform distribution.
Definition at line 44 of file RandScalar.cpp.
| double RandScalar::get | ( | double | min, |
| double | max | ||
| ) |
Generate a random number from a uniform distribution within [min, max].
Definition at line 50 of file RandScalar.cpp.
|
inline |
| void RandScalar::init | ( | ) |
Initialize the random generator using current time (time(0)).
Definition at line 57 of file RandScalar.cpp.
| void RandScalar::init | ( | int | seed | ) |
Initialize the random generator.
| seed | the seed. |
Definition at line 64 of file RandScalar.cpp.