What is the use case of RandomCover?

Ivan Kazmenko gassa at mail.ru
Tue Feb 19 14:19:18 PST 2013


> On a side note, as D also uses MT19937 as the main RNG, random2 
> designers may want to address the same accuracy issue which 
> Python did.  More on that topic here: 
> http://bugs.python.org/issue9025

Sorry for replying to myself again, but the abovementioned 
accuracy issue is not about MT19937.  It's about how we transform 
the (uniform enough) bits from MT19937 to an integer in some 
range [0, LIMIT).  Looks like the inaccuracy is already addressed 
in D, so, sorry again for the bother.  Still, the current 
implementation uses divisions (which is slow on most CPUs), and 
for a good source of random bits such as MT19937, the 
implementation which repeatedly gets exactly 
core.bitop.bsr(LIMIT)+1 bits until the result is in [0, LIMIT) 
may be faster.

-----
Ivan Kazmenko


More information about the Digitalmars-d-learn mailing list