New submission from jfbu <j...@free.fr>:
We generate quadruples of random integers using randrange(n) and randrange(m) and count how many times the quadruples are identical, using the same random seed. Of course for nearby n and m (the real life example was with n==95 and m==97) we do expect matches. But we found orders of magnitude more than was expected. The attached file demonstrates this by comparison with random()*n (with rounding) as alternative method to generate the random integers (we are aware this gives less uniformity for a given range, but these effects are completely negligible in comparison to the effect we test). For the latter the probability of matches is non-vanishing but orders of magnitude smaller than using randrange(n). Here is an excerpt of our testing result. Each trial uses a random seed (selected via randrange(100000000)). Then 4 random integers in two given ranges are generated and compared. A hit is when all 4 match. - with randrange(): n = 99, m = 124, 4135 hits among 10000 trials n = 99, m = 125, 3804 hits among 10000 trials n = 99, m = 126, 3803 hits among 10000 trials n = 99, m = 127, 3892 hits among 10000 trials n = 99, m = 128, 0 hits among 10000 trials n = 99, m = 129, 0 hits among 10000 trials n = 99, m = 130, 0 hits among 10000 trials n = 99, m = 131, 0 hits among 10000 trials - with random(): n = 99, m = 124, 0 hits among 10000 trials n = 99, m = 125, 0 hits among 10000 trials n = 99, m = 126, 0 hits among 10000 trials n = 99, m = 127, 0 hits among 10000 trials n = 99, m = 128, 0 hits among 10000 trials n = 99, m = 129, 0 hits among 10000 trials n = 99, m = 130, 0 hits among 10000 trials n = 99, m = 131, 0 hits among 10000 trials The test file has some hard-coded random seeds for reproductibility. Although I did only limited testing it is flagrant there is completely abnormal correlation between randrange(n) and randrange(m) when the two integers have the same length in base 2. Tested with 3.6 and 3.8. ---------- files: testrandrange.py messages: 363451 nosy: jfbu priority: normal severity: normal status: open title: randrange(N) for N's in same dyadic blocs have excessive correlations when sharing identical seeds versions: Python 3.8 Added file: https://bugs.python.org/file48955/testrandrange.py _______________________________________ 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