For example if I instantiate a std::mt19937
with the exact same seed and parameters under GCC and under MSVC, should I get the same sequence of random numbers? If so I assume this property would hold for mersenne_twister_engine in general since mt19937 is just one with specific parameters. This is not true for rand()
in C. It looks like the standard documents the transformations applied in terms of specific code, so I suspect it should always be the same, but the devil is in the details...
The random number generator works by remembering a seed value which it uses to compute the next random number and also to compute a new seed. Although the generated numbers look unpredictable within one run of a program, the sequence of numbers is exactly the same from one run to the next.
Generating IntegersThe rand() function in C could be used in order to generate the random number and the generated number is totally deleting seed. A seed is a value that is used by rand function to generate the random value.
For the new random number engines, yes, for the same seed and parameters you'll get the same sequence of values on all platforms. For rand()
, no. You also don't have that guarantee with random number distributions, even when they are fed the same sequence of input values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With