test_gaussian_components_fixedvar.py 文件源码

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

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

    np.random.seed(1)

    # Prior
    D = 10
    var = 1*np.random.rand(D)
    mu_0 = 5*np.random.rand(D) - 2
    var_0 = 2*np.random.rand(D)
    prior = FixedVarPrior(var, mu_0, var_0)

    # GMM will be used to access `_log_prod_norm`
    x = 3*np.random.rand(D) + 4
    gmm = GaussianComponentsFixedVar(np.array([x]), prior)

    expected_prior = np.sum([log_norm_pdf(x[i], mu_0[i], var_0[i]) for i in range(len(x))])

    npt.assert_almost_equal(gmm.log_prior(0), expected_prior)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号