高斯混合物的密度估计与密度图

时间:2018-04-13 21:26:19

标签: python scipy probability-density kernel-density mixture

我有一个数据集x,它是作为四个不同高斯混合的样本生成的:

mus = [60,150,300,500]
sigmas = [5,10,10,50]
Ns = [380,670,440,810]
Ns_rel = [i/sum(Ns) for i in Ns]
x = []
for mu,sig,N in zip(mus,sigmas,Ns): 
    x = np.append(x,st.norm(mu,sig).rvs(N))

通过数据集seaborn.kdeplot(x) x的核密度图产生:

enter image description here

高斯混合物的“实际”密度的曲线产生 - 然而 - 完全不同的图表:

x_plot = np.arange(-200,1400)
y_plot = np.zeros(1600)
for mu,sig,N in zip(mus,sigmas,Ns_rel): 
    y_plot += st.norm(mu,sig).pdf(x_plot)*N

将样本的核密度估计与实际密度一起绘制产生两个完全不同的图:

sns.kdeplot(x, label="Density Estimation of sample of Gaussian Mixture")
plt.plot(x_plot,y_plot, "-", label="Real density of Gaussian Mixture")
plt.legend()

enter image description here

密度和密度估计应该非常相似,特别是当我的例子中有如此多的样本时。

我在这里做错了什么?

0 个答案:

没有答案
相关问题