lua-users home
lua-l archive

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


On Jul 12, 2004 at 10:46 +0200, Philippe Lhoste wrote:
> 
> Interesting. I suppose you tested it using good statistical rules...
> Oh well, you seem to have used a sane algorithm (good idea to have made 
> the README readable without having first to download the archive...), 
> and for most uses, MT quality isn't probably needed. After all, a lot of 
> programs use rand() which has an awful reputation... (perhaps injust in 
> modern implementations).
> 
> Note that I saw an MT implementation that generate numbers one by one 
> (ie. not in batches of 624 words), so it should use less memory, perhaps 
> at the cost of slower generation (but it seems to depend on the platform).

I have little first-hand understanding of random number generation,
but some things that I've read suggest that George Marsaglia's
complimentary-multiply-with-carry is as good or better in terms of
randomness, as well as much simpler than MT.

Here's a 2003 Communications of the ACM article by George Marsaglia
that includes some code (requires access to ACM Digital Library):

http://portal.acm.org/ft_gateway.cfm?id=769827&type=pdf&dl=portal&dl=ACM&CFID=11111111&CFTOKEN=2222222

Here's some simple and small code I wrote based on the above article.
It's public domain, so you can use it any way you want to.  I don't
make any claim that it's bug free so use at your own risk:

http://cvs.sourceforge.net/viewcvs.py/tu-testbed/tu-testbed/base/tu_random.cpp?rev=1.7&view=auto

It's missing a substitute for srand() though.

Here's an interesting set of slides that reviews RNG's:

http://www.elsteve.com/holdings/rand.pdf

-- 
Thatcher Ulrich
http://tulrich.com