[issue39867] randrange(N) for N's in same dyadic blocs have excessive correlations when sharing identical seeds
jfbu
report at bugs.python.org
Thu Mar 5 18:00:34 EST 2020
jfbu <jfbu at free.fr> added the comment:
@tim.peters yes, a uniform random variable rescaled to two nearby scales N and M will display strong correlations. The CPython randrange() exhibits however orders of magnitude higher such correlations, but only in relation to a common bitlength. A randrange() function should a priori not be so strongly tied to the binary base.
The example you show would not be counted as a hit by my test for the randomseed 12.
>>> s = 0
>>> for t in range(100000):
... random.seed(t)
... x = [round(random.random() * 100) for i in range(10)]
... random.seed(t)
... y = [round(random.random() * 101) for i in range(10)]
... if x == y:
... s += 1
...
>>> s
94
>>> s = 0
>>> for t in range(100000):
... random.seed(t)
... x = [random.randrange(100) for i in range(10)]
... random.seed(t)
... y = [random.randrange(101) for i in range(10)]
... if x == y:
... s += 1
...
>>> s
90432
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39867>
_______________________________________
More information about the Python-bugs-list
mailing list