def messages_backwards(self):
# NOTE: np.maximum calls are because the C++ code doesn't do
# np.logaddexp(-inf,-inf) = -inf, it likes nans instead
from hsmm_messages_interface import messages_backwards_log
betal, betastarl = messages_backwards_log(
np.maximum(self.trans_matrix,1e-50),self.aBl,np.maximum(self.aDl,-1000000),
self.aDsl,np.empty_like(self.aBl),np.empty_like(self.aBl),
self.right_censoring,self.trunc if self.trunc is not None else self.T)
assert not np.isnan(betal).any()
assert not np.isnan(betastarl).any()
if not self.left_censoring:
self._normalizer = np.logaddexp.reduce(np.log(self.pi_0) + betastarl[0])
else:
raise NotImplementedError
return betal, betastarl
评论列表
文章目录