![](/img/trans.png)
[英]How to get log-normal distribution (i.e. a normal distribution in dB) with a zero mean and a standard deviation of σ = 2 dB for 600 values in python?
[英]when plotting a pdf in python for a normal distribution and the standard deviation is 2, will the mean still be zero?
因此,根据我对正态分布的理解,当标准差为 1 时,默认情况下均值为零。 2 的偏差。均值仍然为零吗? 我试过了,但我的情节没有形成钟形。 我不知道我做错了什么。
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
mu=0 # mean
sigma=2
x=np.arange(10,45,0.1)
y=stats.norm.pdf(x, 0, sigma)
plt.plot(x,y)
plt.show()
在这里查看我的情节: myplot
from scipy.stats import norm
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(10,45,0.1)
sigma = 2
print('Mean :', round(x.mean(), 2),'SD :', sigma)
plt.plot(x, norm.pdf(x,x.mean(),sigma), 'r1', lw=2, alpha=0.5, label='norm PDF')
plt.legend(loc='best')
plt.show()
哪个打印:
Mean : 27.45 SD : 2
并显示了概率密度函数的形状:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.