所以,基本上我有一个python的2D矢量列表,我想通过绘图来三维可视化这个矢量的分布,就像一条曲面曲线。我将给出向量的前4个分量的样本
[[0.35431211986827776, 0.21438054570807566], [0.35431211986827776, 0.21438054570807566], [0.35431211986827776, 0.21438054570807566], [0.35431211986827776, 0.21438054570807566],
所以我使用seaborn.kdeplot()进行可视化,只给出了KDE的2D可视化:

但我想要一个3D结果,就像在这个二元正态分布图中,其中de X和Y轴是2d矩阵,z轴是pdf:

我想我只需要为我列表中的每个向量找到一个好的pdf估计。有没有办法将KDE拟合到我的数据中,以便获得每个向量的近似分布,然后绘制曲面?
非常感谢
发布于 2020-06-03 16:17:45
这里有一种方法可以做到:
x = np.random.normal(5, 10, 100000)
y = np.random.normal(10, 3, 100000)
h = np.histogram2d(x, y, bins=50)
def bin_centers(bins):
centers = (bins + (bins[1]-bins[0])/2) [:-1]
return centers
x_bins_centers = bin_centers(h[1])
y_bins_centers = bin_centers(h[2])
df = pd.DataFrame(h[0], index=x_bins_centers, columns=y_bins_centers)
fig = go.Figure(data=[go.Surface(z=df)])
fig.show()结果是:

https://stackoverflow.com/questions/62158473
复制相似问题