Message363454
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. |
|
Date |
User |
Action |
Args |
2020-03-05 21:18:11 | jfbu | set | recipients:
+ jfbu, rhettinger, mark.dickinson |
2020-03-05 21:18:11 | jfbu | set | messageid: <1583443091.31.0.0371254331329.issue39867@roundup.psfhosted.org> |
2020-03-05 21:18:11 | jfbu | link | issue39867 messages |
2020-03-05 21:18:11 | jfbu | create | |
|