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

"bug" is a strong word, which I did never employ myself, apart from using this 
channel of report. I rather think of a (non-documented) "deficiency", but I 
expect the consensus will again be that I am expressing a "raw expression". 
However reading more than once that "the correlations are indeed unsurprising" 
it is my turn to see there a raw expression. The correlations are unsurprising 
*only* if one looks at the source code and understand how a (to a very high 
degree) uniform distribution on a power of 2 range is reduced to distribution 
on the smaller range (keeping the extremely high uniformity). Thus, sorry, the 
correlations are to the contrary *very surprising* to the end user who has no 
knowledge of the internals.

Donald Knuth for example many decades ago in his work on MetaPost used a RNG 
which is a kind a primitive ancestor (in the family of those commented upon in 
AOCP) of the much more sophisticated one used nowadays by Python. He used the 
rescaling with rounding method to go from power of 2 range to non power of 2 
range. That method induces some non-uniformity and if I understand (without 
having checked) it was the one from Python < 3.2. At some point Python changed 
its way to another way, to cure non-uniformity (and other artefacts of the 
simple minded rescaling method). But there are other ways to reduce the 
non-uniformity to negligible levels which are not the choice made currently in 
Python code. (which for people not having _randbelow_with_getrandbits before 
their eyes is simply to draw a random integer with at most the number of bits 
of the limit N until one is found at most equal to N).

----------

_______________________________________
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