I'm making a monte carlo simulation in C++ and I was using Boost for random numbers. I used GSL a bit too. But it turns out random number generation is one of my biggest runtime inefficiencies, so I just started using good old rand()
from cstdlib
.
How badly am I risking to have poor random number properties on my simulation? I use around 10^6 or 10^7 random number samples.
There are two issues: (1) because RAND_MAX is only guaranteed to be at least 32767, there might not be many possible values (not necessarily bad for some applications), and (2) poor implementations.
If you need what is known as a secure random number generator you will need to look somewhere else. But for many apps, rand()
is sufficient.
A blog post that addresses your concerns is http://eternallyconfuzzled.com/arts/jsw_art_rand.aspx.