def check_params(natparam): natparam2 = standard_to_natural(*natural_to_standard(natparam)) assert np.allclose(natparam, natparam2)
def rand_niw(n): S = rand_psd(n) + n * np.eye(n) m = npr.randn(n) kappa = n + npr.uniform(1, 3) nu = n + npr.uniform(1, 3) return standard_to_natural(S, m, kappa, nu)
def init_niw_natparam(N): nu, S, m, kappa = N+niw_conc, (N+niw_conc)*np.eye(N), np.zeros(N), niw_conc m = m + random_scale * npr.randn(*m.shape) return niw.standard_to_natural(S, m, kappa, nu)