The docs say:
Compatibility Guarantee A fixed seed and a fixed series of calls to ‘RandomState’ methods using the same parameters will always produce the same results up to roundoff error except when the values were incorrect. Incorrect values will be fixed and the NumPy version in which the fix was made will be noted in the relevant docstring. Extension of existing parameter ranges and the addition of new parameters is allowed as long the previous behavior remains unchanged.
There is no mention of operating systems.
If I call np.random.seed(42)
on windows and linux, will the random numbers generated afterwards be the same ?
Will it be the same across different versions of 64bit Ubuntu ?
I assume that the rng uses system libraries, so the code is probably not portable. If that's true, is there a fix ? I know that this would probably be ugly, like changing the linux rng system for something that emulates windows. But I'm ready for creative solutions.
The numpy random seed is a numerical value that generates a new set or repeats pseudo-random numbers. The value in the numpy random seed saves the state of randomness. If we call the seed function using value 1 multiple times, the computer displays the same random numbers.
It uses global state, which means results will change as the code changes. It uses a RandomState rather than the more modern Generator .
The seed() method is used to initialize the random number generator. The random number generator needs a number to start with (a seed value), to be able to generate a random number. By default the random number generator uses the current system time.
In the Python random module, the . seed() method is used to create a pseudo-random number generator. Pseudo-random number generators appear to produce random numbers by performing some operation on a value. This value is the seed and it sets the first “random” value of the number sequence.
As per sascha’s comment, random numbers are platform independent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With