Articles → Numpy → Seed Function In NumpySeed Function In NumpyIn this article, we will discuss the seed function in NumPy.Purpose Consider the following code: -import numpy as np print(np.random.rand(4))The above code returns a set of random numbers.Click to EnlargeAs you can see in the image above, every time the rand() function returns a different result i.e. result is not predictable. To make the result predictable, we use the seed() function.import numpy as np np.random.seed(0) print(np.random.rand(4))Here is the result of the above code. Even after multiple executions, the same set of results will be returned.Click to EnlargePosted By - Karan Gupta Posted On - Wednesday, April 10, 2019 Query/Feedback Your Email Id Subject Query/Feedback Characters remaining 250
import numpy as np print(np.random.rand(4))
import numpy as np np.random.seed(0) print(np.random.rand(4))
Query/Feedback