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...
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.