Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Why does Julia use Mersenne Twister as default? I gather that it's quite bad by modern standards?


"quite bad" is quite an overstatement; its quality isn't a problem for many real use cases. It's quite slow compared to the likes of PCG though.


It is very bad. It's is huge, 10x slower than good LCG's, and fails statistical tests, esp. it's lower bits, most wellknown by the Ferrenberg affair. https://arxiv.org/pdf/1910.06437.pdf

PCG is also not that good. There do exist proper and fast PRNG's though. DSFMT has the same problems as MT. I'm just adding some of them to gsl and dieharder btw.


If you read that paper you referenced, the Mersenne-Twister actually ended the Ferrenberg affair. And where does it say that lower bits of dSFMT are bad? Is there proof for this statement? Now I am not saying that dSFMT is the best RNG ever, far from it. It's just very decent, and quite fast.

LCGs have an awkward habit of bad projections in 2D.


Thank you for the reference. I stand corrected. I wasn't aware that its quality problems are that bad.

What's the best argument against PCG?


Give me a bit more time. I just added all the relevant modern RNG's to dieharder and am running all the tests. TestU01 later. Actually MT looks good enough to me now.

Preliminary results at https://github.com/rurban/dieharder/blob/pcg/QUALITY.md

Re PCG: statistical weaknesses compared to the good xoshiro's or wyrand, and much slower. I'm still missing SFMT (2x faster, due to simd), and the 2 newer PCG's with a good and a fast mixer.

But given the current results, there are a few new PRNG's which are so much better and faster than everything else: wyrand, xoshiro128+, xoroshiro64, xoshito128++, xoroshiro64


This is interesting. By the way, it is noticeable that Ferrenberg himself did not find anything wrong with MT in one of his latest papers. He however mostly used MRG32k3a, and checked that MT gave similar numbers.

https://arxiv.org/pdf/1806.03558


Julia uses dSFMT, which is as fast as xoshiro on vigna own benchmark page. I would not call that slow.


Right, a bad phrasing from my part; I didn't actually mean the distribution, but more like... the bang for the buck. Why would you use slow generator as a default, if you don't even get good distribution?


You get a good distribution in 99.99% of the cases. There is no perfect rng. I am sure that pcg and xoroshiro also have deficiencies. The issue of good seedings is quite general.


Of course there are perfect RNG's. Some of them even quite fast. Good PRNG's eg. do have no seeding problem as most bad LCG's.


Some people are easy to satisfy I guess


I can't tell you why it was originally chosen, but there is a PR underway to have tasklocal RNG in Julia. That necessitates a smaller RNG, and we'll probably land on xoshiro256

Ref: https://github.com/JuliaLang/julia/pull/34852


It _has_ a cool name, tough...


And the pcg page has pretty colors


no, it is pretty good rng, but quite slow, and world move on since 80s




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: