[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Am I misunderstanding random numbers?
- From: Javier Guerra Giraldez <javier@...>
- Date: Tue, 16 Mar 2010 12:54:52 -0500
On Tue, Mar 16, 2010 at 11:17 AM, Christopher Eykamp <chris@eykamp.com> wrote:
> I'm running on Windows, embedded in a C++ app. The chances of a re-seed
> seem minimal, as the two lines I posted are executed one after the other in
> the same file.
>
> I have temporarily resolved my problem by overwriting the random function to
> call my C++ program and use it's random function, which seems to be...
> well... random.
>
> If the seeds were the same, I would expect the results I see, but they're
> clearly different.
i've just tried this:
function tr(seed)
math.randomseed( seed )
print ("Seed: "..seed,
math.random(10000),math.random(10000),math.random(10000),math.random(10000))
end
for _,s in ipairs
({3063121584,2428144928,3559301251,4287790062,2737803158,2458923424})
do
tr(s)
end
and i get:
Seed: 3063121584 2331 1179 6134 7741
Seed: 2428144928 9074 3329 5507 8307
Seed: 3559301251 1739 4278 5885 8691
Seed: 4287790062 6352 1754 759 588
Seed: 2737803158 5587 8387 1486 6766
Seed: 2458923424 4302 7992 5852 5221
i guess that your Lua's math.random() is not stock Lua's. if it were,
we should get the same numbers given the same seeds.
can other members try this and see if everybody gets exactly the same
random numbers? this is Kubuntu 9.04 x86_64 with Lua 5.1.4 default
install.
--
Javier