numpy random array seed code example
Example 1: np.random.seed
import numpy as np
np.random.seed(42)
random_numbers = np.random.random(size=4)
random_numbers
Example 2: np random seed
>>> import numpy as np
>>>
>>> np.random.seed(0)
>>>
>>> np.random.rand(3)
array([0.5488135 , 0.71518937, 0.60276338])
>>> np.random.rand(3)
array([0.54488318, 0.4236548 , 0.64589411])
>>>
>>>
>>> np.random.seed(1)
>>>
>>> np.random.rand(3)
array([4.17022005e-01, 7.20324493e-01, 1.14374817e-04])
>>> np.random.rand(3)
array([0.30233257, 0.14675589, 0.09233859])
>>>
>>>
>>> np.random.seed(0)
>>>
>>> np.random.rand(3)
array([0.5488135 , 0.71518937, 0.60276338])
>>> np.random.rand(3)
array([0.54488318, 0.4236548 , 0.64589411])
Example 3: np.random.seed
array([0.3745012, 0.95071431, 0.73199394, 0.59865848])