A random number generator, uniform in the range 0-1. More...
#include <yarp/math/RandScalar.h>
Public Member Functions | |
RandScalar (int seed) | |
RandScalar () | |
~RandScalar () | |
void | init () |
Initialize the random generator using current time (time(0)). More... | |
void | init (int seed) |
Initialize the random generator. More... | |
int | getSeed () |
Get the seed. More... | |
double | get () |
Generate a random number from a uniform distribution. More... | |
double | get (double min, double max) |
Generate a random number from a uniform distribution within [min, max]. More... | |
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 31 of file RandScalar.h.
RandScalar::RandScalar | ( | int | seed | ) |
Definition at line 35 of file RandScalar.cpp.
RandScalar::RandScalar | ( | ) |
Definition at line 29 of file RandScalar.cpp.
RandScalar::~RandScalar | ( | ) |
Definition at line 42 of file RandScalar.cpp.
double RandScalar::get | ( | ) |
Generate a random number from a uniform distribution.
Definition at line 47 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 53 of file RandScalar.cpp.
|
inline |
void RandScalar::init | ( | ) |
Initialize the random generator using current time (time(0)).
Definition at line 60 of file RandScalar.cpp.
void RandScalar::init | ( | int | seed | ) |
Initialize the random generator.
seed | the seed. |
Definition at line 67 of file RandScalar.cpp.