On Sat, 21 Oct 2006 07:53:59 -0700, asdf wrote:
Quote:
I want a random number generator, the random number should be subject a
uniform distribution in [0,1]. Could you please give me some hints?
Thanks.
Are you sure you want (1) included in your range?
Others have given you pointers to RNG literature. One thing I've noticed
that seems to be an almost universal misuse of random number functions
such as the srand() and rand() functions is that programmers who
use them to generate numbers [0..1) virtually NEVER check to see if the
returned value of rand()==RAND_MAX. While the probability of this
happening is 1/RAND_MAX, you should check because rand()/RAND_MAX could
end up outside of your intended range.
For simple non-cryptographic uniform distributions the rand() function is
often adequate but for more stringent requirements the BOOST library
provides several RNGs. Of course as with many open source projects, the
documentation is lacking...at least it was when I last used them.