30 #ifndef MATH_UTIL_RANDOM_H_ 31 #define MATH_UTIL_RANDOM_H_ 35 #include <boost/random/mersenne_twister.hpp> 36 #include <boost/random/uniform_int.hpp> 37 #include <boost/shared_ptr.hpp> 38 #include <boost/thread/mutex.hpp> 41 #include <boost/nondet_random.hpp> 43 #include <boost/random/random_device.hpp> 49 namespace boost_random =
boost;
51 namespace boost_random = boost::random;
63 std::vector<int32_t>& sample);
66 boost_random::random_device
seed_;
67 boost_random::mt19937
rng_;
94 std::vector<int32_t>& sample)
109 int32_t range = (max - min) + 1;
115 sample.resize(count);
117 boost::uniform_int<> dist(min, max);
118 for (int32_t i = 0; i < count; i++)
120 bool has_sample =
false;
123 sample[i] = dist(rng);
125 for (j = 0; j < i; j++)
127 if (sample[i] == sample[j])
break;
135 #endif // MATH_UTIL_RANDOM_H_
RandomGenerator(int32_t seed=-1)
void GetUniformRandomSample(int32_t min, int32_t max, int32_t count, std::vector< int32_t > &sample)
boost::shared_ptr< RandomGenerator > RandomGeneratorPtr
boost_random::random_device seed_
boost_random::mt19937 rng_