Python画图高斯分布的示例

时间:2022-10-27 22:48:20

如下所示:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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画图高斯分布的示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/WangJiankun_ls/article/details/78692254