Random Engine Differences

前端 未结 7 1364
灰色年华
灰色年华 2020-12-13 02:06

The C++11 standard specifies a number of different engines for random number generation: linear_congruential_engine, mersenne_twister_engine,

7条回答
  •  时光说笑
    2020-12-13 02:11

    Its a trade-off really. A PRNG like Mersenne Twister is better because it has extremely large period and other good statistical properties.

    But a large period PRNG takes up more memory (for maintaining the internal state) and also takes more time for generating a random number (due to complex transitions and post processing).

    Choose a PNRG depending on the needs of your application. When in doubt use Mersenne Twister, its the default in many tools.

提交回复
热议问题