lua-users home
lua-l archive

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


Doug Currie wrote:
> Seed: 3063121584	4964	2752	7879	8016
> Seed: 2428144928	8048	3582	6757	2385
> Seed: 3559301251	9603	7007	8275	1133
> Seed: 4287790062	1512	4513	7587	1872
> Seed: 2737803158	5117	7206	7927	2449
> Seed: 2458923424	1045	5001	815	5114
> 
> LuaJIT 2.0.0-beta3
> OS X 10.6.2

LuaJIT uses its own pseudo-random number generator. It's a
Tausworthe PRNG with period 2^223 (TW223). It generates the same
sequences from the same seeds on all platforms and makes use of
all bits in the seed argument.

math.random() without arguments generates 52 pseudo-random bits
for every call. And the result is uniformly distributed between 0
and 1, too (bias trick). If you use math.random(n [,m]), the
result is correctly scaled up and rounded to preserve uniformity.

The quality of the TW223 PRNG results is much better than what
standard Lua could possibly get from ANSI rand() (API too narrow
and lots of bad libc implementations).

--Mike