我想按照铃声的顺序生成正态分布。我使用此代码来生成数字:
import numpy as np
mu,sigma,n = 0.,1.,1000
def normal(x,mu,sigma):
return ( 2.*np.pi*sigma**2. )**-.5 * np.exp( -.5 * (x-mu)**2. / sigma**2. )
x = np.random.normal(mu,sigma,n) #generate random list of points from normal distribution
y = normal(x,mu,sigma) #evaluate the probability density at each point
x,y = x[np.argsort(y)],np.sort(y) #sort according to the probability density
Run Code Online (Sandbox Code Playgroud)
这是中提出的代码:按顺序生成正态分布 python,numpy
但数字并不遵循钟形。有任何想法吗?非常感谢