Should I use std::default_random_engine or should I use std::mt19937?

后端 未结 3 2056
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-01 13:47

when I want to generate random numbers using std::random, which engine should I prefer? the std::default_random_engine or the std::mt19937? what ar

3条回答
  •  余生分开走
    2021-01-01 13:58

    The question is currently having one close vote as primary opinion based. I would argue against that and say that std::default_random_engine is objectively a bad choice, since you don't know what you get and switching standard libraries can give you different results in the quality of the randomness you receive.

    You should pick whatever random number generator gives you the kind of qualities you are looking for. If you have to pick between the two, go with std::mt19937 as it gives you predictable and defined behaviour.

提交回复
热议问题