python--numpy.random

numpy.random

Generate (0,1) uniformly distributed random numbers

np.random.rand(2,3)
#array([[0.23159584, 0.1895618 , 0.87409391],
#       [0.40875295, 0.63464579, 0.83562079]])

Random number in given range

np.random.randint(0,10,size=5)

Generate Binomial Distribution Random Number

np.random.binomial(10,0.5,size=5)

Normally distributed random number

np.random.normal(0,0.5,size=(4,4))

Random numbers with standard normal distribution (mean 0 and variance 1)

np.random.randn(4,4)

Determine the seed of the random number generator so that the process of generating random numbers can be reproduced.
When we do not set the seed, the random number generated is different each time.

np.random.seed(10)#每次的结果一定
np.random.rand(3,2)

Guess you like

Origin blog.csdn.net/weixin_44039266/article/details/114794525
Recommended