Python is convenient to use the random library to generate random numbers. However, if you want to generate random arrays, numpy is better and bigger.
Generate a random array with a length of 10 and evenly distributed between [0, 1:
Rarray = numpy. Random. Random (size = 10)
Or
Rarray = numpy. Random. Random (10 ,))
Generate an average distribution between-0.1 and 0.1:
Rarray = 0.2 * numpy. Random. Random (size = 10)-0.1
Or
Rarray = numpy. Random. Uniform (-0.1, 0.1, size = 10)
Convert to normal List format
Rlist = List (rarray)
For more details about how to generate an evenly distributed random number, see numpy. Random. Random.
Generate a random number with a length of 10 and conform to the normal distribution.
Mu, Sigma = 0, 0.1 # mean and standard deviation rarray = numpy. Random. Normal (MU, Sigma, 10)
For more details about how to generate a random number with a normal distribution, see numpy. Random. Normal.
For details about other random numbers and more operations, see numpy. Random.