This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jfbu
Recipients jfbu, mark.dickinson, rhettinger
Date 2020-03-05.21:18:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1583443091.31.0.0371254331329.issue39867@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-03-05 21:18:11jfbusetrecipients: + jfbu, rhettinger, mark.dickinson
2020-03-05 21:18:11jfbusetmessageid: <1583443091.31.0.0371254331329.issue39867@roundup.psfhosted.org>
2020-03-05 21:18:11jfbulinkissue39867 messages
2020-03-05 21:18:11jfbucreate