lua-users home
lua-l archive

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


On Sat, Mar 22, 2014 at 5:49 PM, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
> There are CSPRNGs with better performance than MT[1].
>
> [1] http://burtleburtle.net/bob/rand/isaacafa.html

There is also the simpler taus88 which can now be coded in Lua 5.3.
Here is the C code from the original paper:
        http://www.ams.org/journals/mcom/1996-65-213/S0025-5718-96-00696-5/

static unsigned long s1, s2, s3, b;

double taus88()
{       /* Generates numbers between 0 and 1. */
        b = (((s1 << 13) ^ s1) >> 19);
        s1 = (((s1 & 4294967294UL) << 12) ^ b);
        b = (((s2 << 2) ^ s2) >> 25);
        s2 = (((s2 & 4294967288UL) << 4) ^ b);
        b = (((s3 << 3) ^ s3) >> 11);
        s3 = (((s3 & 4294967280UL) << 17) ^ b);
        return ((s1 ^ s2 ^ s3) * 2.3283064365e-10);
}

It is quite easy to use this instead of MT in my lrandom.
I have the code already. If anyone is interested just drop me a line.


Interesting. What license is that code published under?

--
Sent from my Game Boy.