lua-users home
lua-l archive

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


Philippe Lhoste wrote:
Bad Things:
- PalmOS MathLib does not have a rand() or srand() function. If you have
one, MIT licesend, please send to us, so we can add it to the port.

I believe the Meresnne Twister <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html> was implemented in Lua or in C with Lua interface. Maybe this is an overkill for the PalmOS (I don't know if the implementation is really big or slow or memory hungry. They say it is as fast as rand(), and consumes 624 words of workplace, probably because it generates 624 numbers at each iteration)

I may as well pimp my random number generator again, since
it's probably good for low-power CPUs, though it doesn't come
with a lua binding (yet!) but that should be simple:
http://icculus.org/~aspirin/fnvrand/

It uses only a few bytes of state and is about 10x faster than
a good MT implementation, though I really doubt the quality of
randomness is comparable (but it's pretty good, from casual
analysis).

--Adam