Commit a231f1f5 by Emmanuel PIGNAT

### correcting bug in multivariate-t pdf

parent 66137835
 ... ... @@ -262,7 +262,7 @@ def multi_variate_t(x, nu, mu, sigma=None, log=True, gmm=False, lmbda=None): :param log: bool :return: """ from scipy.special import gamma from scipy.special import gamma, gammaln if not gmm: if type(sigma) is float: sigma = np.array(sigma, ndmin=2) ... ... @@ -288,9 +288,9 @@ def multi_variate_t(x, nu, mu, sigma=None, log=True, gmm=False, lmbda=None): (1 + 1/nu * dist) ** (-(nu+p)/2) return lik else: log_lik = np.log(gamma((nu + p)/2)) + 0.5 * np.linalg.slogdet(lmbda_)[1] - \ (np.log(gamma(nu / 2)) + (p / 2) * np.log(nu) + (p / 2) * np.log(np.pi)) + \ ((-(nu + p) / 2) * np.log(1 + 1 / nu * dist)) log_lik = gammaln((nu + p)/2) + 0.5 * np.linalg.slogdet(lmbda_)[1] - \ gammaln(nu/2) - p/2. * (np.log(nu) + np.log(np.pi)) +\ ((-(nu + p) / 2) * np.log(1 + dist / nu)) return log_lik else: ... ... @@ -326,7 +326,7 @@ def multi_variate_normal(x, mu, sigma=None, log=True, gmm=False, lmbda=None): if sigma is not None: log_lik -= 0.5 * (x.shape[1] * np.log(2 * np.pi) + np.linalg.slogdet(sigma)[1]) else: log_lik += 0.5 * np.linalg.slogdet(2 * np.pi * lmbda)[1] log_lik -= 0.5 * (x.shape[1] * np.log(2 * np.pi) - np.linalg.slogdet(lmbda)[1]) return log_lik if log else np.exp(log_lik) ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!