[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bad random numbers

From: A+A Adler
Subject: Re: bad random numbers
Date: Tue, 13 Jul 1999 21:14:16 -0400 (EDT)

On Tue, 13 Jul 1999, Mike Miller wrote:
> On Tue, 13 Jul 1999, John W. Eaton wrote:
> > | The results you produced show the same problem and it *is* a serious
> > | problem.
> > 
> > It is not a serious problem for me, because I don't expect that there
> > is any reason to believe that the sequence of numbers obtained by
> > running
> > 
> >   while true; do echo rand | octave -qf; done
> > 
> > should have any special properties.
> Like being random?  My "reason to believe" was that Octave documentation
> states that a seed is produced from the system clock everytime Octave
> starts.  This usually means that we get a different random number every
> time we start the program.  That isn't what happens.

If you think the situation is "bad" in octave, just try matlab.
Matlab 5.3, SunOS 5.5 always gives the following matrix
>> rand(3)
ans =
    0.9501    0.4860    0.4565
    0.2311    0.8913    0.0185
    0.6068    0.7621    0.8214

for the first call of rand, every time you run matlab.

I agree with John here. The "science" of building a random number
generator involves a function which returns uncorrelated output
for _successive_ calls of the function. This is what the
octave random number generator does.

What you are looking for is a random seed generator. The octave
random number generator does not advertise this functionality,
and if you try to use it for this, you're looking for trouble.

If you need this functionality, and are using Linux, one possiblity
is to use the /dev/random generator like this

          dd if=/dev/random  bs=1 count=1

/dev/random tries to accumulate "entropy" from "real-world" processes
such as the system clock, time between keypresses, etc.

In my oppinion, however, this kind of solution is appropriate for
very few numerical problems. I would suggest thinking carefully
about what you're trying to do. Your problem may very well be amenable
to using octave's random number generator the way it was designed.

Andy Adler,                               address@hidden

Octave is freely available under the terms of the GNU GPL.  To ensure
that development continues, see
Instructions for unsubscribing:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]