13 #ifndef __MLPACK_CORE_MATH_RANDOM_HPP
14 #define __MLPACK_CORE_MATH_RANDOM_HPP
17 #include <boost/random.hpp>
23 #include <boost/version.hpp>
25 #if BOOST_VERSION >= 104700
27 extern boost::random::mt19937
randGen;
36 #if BOOST_VERSION >= 103900
57 randGen.seed((uint32_t) seed);
58 srand((
unsigned int) seed);
59 #if ARMA_VERSION_MAJOR > 3 || \
60 (ARMA_VERSION_MAJOR == 3 && ARMA_VERSION_MINOR >= 930)
63 arma::arma_rng::set_seed(seed);
72 #if BOOST_VERSION >= 103900
84 inline double Random(
const double lo,
const double hi)
86 #if BOOST_VERSION >= 103900
100 #if BOOST_VERSION >= 103900
101 return (
int) std::floor((
double) hiExclusive *
randUniformDist(randGen));
112 inline int RandInt(
const int lo,
const int hiExclusive)
114 #if BOOST_VERSION >= 103900
115 return lo + (int) std::floor((
double) (hiExclusive - lo)
120 return lo + (int) std::floor((
double) (hiExclusive - lo)
141 inline double RandNormal(
const double mean,
const double variance)
149 #endif // __MLPACK_CORE_MATH_MATH_LIB_HPP
boost::uniform_01< boost::mt19937, double > randUniformDist
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
void RandomSeed(const size_t seed)
Set the random seed used by the random functions (Random() and RandInt()).
double RandNormal()
Generates a normally distributed random number with mean 0 and variance 1.
double Random()
Generates a uniform random number between 0 and 1.
boost::normal_distribution randNormalDist
int RandInt(const int hiExclusive)
Generates a uniform random integer.