boost-random

Using boost::random as the RNG for std::random_shuffle

I have a program that uses the mt19937 random number generator from boost::random. I need to do a random_shuffle and want the random numbers generated for this to be from this shared state so that they can be deterministic with respect to the mersenne twister's previously generated numbers. I tried something like this: void foo(std::ve...

Using boost::random to select from an std::list where elements are being removed

See this related question on more generic use of the Boost Random library. My questions involves selecting a random element from an std::list, doing some operation, which could potentally include removing the element from the list, and then choosing another random element, until some condition is satisfied. The boost code and for loop ...

Thread-safty of boost RNG

I have a loop which should be nicely pararellized by insering one openmp pragma: boost::normal_distribution<double> ddist(0, pow(retention, i - 1)); boost::variate_generator<gen &, BOOST_TYPEOF(ddist)> dgen(rng, ddist); // Diamond const std::uint_fast32_t dno = 1 <<...

How to generate random 64 bit ints with boost random

I'm trying to generate a random 64bit unsigned integer using boost random, but I'm getting an assertion failure with uniform_int. struct timeval tv; boost::mt19937 randGen(tval.tv_usec); boost::uniform_int<> uInt64Dist(0, std::numeric_limits<uint64_t>::max()); boost::variate_generator<boost::mt19937&, boost::uniform_int<> > getRand(rand...

Encapsulating boost::random for ease of usage to replace rand()

Hello, for my program I need pseudo random integers with different ranges. Until now I used the rand() function but it has it's limitations. I found the boost::random library to be a much better replacement but I didn't want to create random generators all over the place. ( I need random integers in many classes, because it's a stress t...