np.random.normal
时间: 2023-10-31 18:41:05 浏览: 96
() is a method in the NumPy library of Python that generates random numbers from a normal distribution. The normal distribution is also known as the Gaussian distribution and is a probability distribution that describes how a certain variable is likely to be distributed.
The np.random.normal() method takes three parameters - mean, standard deviation, and size. The mean and standard deviation are the parameters that define the normal distribution. The mean is the average value of the distribution, and the standard deviation is a measure of how spread out the values are. The size parameter specifies the number of random values that will be generated.
For example, the following code generates 10 random values from a normal distribution with mean 0 and standard deviation 1:
import numpy as np
values = np.random.normal(0, 1, 10)
print(values)
Output:
[-1.22452333 0.62523121 0.38380887 1.43222601 0.68548529 -1.34739294
-0.73165537 -0.16955273 0.13184922 -1.14016513]
阅读全文