Re: Why is the first random number after randomseed() not random?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Why is the first random number after randomseed() not random?
- From: "Thomas Harning Jr." <harningt@...>
- Date: 2007年3月19日 14:46:37 -0400
On 3/19/07, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
> The Lua Wiki Math Library Tutorial page[1] says:
> "But beware! The first random number you get is not really 'randomized'
> (at least in Windows 2K and OS X)."
That's the way Pseudorandom number generators usually work. See
http://en.wikipedia.org/wiki/Pseudo-random_number_generator
To fix that, start your program with
math.randomseed(os.time())
for instance.
--lhf
I think the issue he's seeing is that even w/ diff seeds, the first
val is still 66.
--
Thomas Harning Jr.