Commit 3948dc09 authored by Emmanuel PIGNAT's avatar Emmanuel PIGNAT
Browse files

correcting important bug in HMM compute messages

parent 57a9c406
......@@ -318,9 +318,9 @@ def multi_variate_normal(x, mu, sigma=None, log=True, gmm=False, lmbda=None):
log_lik = -0.5 * np.einsum('...j,...j', dx, np.einsum('...jk,...j->...k', lmbda_, dx))
if sigma is not None:
log_lik -= 0.5 * np.log(np.linalg.det(2 * np.pi * sigma))
log_lik -= 0.5 * (x.shape[1] * np.log(2 * np.pi) + np.linalg.slogdet(sigma)[1])
else:
log_lik += 0.5 * np.log(np.linalg.det(2 * np.pi * lmbda))
log_lik += 0.5 * np.linalg.slogdet(2 * np.pi * lmbda)[1]
return log_lik if log else np.exp(log_lik)
......
......@@ -202,7 +202,7 @@ class HMM(GMM):
beta = np.zeros((self.nb_states, sample_size))
beta[:, -1] = np.ones(self.nb_states) * c[-1] # Rescaling
for t in range(sample_size - 2, -1, -1):
beta[:, t] = np.dot(self.Trans, beta[:, t + 1]) * B[:, t + 1]
beta[:, t] = np.dot(self.Trans, beta[:, t + 1] * B[:, t + 1])
beta[:, t] = np.minimum(beta[:, t] * c[t], realmax)
# Smooth node marginals, gamma
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment