我使用 matplotlib.pyplot.hist2d 生成了2D Guassian发行版。我想知道的是,如果Python中有任何函数允许我进行计算并绘制2D直方图的积分和导数。 在网上查询我发现了很多关于此问题的主题,但仅限于一维分发。
有人可以帮助我吗?
这是我的代码:
import numpy as np
import matplotlib.pyplot as plt
#GENERATE 2 RANDOM GAUSSIAN DISTRIBUTION
mu1, sigma1 = 0, 0.1
s1 = np.random.normal(mu1, sigma1, 10000)
mu2, sigma2 = 0, 0.3
s2 = np.random.normal(mu2, sigma2, 10000)
#PLOT 2 RANDOM GAUSSIAN DISTRIBUTION
plt.figure(1)
plt.title('Histogram of a 2D-Gaussian Distribution')
plt.xlabel('Radial position')
plt.ylabel('Particle frequency')
bins1 = plt.hist(s1, 100)
bins2 = plt.hist(s2, 100)
plt.show()
#GENERATE AND PLOT 2D RANDOM GAUSSIAN DISTRIBUTION
plt.figure(2)
plt.title('2D-Gaussian Distribution')
bins = plt.hist2d(s1, s2, 100)
cb = plt.colorbar()
cb.set_label('counts in bin')
#plt.axis('equal')
plt.show()
谢谢!