【发布时间】:2020-09-25 17:58:01
【问题描述】:
我正在尝试使用等高线图绘制密度估计值并出现以下错误。
A = np.random.uniform(size=(100, 2))
#mean = np.mean(x)
#cov = np.cov(x)
mean = np.array([0.5, 0.1])
cov = np.array([[0.1, 0.0], [0.0, 1.5,]])
B = multivariate_normal.pdf(A, mean=mean, cov=cov)
# visualize
contours = plt.contour(A, B, linewidths=2)
plt.clabel(contours, inline=True, fontsize=12)
#plt.plot(x, y)
plt.colorbar();
【问题讨论】:
-
您需要使用
meshgrid。这个SO question的第二个答案有一个实现
标签: contour gaussian probability-density