test_gaussian_components.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:PyBGMM 作者: junlulocky 项目源码 文件源码
def test_map():

    # Setup densities
    prior = NIW(m_0=np.array([0.0, 0.0]), k_0=2.0, v_0=5.0, S_0=5.0*np.eye(2))
    gmm = GaussianComponents(np.array([
        [1.2, 0.9],
        [-0.1, 0.8]
        ]), prior)
    gmm.add_item(0, 0)
    gmm.add_item(1, 0)

    mu_expected = np.array([0.275, 0.425])
    sigma_expected = np.array([
        [0.55886364, 0.04840909],
        [0.04840909, 0.52068182]
        ])

    # Calculate the posterior MAP of the parameters
    mu, sigma = gmm.map(0)

    npt.assert_almost_equal(mu, mu_expected)
    npt.assert_almost_equal(sigma, sigma_expected)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号