def _set_steadyprob(self, steadyprob):
if steadyprob is None:
steadyprob = np.ones(shape=(self.n_partial_states, self.n_hidden_states)) / self.n_hidden_states
else:
steadyprob = np.asarray(steadyprob, dtype=np.float)
# check if there exists a component whose value is exactly zero
# if so, add a small number and re-normalize
if not np.alltrue(steadyprob):
steadyprob = normalize(steadyprob, axis=1)
if len(steadyprob) != self.n_partial_states:
raise ValueError('steadyprob must have length n_partial_states')
if not np.allclose(np.sum(steadyprob, axis=1), 1.0):
raise ValueError('steadyprob must sum to 1.0')
self._log_steadyprob = np.log(np.asarray(steadyprob).copy())
评论列表
文章目录