Marsaglia's Kiss PRNG

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Marsaglia's Kiss PRNG

Nicolas Cellier
I've ported this PRNG that i personnally use in Squeak.
It's a rather "standard" one (used in gfortran).
Ref http://sci.tech-archive.net/Archive/sci.math.num-analysis/2005-11/msg00352.html

Currently, it generates Float on whole 53 bits significand range, while the MersenneTwister only generates 32 bits as currently configured.
I have the feeling that this should be some sort of tunable feature with a common API...
This extra-precision makes it almost twice slower than the MersenneTwister implementation, but 32 bits timings are similar.

RandomGenerator allSubclasses collect: [:prng |
    | p |
    p := prng new.
    prng -> [100000 timesRepeat: [ p next ]] timeToRun] as: Array.
->
LCRandom->0:00:00:00.028
LehmerRandom->0:00:00:00.164
MersenneTwisterRandom->0:00:00:00.754
PMRandom->0:00:00:00.151
MarsagliaKissRandom->0:00:00:01.396

It is also to be noted that Marsaglia's algorithm is a bit more robust than Mersenne to poor seed initialization
(using a poor seed may result in altered whiteness and distribution during a more or less long transient).

--
You received this message because you are subscribed to the Google Groups "SciSmalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Marsaglia's Kiss PRNG

Nicolas Cellier
By the way, did someone started any PRNG randomness test like http://en.wikipedia.org/wiki/TestU01?

On Monday, April 21, 2014 10:23:24 PM UTC+2, Nicolas Cellier wrote:
I've ported this PRNG that i personnally use in Squeak.
It's a rather "standard" one (used in gfortran).
Ref <a href="http://sci.tech-archive.net/Archive/sci.math.num-analysis/2005-11/msg00352.html" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fsci.tech-archive.net%2FArchive%2Fsci.math.num-analysis%2F2005-11%2Fmsg00352.html\46sa\75D\46sntz\0751\46usg\75AFQjCNHFeH3nvtJfF7FZ4Np2GgLJBgeMMQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fsci.tech-archive.net%2FArchive%2Fsci.math.num-analysis%2F2005-11%2Fmsg00352.html\46sa\75D\46sntz\0751\46usg\75AFQjCNHFeH3nvtJfF7FZ4Np2GgLJBgeMMQ';return true;">http://sci.tech-archive.net/Archive/sci.math.num-analysis/2005-11/msg00352.html

Currently, it generates Float on whole 53 bits significand range, while the MersenneTwister only generates 32 bits as currently configured.
I have the feeling that this should be some sort of tunable feature with a common API...
This extra-precision makes it almost twice slower than the MersenneTwister implementation, but 32 bits timings are similar.

RandomGenerator allSubclasses collect: [:prng |
    | p |
    p := prng new.
    prng -> [100000 timesRepeat: [ p next ]] timeToRun] as: Array.
->
LCRandom->0:00:00:00.028
LehmerRandom->0:00:00:00.164
MersenneTwisterRandom->0:00:00:00.754
PMRandom->0:00:00:00.151
MarsagliaKissRandom->0:00:00:01.396

It is also to be noted that Marsaglia's algorithm is a bit more robust than Mersenne to poor seed initialization
(using a poor seed may result in altered whiteness and distribution during a more or less long transient).

--
You received this message because you are subscribed to the Google Groups "SciSmalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.