def test_log_prod_students_t():
np.random.seed(1)
# Prior
D = 10
m_0 = 5*np.random.rand(D) - 2
k_0 = np.random.randint(15)
v_0 = D + np.random.randint(5)
S_0 = 2*np.random.rand(D) + 3
prior = NIW(m_0=m_0, k_0=k_0, v_0=v_0, S_0=S_0)
# GMM we will use to access `_log_prod_students_t`
x = 3*np.random.rand(D) + 4
gmm = GaussianComponentsDiag(np.array([x]), prior)
expected_prior = np.sum(
[students_t(x[i], m_0[i], S_0[i]*(k_0 + 1)/(k_0 * v_0), v_0) for i in range(len(x))]
)
npt.assert_almost_equal(gmm.log_prior(0), expected_prior)
test_gaussian_components_diag.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录