std.random and mersenne twister
cdillaba at cg.scs.carleton.ca
Fri Jul 20 07:05:02 PDT 2012
On Friday, 20 July 2012 at 12:51:25 UTC, Andrea Fontana wrote:
> CMWC is proven to be a valid method and it passes diehard
> tests. It was
> written by prof. George Marsiglia (he developed xorshift too -
> in std.random). He was one of the best experts in PRNG.
> He also developed the "Marsiglia's Theorem" where he
> demonstrate that
> LCG (that is the default algorithm for many languages for ex:
> glibc and
> vc++ lib, ...) has big issues.
> LCG is very widespread but d doesn't use it (phew!). If a user
> difference between PRNG algorithms can use MT, but as default
> for people
> that use weak C rand() function as default (that neither passes
> tests) it can just be a good improvement (why should we give
> them MT
> that is slower than CMWC if they neither know default rand()
> MT has a complex implementation, I hope std.random MT was
> tested :)
> Il giorno ven, 20/07/2012 alle 13.16 +0200, monarch_dodra ha
>> On Friday, 20 July 2012 at 09:47:52 UTC, Andrea Fontana wrote:
>> > I read that default RNG in phobos is Mersenne Twister.
>> > I think it would be a good idea to replace it with
>> > complementary-multiply-with-carry (cmwc). CMWC is faster
>> > (use simpler
>> > math), has a longer period (standard implementation has a
>> > 2^131104
>> > period vs 2^19937 of current MT implementation in phobos)
>> > and passed
>> > diehard tests (mt passes them too)
>> > And of course it's very easy to implement:
>> > http://en.wikipedia.org/wiki/Multiply-with-carry#Implementation
>> I'd say the problem is that it is not a very widespread or
>> known PRNG.
>> While I wouldn't be against adding it to the library ("I see
>> no reason not to add it"), making it the _default_ PRNG is a
>> whole other story.
>> Users that choose "default" want something reliable,
>> documented, trustworthy etc...
>> Multiply With Carry seems like it is Cutting Edge to me, not
>> yet widespread, known or tested. I'd say it should only be
>> used by those that explicitly request it's usage.
But Mersenne Twister has a cooler name :o)
'Multiply with carry' is so blah. You'll need to come up with a
sexy new name for it.
More information about the Digitalmars-d