[Numpy-discussion] [Python-ideas] Should our default random number generator be secure?

Nathaniel Smith njs at pobox.com
Fri Sep 18 21:05:37 EDT 2015


On Mon, Sep 14, 2015 at 7:56 AM, Sturla Molden <sturla.molden at gmail.com> wrote:
> On 14/09/15 10:34, Antoine Pitrou wrote:
>
>> Currently we don't provide those APIs on the GPU, since MT is much too
>> costly there.
>>
>> If Numpy wanted to switch to a different generator, and if Numba wanted
>> to remain compatible with Numpy, one of the PCG functions would be an
>> excellent choice (also for CPU performance, incidentally).
>
>
> We have discussed allowing plugable PRNGs in NumPy on multiple occations.
>
> I don't think NumPy should change its default PRNG. The Mersenne Twister
> MT19937 is state of the art of numerical work. It has excellent numerical
> accuracy, a huge period, and is very fast. For most users of NumPy, the
> MT19937 is the first and last word that needs to be said about pseudorandom
> number generators.

There are obviously trade-offs here and I haven't looked at the
details enough to have an opinion on whether the benefits are *enough*
that changing the default would be worth it, but it's simply not true
that MT19937 is state of the art. There are faster generators with
better numerical properties and more features (including, but not
only, the PCG family).

It looks like the random123 Philox generator is somewhat popular on
GPUs at this point too (e.g.
https://uk.mathworks.com/help/distcomp/examples/generating-random-numbers-on-a-gpu.html).

-n

-- 
Nathaniel J. Smith -- http://vorpus.org



More information about the NumPy-Discussion mailing list