When using random
in python, there are certain seeds that produce similar random numbers.
For example in python 3.8.5:
>>> import random
>>> random.seed(100)
>>> print(random.randint(1,100))
19
>>> random.seed(335)
>>> print(random.randint(1,100))
19
>>> random.seed(100)
>>> print(random.randint(1,500))
75
>>> random.seed(335)
>>> print(random.randint(1,500))
75
>>> random.seed(100)
>>> print(random.randint(1,1000))
150
>>> random.seed(335)
>>> print(random.randint(1,1000))
149
It would appear that this pattern holds for many combinations of seeds where making random.randint produce similar results for different seeds.
For another example:
>>> import random
>>> random.seed(101)
>>> print(random.randint(1,100))
75
>>> random.seed(155)
>>> print(random.randint(1,100))
75
>>> random.seed(101)
>>> print(random.randint(1,500))
298
>>> random.seed(155)
>>> print(random.randint(1,500))
298
>>> random.seed(101)
>>> print(random.randint(1,1000))
596
>>> random.seed(155)
>>> print(random.randint(1,1000))
595
Is there any reasonably simple way to solve this such that these numbers produce substantially different results given different range sizes?
Aucun commentaire:
Enregistrer un commentaire