def __mul__(self, other):
"""Multiply with a single gaussian."""
assert isinstance(other, Gaussian)
ys = [x * other for x in self.xs]
lcs = np.empty_like(self.a)
for i, (x, y) in enumerate(izip(self.xs, ys)):
lcs[i] = x.logdetP + other.logdetP - y.logdetP
lcs[i] -= np.dot(x.m, np.dot(x.P, x.m)) + np.dot(other.m, np.dot(other.P, other.m)) - np.dot(y.m, np.dot(y.P, y.m))
lcs[i] *= 0.5
la = np.log(self.a) + lcs
la -= scipy.misc.logsumexp(la)
a = np.exp(la)
return MoG(a=a, xs=ys)
评论列表
文章目录