Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What does random.seed([list of int]) do?

I know what random.seed(int) does, like below:

random.seed(10)

But I saw a code which uses random.seed([list of int]), like below:

random.seed([1, 2, 1000])

What is the difference between passing a list and int to random.seed ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The answer is basically in the comments, but putting it together: it appears the code you found imports random from numpy, instead of importing the standard Python random module:

from numpy import random

random.seed([1, 2, 1000])

Not recommended, to avoid exactly the confusion you’re running into.

numpy can use a 1d array of integers as a seed (presumably because it uses a different pseudo-random function than Python itself to generate ‘random’ numbers, which can use a more complex seed), as described in the documentation for numpy.RandomState

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading