Posted by Haipeng Guo on January 28, 2001 at 12:00:28:
In Reply to: Re: Random number generator posted by Laura Kruse on January 10, 2001 at 23:35:24:
Dr. Hsu has recommend a very good Random generator Mersenne Twister to me. I think it's the best and I strongly recommend it. Please go to this URL:
http://www.cs.umd.edu/users/seanl/gp
: : Dear all,
: : Is there anybody who has used the Random Class in Java.util.Random? How random is it? I want to use it generate random doubles, uniformly distributed between 0.0 and 1.0. Do you have any idea how random and uniform it (the random numbers generated by Java.util.random) is? Thank you very much for any suggestions!
: : -hpguo
: Yeah, I did when I was working on the pullinput thing that takes the
: *.dat files and produces other files from it.
: Here's a code snippet for what you probally want. It gives me random
: numbers. :)
: Vector data;
: Random random;
: int rand;
: String tmp;
: data = new Vector();
: random = new Random();
: [...snip...]
: for(int i=0;i<100;i++) {
: rand = java.lang.Math.abs(random.nextInt(data.size() - 1));
: tmp = (String) data.elementAt(rand);
: [...snip...]
: }
: I hope that helps. :) That gives me a positive random number between 0
: and data.size() - 1.
: --
: Laura