jfbu <j...@free.fr> added the comment:

Yes indeed the source code of _randbelow_with_getrandbits generates this 
effect. And I understand the puzzlement about my test file setting the same 
random seed and then complaining about correlations. But there is some 
non-uniformity which is enormous between what happens for say n=99 and m=127 
versus n=99 and m=128.

Now that I looked at the actual source code, I have in other programming 
contexts available manners of reducing from a power of 2 to an arbitrary range 
which should not show this artefact.  I will need to translate it into Python 
and may submit a PR for evaluation after having tested.

My test file illustrates that if randrange() proceeded from a pseudo-random 
variable emulating the uniform distribution in (0,1) and rescaled and rounded 
to an integer range, correlations between distinct ranges would be of a 
completely different nature than what the CPython method leads to.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39867>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to