32 #ifndef SHARK_RNG_DISCRETEUNIFORM_H 33 #define SHARK_RNG_DISCRETEUNIFORM_H 37 #include <boost/random.hpp> 47 template<
typename RngType = shark::DefaultRngType>
48 class DiscreteUniform :
public boost::variate_generator<RngType*,boost::uniform_int<std::size_t> > {
51 typedef boost::variate_generator<RngType*,boost::uniform_int<std::size_t> > Base;
68 using Base::operator();
77 typename Base::result_type
operator()(std::size_t low_,std::size_t high_)
79 boost::uniform_int<std::size_t> dist(
std::min(low_,high_),
std::max(low_,high_));
80 return dist(Base::engine());
84 std::size_t
low()
const 86 return Base::distribution().min();
92 return Base::distribution().max();
96 void setRange(std::size_t low_,std::size_t high_)
98 boost::uniform_int<std::size_t> dist(
std::min(low_,high_),
std::max(low_,high_));
99 Base::distribution()=dist;
103 double p( std::size_t x )
const {
110 template<
class RngType>