Random Engine Differences

前端 未结 7 1399
灰色年华
灰色年华 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:29

    I think that the point is that random generators have different properties, which can make them more suitable or not for a given problem.

    • The period length is one of the properties.
    • The quality of the random numbers can also be important.
    • The performance of the generator can also be an issue.

    Depending on your need, you might take one generator or another one. E.g., if you need fast random numbers but do not really care for the quality, an LCG might be a good option. If you want better quality random numbers, the Mersenne Twister is probably a better option.

    To help you making your choice, there are some standard tests and results (I definitely like the table p.29 of this paper).


    EDIT: From the paper,

    1. The LCG (LCG(***) in the paper) family are the fastest generators, but with the poorest quality.
    2. The Mersenne Twister (MT19937) is a little bit slower, but yields better random numbers.
    3. The substract with carry ( SWB(***), I think) are way slower, but can yield better random properties when well tuned.

提交回复
热议问题