Re: best approach to generate random number in java

From: Matt Humphrey (matth_at_ivizNOSPAM.com)
Date: 10/13/04


Date: Wed, 13 Oct 2004 15:05:44 -0400


"Paul Lutus" <nospam@nosite.zzz> wrote in message
news:10mqq2hth46a7d9@corp.supernews.com...
> Matt Humphrey wrote:
>
> >
> > "Paul Lutus" <nospam@nosite.zzz> wrote in message
> > news:10mqoqc57b4blb7@corp.supernews.com...
> >> Matt wrote:
> >>
> >> > If I tried Random with seed, my observation is it always generate the
> >> > same number with seed:
> >>
> >> That is how it is supposed to work. Pseudorandom number generators are
> >> supposed to create a series of numbers that are random with respect to
> > each
> >> other, but the sequence can be recreated exactly if the same seed is
> >> used. This is a Good Thing(tm).
> >>
> >> You know, you can always read the docmentation.
> >>
> >> http://java.sun.com/j2se/1.4.2/docs/api/java/util/Random.html
> >>
> >> http://www.cafeaulait.org/course/week4/54.html
> >>
> >> / ...
> >>
> >> > So what's the purpose of using a seed?
> >>
> >> See above. It allows you to recreate the same sequence.
> >>
> >> > I thought using a seed can
> >> > yield a more random number.
> >>
> >> "More random". Hmm. Entirely new concept.
> >
> > The quality of randomness as applied to PRGs can be assessed
> > statistically.
> > Some PRGs give results with better distributions than others. My
> > understanding is that for Java the SecureRandom number generator gives
> > longer periods and better distributions than Random.
>
> Yes, all fine, but my point is that "random" is a superlative term.
> Therefore saying "more random" is like saying "more perfect".

I agree that the lay definition of random as meaning without design or
arbitrary is superlative, but when speaking of random number generators
there are many grades of randomness (e.g. perfectly, truly) and so in this
context the term is not superlative.

Cheers,
Matt Humphrey matth@ivizNOSPAM.com http://www.iviz.com/