[Top][All Lists]

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

Re: bad random numbers

From: lash
Subject: Re: bad random numbers
Date: Wed, 14 Jul 1999 10:32:17 -0500 (CDT)

> I think it would be good to have Bill Lash's code incorporated in the
> standard octave source.  I'm assuming it does what it's supposed to do and
> won't cause problems on other systems.

Well, the change does give "random looking" results for successive runs
in a while loop without the need to seed, but I wrote it to mimic the behavior 
of the
loop that uses the time to seed the random number generator.  As I said in
the last message, this will not give better results if the platform
does not have gettimeofday().

The patch also uses the trick that the seeding routine of the random number
generator uses, where the two integers that are needed to seed the RNG are
developed by taking a double floating point number and using the upper
and lower 32 bits as integers.  I won't speculate as to whether this is
good or not, it seems to work, so I guess it isn't terrible.

The original initialization code seemed to make an effort to provide
different numbers for each second, so it might make sense to keep this
basic behavior, but add in the fractional second stuff so that the number
has more appearance of being random.

If John wants to incorporate the patch, that is fine by me, but remember
that it was a quick hack, and that it does have some limitations.  

Bill Lash

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]