def plot_model(model, data):
"""
:param model: the GMM model
:param data: the data set 2D
:return:
"""
delta = 0.025
x = np.arange(0.0, 4, delta)
y = np.arange(0.0, 4, delta)
X, Y = np.meshgrid(x, y)
z = np.zeros((np.size(x), np.size(y)))
# sum of Gaussian
plt.figure()
for i in range(np.size(model)):
ztemp = mlab.bivariate_normal(X, Y, np.sqrt(model['cov'][i][0, 0]), np.sqrt(model['cov'][i][1, 1]), model['mu'][i][0], model['mu'][i][1], model['cov'][i][0,1])
plt.contour(X, Y, model['w'][i]*ztemp)
z = np.add(z, ztemp)
plt.scatter(data[0, :], data[1, :], s=5)
plt.figure()
plt.contour(X, Y, z*np.size(model))
plt.scatter(data[0, :], data[1, :], s=5)
gmm2.0.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录