Randint:- This function is used to generate a random number between a given range.
Syntax:- randint(min,max,total_values)
import numpy as np arr=np.random.randint(1,10,3) print(arr) |
rand:- This function is used to generate a random values between 0 to 1.
Syntax:- rand(number of value)
import numpy as np arr=np.random.rand(2,3) print(arr) |
import numpy as np arr=np.random.rand(5) print(arr) |
randn:- This function is used generate a random values close to 0 (zero). This may return positive or negative numbers as well.
Syntax:- randn(number of value)
import numpy as np arr=np.random.randn(5) print(arr) |
seed:- we know that randint() function generates random numbers. Every time we run the program, new set of random number is generated. But what if we want to fix the generation of this random number. In this case we use seed, this generates fix set of random numbers.
import numpy as np np.random.seed(10) arr=np.random.randint(1,50,10) print(arr) |