如下所示:importmatplotlib.pyplotaspltimportnumpyasnpimportmathdefgaussian(sigma,x,u):y=np.exp(-(x-u)**2/(2*sigma**
如下所示:
import matplotlib.pyplot as plt
import numpy as np
import math
def gaussian(sigma, x, u):
y = np.exp(-(x - u) ** 2 / (2 * sigma ** 2)) / (sigma * math.sqrt(2 * math.pi))
return y
#x = np.linspace(220, 230, 10000)
x = np.linspace(-800, 800, 10000)
plt.title('PDF in Horizontal Direction', fontsize=22)
plt.xticks(fontsize=22)
plt.yticks(fontsize=22)
axes = plt.subplot(111)
axes.set_xticks([-800,-400,0,400,800])
axes.set_yticks([0,0.001,0.002,0.0030])
plt.plot(x, gaussian(120, x, 0), "b-", linewidth=6)
plt.show()
以上这篇Python画图高斯分布的示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
Python 画图 高斯分布