[Python-ideas] Should our default random number generator be secure?
Sturla Molden
sturla.molden at gmail.com
Mon Sep 14 22:39:42 CEST 2015
On 14/09/15 21:07, Sturla Molden wrote:
> And with this criterion, only MT and certain PCG generators are
> acceptable. Those are (to my knowledge) the only ones with proven
> equidistribution.
Just to explain, for those who do not know...
Equidistribution means that the numbers are "uniformly distributed", or
specifically that "the proportion of the sequence that fall within an
interval is proportional to the length of the interval".
With one-dimensional equidistribution, the deviates are uniformly
distributed on a line. With two-dimensional equidistribution, the
deviates are uniformly distributed in a square. With three-dimensional
equidistribution, the deviates are uniformly distributed in a cube.
k-dimensional equi-distribution generalizes this up to a k-dimensional
space.
Let us say you want to simulate a shooter firing a gun at a target.
Every bullet is aimed at the target and hits in a sightly different
place. The shooter is unbiased, but there will be some random jitter.
The probability of hitting the target should be proportional to its
size, right? Perhaps!
Mersenne Twister MT19937 (used in Python) is proven to have 623
dimensional equidistribution. Certain PCG generators are proven to have
equidistribution of arbitrary dimensionality. Your simulation of the
shooter will agree with common sence if you pick one of these.
With other generators, such there are no k-dimensional equidistribution.
Your simulation of the shooter will disagree with common sence. Which is
correct? Common sence.
From a mathematical point of view, this is so important than anything
else than Mersenne Twister or PCG is not worth considering in a Monte
Carlo simulation.
Sturla
More information about the Python-ideas
mailing list