random module of numpy in python

1. rand(d0,d1,.....,dn) generates a floating-point random number of [0,1], the parameters in the parentheses can specify the shape of the generated array

For example: np.random.rand(3,2) will generate a 3×2 array, and the numbers in it are floating-point random numbers from 0 to 1
 
2.randn(d0,d1,...,dn) generates standard normal distribution random numbers, the meaning of the parameters is the same as rand
 
3. randint(low,high,size) generates random numbers in the specified range in the half-open interval [low,high), and the last parameter is the tuple, which determines the shape of the array
>>> np.random.randint(2, size=10)
array([1, 0, 0, 0, 1, 1, 0, 0, 1, 0])
Create a 2x4 array with element values ​​at [0, 4 )

>>> np.random.randint(5, size=(2, 4))
array([[4, 0, 2, 1],
       [3, 2, 2, 0]])

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325873165&siteId=291194637