No pure Go language Mersenne Twister implementation?

751 views
Skip to first unread message

Warren Henning

unread,
Dec 30, 2010, 8:43:36 PM12/30/10
to golang-nuts
Hi, it looks like the pseudorandom number generators in the rand
package are linear congruential generators.

The Mersenne Twister ( http://en.wikipedia.org/wiki/Mersenne_twister )
is a high-quality PRNG designed for Monte Carlo simulations,
stochastic algorithms, and the like, which need high-quality random
numbers. It's actually the default RNG in Python and Ruby.

I looked on the project dashboard and didn't see any implementations of it.

Is anyone working on this or interested?

I realize you could just use an RNG from another language via SWIG or something.

I'm new to Go and porting an existing implementation (which is under a
suitable license) seems like a good learning exercise that would
actually benefit Go users.

Thanks.

Warren

LazyMiha

unread,
Jan 1, 2011, 9:30:32 AM1/1/11
to golang-nuts
> The Mersenne Twister (http://en.wikipedia.org/wiki/Mersenne_twister)
> is a high-quality PRNG designed for Monte Carlo simulations,
> stochastic algorithms, and the like, which need high-quality random
> numbers. It's actually the default RNG in Python and Ruby.

Mersenne Twister is good and simple generator. I think that properly
implemented PRNG is will be very usable.

Jochen Voss

unread,
Oct 24, 2013, 5:41:04 AM10/24/13
to golan...@googlegroups.com
Dear all,
Just for the record, I have implemented the 64bit variant of the Mersenne
Twister in Go.


Comments would be very welcome.

All the best,
Jochen
--

zephyr...@gmail.com

unread,
Oct 24, 2013, 10:13:20 AM10/24/13
to golan...@googlegroups.com, warren....@gmail.com
The PRNG in math/rand is a lagged Fibonacci generator, which is less studied than the Mersenne Twister, but is still of very high quality. It's also faster, which is nice for Monte Carlo simulations and the like. If you care about empirically tested statistical randomness, I wrote a tool in the spirit of Diehard a while ago: https://github.com/zephyrtronium/prngt

Warren Henning

unread,
Oct 24, 2013, 12:32:59 PM10/24/13
to zephyr...@gmail.com, golang-nuts
Impressive thread necromancy.
Reply all
Reply to author
Forward
0 new messages