21 #ifndef __MLPACK_CORE_MATH_RANDOM_HPP 22 #define __MLPACK_CORE_MATH_RANDOM_HPP 25 #include <boost/random.hpp> 31 #include <boost/version.hpp> 33 #if BOOST_VERSION >= 104700 35 extern boost::random::mt19937
randGen;
44 #if BOOST_VERSION >= 103900 65 randGen.seed((uint32_t) seed);
66 srand((
unsigned int) seed);
67 #if ARMA_VERSION_MAJOR > 3 || \ 68 (ARMA_VERSION_MAJOR == 3 && ARMA_VERSION_MINOR >= 930) 71 arma::arma_rng::set_seed(seed);
80 #if BOOST_VERSION >= 103900 92 inline double Random(
const double lo,
const double hi)
94 #if BOOST_VERSION >= 103900 108 #if BOOST_VERSION >= 103900 109 return (
int) std::floor((
double) hiExclusive *
randUniformDist(randGen));
120 inline int RandInt(
const int lo,
const int hiExclusive)
122 #if BOOST_VERSION >= 103900 123 return lo + (int) std::floor((
double) (hiExclusive - lo)
128 return lo + (int) std::floor((
double) (hiExclusive - lo)
149 inline double RandNormal(
const double mean,
const double variance)
157 #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.