UFJF - Machine Learning Toolkit  0.51.8
mltk::random Namespace Reference

Namespace for random number generation (Mersenne Twister pseudorandom generator). More...

Functions

size_t init (unsigned int seed=0)
 Initialize the mersenne twister pseudorandom number generator. More...
 
template<typename Integral = int, typename Integral1 , typename Distribution = std::uniform_int_distribution<Integral>>
Integral intInRange (Integral low, Integral1 high)
 Returns a integer between low and high. More...
 
template<typename Real = double, typename Distribution = std::uniform_real_distribution<Real>>
Real floatInRange (Real low, Real high)
 Returns a float between low and high. More...
 
size_t getSeed ()
 Get the seed used in the mersenne twister. More...
 
template double floatInRange< double, std::uniform_real_distribution< double > > (double, double)
 
template double floatInRange< double, std::normal_distribution< double > > (double, double)
 
template float floatInRange< float, std::uniform_real_distribution< float > > (float, float)
 
template float floatInRange< float, std::normal_distribution< float > > (float, float)
 
template double floatInRange< double, std::gamma_distribution< double > > (double, double)
 
template float floatInRange< float, std::gamma_distribution< float > > (float, float)
 
template double floatInRange< double, std::fisher_f_distribution< double > > (double, double)
 
template float floatInRange< float, std::fisher_f_distribution< float > > (float, float)
 
template int intInRange< int, int, std::uniform_int_distribution< int > > (int, int)
 
template size_t intInRange< size_t, size_t, std::uniform_int_distribution< size_t > > (size_t, size_t)
 
template int intInRange< int, unsigned long, std::uniform_int_distribution< int > > (int, unsigned long)
 
template int intInRange< int, unsigned int, std::uniform_int_distribution< int > > (int, unsigned int)
 

Variables

unsigned int seed_param = 1
 
std::mt19937 m_generator {std::random_device{}()}
 

Detailed Description

Namespace for random number generation (Mersenne Twister pseudorandom generator).

Function Documentation

◆ floatInRange()

template<typename Real = double, typename Distribution = std::uniform_real_distribution<Real>>
Real mltk::random::floatInRange ( Real  low,
Real  high 
)
inline

Returns a float between low and high.

Parameters
lowLowest possible float.
highHighest possible float.
Returns
float

◆ getSeed()

size_t mltk::random::getSeed ( )

Get the seed used in the mersenne twister.

Returns
unsigned int

◆ init()

size_t mltk::random::init ( unsigned int  seed = 0)

Initialize the mersenne twister pseudorandom number generator.

Parameters
seedSeed used to generate the numbers.
Returns
unsigned int

◆ intInRange()

template<typename Integral = int, typename Integral1 , typename Distribution = std::uniform_int_distribution<Integral>>
Integral mltk::random::intInRange ( Integral  low,
Integral1  high 
)
inline

Returns a integer between low and high.

Parameters
lowLowest possible integer.
highHighest possible integer.
Returns
int