Posted by
Michael Schmid on
Sep 15, 2010; 3:17pm
URL: http://imagej.273.s1.nabble.com/Random-Number-Generator-tp3686911p3686912.html
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_generatorIt 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