Has anyone tested the random number generator for "randomness", especially
to determine if there are any bad seed numbers that should be avoided? I'm running simulations that make thousands of calls to the random number generator, and have been wondering if seed selection matters. Regards, Al Wagner |
Hi Alfred,
the random number generator of java is described in the java documentation http://download.oracle.com/javase/1.4.2/docs/api/java/util/ Random.html and in http://en.wikipedia.org/wiki/Linear_congruential_generator It is much better than the standard one in C, because it uses 48 bits, not 32 bits. In contrast the one in C, with the Java Random class, I have never seen problems due to correlation of successive numbers in Monte Carlo simulations. But of course, like any random number generator on a computer it only creates pseudorandom numbers. These types of random numbers are good as long as you use the number as such, where the most significant bits play the largest role. If you have some algorithm where the less significant bits become important, you are likely to run into problems. E.g., for a random number r, if r/n determines in which bin you put something and r modulo n determines where in the bin you place it, you might end up with problems, especially if n is a power of 2. r modulo n depends on the less significant bits. Of course, you should not interpret numbers including the less significant bits as bit patterns for some yes/no decisions. If you want to read several boolean variables from the numbers, don't use more than the highest 16 bits. In sensitive applications, if n is a power of 2, also the correlation of subsequent numbers may become apparent: if n selects a bin, and you use some bit of the next number, there might be a slight bias of that bit as a function of the previous number. I see no reason why some seed numbers should be better or worse than others. Michael ________________________________________________________________ On 14 Sep 2010, at 23:15, Alfred Wagner wrote: > Has anyone tested the random number generator for "randomness", > especially > to determine if there are any bad seed numbers that should be avoided? > > I'm running simulations that make thousands of calls to the random > number > generator, and have been wondering if seed selection matters. > > Regards, > Al Wagner |
Hi Michael,
Thanks for the detailed response, especially the references. It was very helpful and much appreciated. Regards, Al Wagner IBM Watson Research Center From: Michael Schmid <[hidden email]> To: [hidden email] Date: 09/16/2010 03:03 AM Subject: Re: Random Number Generator Sent by: ImageJ Interest Group <[hidden email]> Hi Alfred, the random number generator of java is described in the java documentation http://download.oracle.com/javase/1.4.2/docs/api/java/util/ Random.html and in http://en.wikipedia.org/wiki/Linear_congruential_generator It is much better than the standard one in C, because it uses 48 bits, not 32 bits. In contrast the one in C, with the Java Random class, I have never seen problems due to correlation of successive numbers in Monte Carlo simulations. But of course, like any random number generator on a computer it only creates pseudorandom numbers. These types of random numbers are good as long as you use the number as such, where the most significant bits play the largest role. If you have some algorithm where the less significant bits become important, you are likely to run into problems. E.g., for a random number r, if r/n determines in which bin you put something and r modulo n determines where in the bin you place it, you might end up with problems, especially if n is a power of 2. r modulo n depends on the less significant bits. Of course, you should not interpret numbers including the less significant bits as bit patterns for some yes/no decisions. If you want to read several boolean variables from the numbers, don't use more than the highest 16 bits. In sensitive applications, if n is a power of 2, also the correlation of subsequent numbers may become apparent: if n selects a bin, and you use some bit of the next number, there might be a slight bias of that bit as a function of the previous number. I see no reason why some seed numbers should be better or worse than others. Michael ________________________________________________________________ On 14 Sep 2010, at 23:15, Alfred Wagner wrote: > Has anyone tested the random number generator for "randomness", > especially > to determine if there are any bad seed numbers that should be avoided? > > I'm running simulations that make thousands of calls to the random > number > generator, and have been wondering if seed selection matters. > > Regards, > Al Wagner |
Free forum by Nabble | Edit this page |