4 ms·
My take is to never trust the built-in random number generator of any standard library. Get a copy of Numerical Recipes and implement your own, it's only a few
by martincmartin 16y ago
My take is to never trust the built-in random number generator of any standard library. Get a copy of Numerical Recipes and implement your own, it's only a few lines of code.
- zem 16y agowhy would you assume that the stdlib random number generator is worse than the few lines of code from numerical recipes?
- malkia 16y agoIt's not that it's worse, it's the fact that is different for each platform.
- zem 16y agoit's a random number generator! you shouldn't be relying on any particular property other than that it passes the statistical tests for randomness.
- zinkem 16y agoYou need to be able to re-create your inputs if a problem occurs. You need to be able to seed a random number generator and have it generate the same sequence for debugging.
- jerf 16y agoAt least then you know which one it is, what properties it has, and how it is initialized. Too few random number libraries document this. But as that is the primary advantage my gut would be to still at least use a library. It's not hard to come up with a Mersenne Twister library, and if you need something cryptographically secure just about the only thing I'd even consider is going straight to the OpenSSL implementation.