4

I'm looking for a random number generation algorithm (c++), which requires

  1. uniformed
  2. deterministic and invariant on any platform
  3. you can specify range (min, max)

mt19937 with uniform_int_distribution is close, but the result is not invariant on any platforms.

So I hope you can give me some advices. Thanks in advance.

nerocrux
  • 83
  • 1
  • 7
  • I guess you checked the standard random number generators as described on [cppreference.com](http://en.cppreference.com/w/cpp/numeric/random)? – Rene Feb 07 '17 at 07:35
  • 1
    I believe the standard engines are guaranteed to be invariant across platforms, but the distributions are not (which is quit silly, imo). So maybe just copy the distribution implementation from whatever platform you are currently on into your own class, and use that with the standard engines. – Benjamin Lindley Feb 07 '17 at 07:48
  • Thank you guys, I have checked random number generators on that page, and I think generators generates same value (it should be) across platforms so the problem is how to specify range (use generator's result, and generate uniformed results in the range). The best way is, of course, use uniform_int_distribution. But the only problem is the result may be not invariant. – nerocrux Feb 07 '17 at 08:47
  • @BenjaminLindley I'll give it a try. I have done some experiments, compile the code with same compiler and run on different platforms such as ios / ubuntu / etc.. and the results are same but still not sure if os / runtime matters. – nerocrux Feb 07 '17 at 08:55

0 Answers0