lua-users home
lua-l archive

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


There is a serious issue with initializing the random seed on 5.1.5 on
mac os x 10.7.5. Code:

for i = 1, 10000 do
    math.randomseed(i)
    print(math.random(1,2))
end

On normal Lua (tested 5.2.2) it yields decent distribution:

$ ./lua-5.2.2/src/lua math.lua |sort|uniq -c
5002 1
4998 2

But on 5.1.5 on osx it's completely broken:

$ ./lua-5.1.5/src/lua math.lua |sort|uniq -c
10000 1

 I'm aware that randomseed is depending on underlying C library and
"no guarantees can be given for its statistical properties", but come
on!

Cheers
    Marek Majkowski