c++,algorithm,random,mersenne-twister

Boost.Random provides quite a few thread-safe random generators, and they work with C++98.

tl;dr: Change your new MersenneTwister() to new MersenneTwister(new Date()) instead. Pseudo-random number generators use a seed to determine the sequence of numbers that come out. Generators will set a seed by default if you don't set one. Some generators use a different seed by default each time, such as by...

c++,boost,random,casting,mersenne-twister

Endianness has nothing to do with it. The "lower" 32 bits of a 64 bits value are bits 0-31, i.e. the bits with values 1<<0 to 1<<31. IOW, taing the lower 32 bits is just taking the value modulo 1<<32. And yes, for a clock that means taking the rapidly...

c,random,prng,mersenne-twister

Normally, any bit should be random, this is a property of the Mersenne twister. However (I do not know MT very deeply) you may have long-term dependence between some bits. It is recommended to use the library functions for setting the integer range, rather than arranging the bits yourself, or...

c++,random,prng,mersenne-twister

This happens because the return value of newr() and newr.max() are integers and the value returned by newr() is smaller than newr.mar(). The result of the division is a zero integer which is then converted to a double. To fix this use rn = static_cast<double>(newr()) / newr.max(); ...

c++,boost,prng,mersenne-twister

I don't know the underlying implementation of urand(), but using the result of a division is likely to produce bias in the low-order bits as a quantisation effect. If gen.max() isn't large then "low-order bits" may be very many or most of the bits of the result. The performance disparity...

Another case for your favorite reference! #include <random> #include <iostream> int main() { std::random_device rd; std::mt19937 gen(rd()); std::uniform_real_distribution<> dis(1, 2); for (int n = 0; n < 10; ++n) { std::cout << dis(gen) << ' '; } std::cout << '\n'; } (taken from here) generates values in [1,2), and the...

c++,c++11,random,random-seed,mersenne-twister

Let's recap (comments too), we want to generate different seeds to get independent sequences of random numbers in each of the following occurrences: The program is relaunched on the same machine later, Two threads are launched on the same machine at the same time, The program is launched on two...

What compiler and OS do you use? Visual Studio 2012 (not sure about 2013) didn't have a real implementation of std::random_device, which means that it was initialized with same value each time - so in such case you would have mersenne twister initialized with same seed each time, thus same...

c++,boost,random,cryptography,mersenne-twister

Analyzing your question is harder than it might seem: You seed the mersenne twister with rd(), which returns an unsigned int, and therefore (on most platforms) contains at most 32 random bits. Everything that the mersenne twister does from this point on is determined by those 32 bits. This means...

It is because you are using new Date().getTime(). The twister function finishes very quickly, to two successive calls to new Date().getTime() give the same value, thus the same seed. If you add a different number, e.g. such as this: http://jsfiddle.net/vcpjdo94/3/ it works as expected. The changes are: $scope.genRandom=function(){ $scope.inputs1= getRandomArray(6,...