How do you generate a random double uniformly distributed between 0 and 1 from C++?

后端 未结 13 608
暗喜
暗喜 2020-11-28 22:28

How do you generate a random double uniformly distributed between 0 and 1 from C++?

Of course I can think of some answers, but I\'d like to know what the standard pr

13条回答
  •  死守一世寂寞
    2020-11-28 23:31

    You could try the Mersenne Twister algorithm.

    http://en.wikipedia.org/wiki/Mersenne_twister

    It has a good blend of speed and randomness, and a GPL implementation.

提交回复
热议问题