DART
6.10.1
|
#include <Random.hpp>
Public Types | |
using | GeneratorType = std::mt19937 |
template<typename FloatType > | |
using | UniformRealDist = std::uniform_real_distribution< FloatType > |
template<typename IntType > | |
using | UniformIntDist = std::uniform_int_distribution< IntType > |
template<typename FloatType > | |
using | NormalRealDist = std::normal_distribution< FloatType > |
Static Public Member Functions | |
static GeneratorType & | getGenerator () |
Returns a mutable reference to the random generator. More... | |
static void | setSeed (unsigned int seed) |
Sets the seed value. More... | |
static unsigned int | generateSeed (bool applyGeneratedSeed=false) |
Generates a seed value using the default random device. More... | |
static unsigned int | getSeed () |
template<typename S > | |
static S | uniform (S min, S max) |
Returns a random number from an uniform distribution. More... | |
template<typename FixedSizeT > | |
static FixedSizeT | uniform (typename FixedSizeT::Scalar min, typename FixedSizeT::Scalar max) |
Returns a random vector or matrix from an uniform distribution. More... | |
template<typename DynamicSizeVectorT > | |
static DynamicSizeVectorT | uniform (int size, typename DynamicSizeVectorT::Scalar min, typename DynamicSizeVectorT::Scalar max) |
Returns a random vector from an uniform distribution. More... | |
template<typename DynamicSizeMatrixT > | |
static DynamicSizeMatrixT | uniform (int rows, int cols, typename DynamicSizeMatrixT::Scalar min, typename DynamicSizeMatrixT::Scalar max) |
Returns a random matrix from an uniform distribution. More... | |
template<typename S > | |
static S | normal (S mean, S sigma) |
Returns a random number from a normal distribution. More... | |
Static Private Member Functions | |
static unsigned int & | getSeedMutable () |
using dart::math::Random::GeneratorType = std::mt19937 |
using dart::math::Random::NormalRealDist = std::normal_distribution<FloatType> |
using dart::math::Random::UniformIntDist = std::uniform_int_distribution<IntType> |
using dart::math::Random::UniformRealDist = std::uniform_real_distribution<FloatType> |
|
static |
Generates a seed value using the default random device.
[in] | applyGeneratedSeed | Whether to apply the generated seed. |
|
static |
Returns a mutable reference to the random generator.
|
static |
|
staticprivate |
|
static |
Returns a random number from a normal distribution.
This template function can generate different scalar types of random numbers as:
float
, double
, long
doubleunsigned
] short
, [unsigned
] int
, [unsigned
] long
, [unsigned
] long
long
Example:
[in] | mean | Mean of the normal distribution. |
[in] | sigma | Standard deviation of the distribution. |
|
static |
Sets the seed value.
The same seed gives the same sequence of random values so that you can regenerate the same sequencial random values as long as you knot the seed value.
|
static |
Returns a random matrix from an uniform distribution.
This variant is meant to be used for dynamic-size matrix.
DynamicSizeMatrixT | The type of dynamic-size matrix. |
[in] | rows | The row size of the matrices. |
[in] | cols | The col size of the matrices. |
[in] | min | The constant value of the lower bound matrix. |
[in] | max | The constant value of the upper bound matrix. |
|
static |
Returns a random vector from an uniform distribution.
This variant is meant to be used for dynamic-size vector.
Example:
DynamicSizeVectorT | The type of dynamic-size vector. |
[in] | size | The size of the vectors. |
[in] | min | The constant value of the lower bound vector. |
[in] | max | The constant value of the upper bound vector. |
|
static |
Returns a random number from an uniform distribution.
This template function can generate different scalar types of random numbers as:
float
, double
, long
doubleunsigned
] short
, [unsigned
] int
, [unsigned
] long
, [unsigned
] long
long
and vectors and matrices as:
Example:
Note that the end of the range is closed for integer types (i.e., [int_min, int_max]), but open for floating-point types (i.e., [float_min, float_max)).
S | The type of random value. |
[in] | min | Lower bound of the distribution. |
[in] | max | Upper bound of the distribution. |
|
static |
Returns a random vector or matrix from an uniform distribution.
This is a helper function for the case that the each of lower and upper bound has an uniform element value in it. For example, the lower bound is [1, 1, 1] or [-2, -2].
This variant is meant to be used for fixed-size vector or matrix types. For dynamic-size types, please use other variants that takes the size of vector or matrix.
Example:
FixedSizeT | The type of fixed-size vector or fixed-size matrix. |
[in] | min | The constant value of the lower bound. |
[in] | max | The constant value of the upper bound. |