Viterbi gives one path. Often you need the probability that the hidden state is i at time t, given the whole observed sequence. That is the smoothed posterior gamma_t(i) = p(s_t = i | obs), computed with the forward-backward algorithm.
alpha_0(i) = pi_i B[i, o_0], alpha_t(j) = (sum_i alpha_(t-1)(i) A[i, j]) B[j, o_t].beta_(T-1)(i) = 1, beta_t(i) = sum_j A[i, j] B[j, o_(t+1)] beta_(t+1)(j).gamma_t(i) is proportional to alpha_t(i) beta_t(i), normalized over i.Implement state_posteriors(pi, A, B, obs). It returns a (T, K) array whose rows sum to 1.
0..M-1.ValueError.Store every forward vector, run the backward pass from the end, and combine them row by row. Normalize each row so rounding does not accumulate.
No results yet
Run your code to check it against the examples, or submit to run every test.