# Path: distributions/dbg/random.py
# def score_student_t(x, nu, mu, sigma):
#     """
#     multivariate score_student_t
# 
#     \cite{murphy2007conjugate}, Eq. 313
#     """
#     p = len(mu)
#     z = x - mu
#     S = inner(inner(z, inv(sigma)), z)
#     score = (
#         gammaln(0.5 * (nu + p))
#         - gammaln(0.5 * nu)
#         - 0.5 * (
#             p * log(nu * pi)
#             + log(det(sigma))
#             + (nu + p) * log(1 + S / nu)
#         )
#     )
#     return score
# 
# def sample_normal_inverse_wishart(mu0, lambda0, psi0, nu0):
#     D, = mu0.shape
#     assert psi0.shape == (D, D)
#     assert lambda0 > 0.0
#     assert nu0 > D - 1
#     cov = sample_inverse_wishart(nu0, psi0)
#     mu = np.random.multivariate_normal(mean=mu0, cov=(1. / lambda0) * cov)
#     return mu, cov


import numpy as np
import math
from scipy.special import multigammaln
from distributions.dbg.random import (
    score_student_t,
    sample_normal_inverse_wishart,
)
from distributions.mixins import SharedMixin, GroupIoMixin, SharedIoMixin
        'shared': {
            'mu': np.zeros(2),
            'kappa': 2.,
            'psi': np.eye(2),
            'nu': 3.,
        },
        'values': [np.array(v) for v in (
            [1., 2.],
            [-2., 3.],
            [-0.2, -0.2],
            [-0.1, 0.5],
            [0.8, 0.5],
            [0.8, 0.3],
            [-9., 0.2],
        )],
    },
    {
        'shared': {
            'mu': np.ones(3),
            'kappa': 7.5,
            'psi': np.eye(3),
            'nu': 5.,
        },
        'values': [np.array(v) for v in (
            [1.35, 0.97, 0.88],
            [0.87, 1.74, 2.13],
            [-0.31, 1.48, 1.96],
            [1.18, 0.34, 1.00],
            [1.47, 0.62, -0.10],
            [-0.23, 2.23, 0.99],

# Path: distributions/dbg/random.py
# def score_student_t(x, nu, mu, sigma):
#     """
#     multivariate score_student_t
# 
#     \cite{murphy2007conjugate}, Eq. 313
#     """
#     p = len(mu)
#     z = x - mu
#     S = inner(inner(z, inv(sigma)), z)
#     score = (
#         gammaln(0.5 * (nu + p))
#         - gammaln(0.5 * nu)
#         - 0.5 * (
#             p * log(nu * pi)
#             + log(det(sigma))
#             + (nu + p) * log(1 + S / nu)
#         )
#     )
#     return score
# 
# def sample_normal_inverse_wishart(mu0, lambda0, psi0, nu0):
#     D, = mu0.shape
#     assert psi0.shape == (D, D)
#     assert lambda0 > 0.0
#     assert nu0 > D - 1
#     cov = sample_inverse_wishart(nu0, psi0)
#     mu = np.random.multivariate_normal(mean=mu0, cov=(1. / lambda0) * cov)
#     return mu, cov


# Path: distributions/dbg/models/niw.py
import numpy as np
import math
from scipy.special import multigammaln
from distributions.dbg.random import (
    score_student_t,
    sample_normal_inverse_wishart,
)
from distributions.mixins import SharedMixin, GroupIoMixin, SharedIoMixin

        'shared': {
            'mu': np.zeros(2),
            'kappa': 2.,
            'psi': np.eye(2),
            'nu': 3.,
        },
        'values': [np.array(v) for v in (
            [1., 2.],
            [-2., 3.],
            [-0.2, -0.2],
            [-0.1, 0.5],
            [0.8, 0.5],
            [0.8, 0.3],
            [-9., 0.2],
        )],
    },
    {
        'shared': {
            'mu': np.ones(3),
            'kappa': 7.5,
            'psi': np.eye(3),
            'nu': 5.,
        },
        'values': [np.array(v) for v in (
            [1.35, 0.97, 0.88],
            [0.87, 1.74, 2.13],
            [-0.31, 1.48, 1.96],
            [1.18, 0.34, 1.00],
            [1.47, 0.62, -0.10],
            [-0.23, 2.23, 0.99],

            [1.23, 0.98, 0.36],