# make prediction with HMM

I want to use HMM to make some prediction. say $O$ is the observation, $S$ is the hidden states, and I know how to train the model with forward-backward algorithm. I just get confused with how to calculate the probability of the next observation.

According to this, I know in the forward pass:

$\alpha_t(i) = P(O_{1:t},S_t=s_i | \lambda)$

And I think that in order to calculate $P(O_{T+1})$, use this equ(1):

$P(O_{T+1}|O_{1:T},\lambda)=\sum_S P(O_{T+1}|S_{T+1})\cdot \sum_S P(S_{T+1}|S_T)\cdot P(S_T|O_{1:T},\lambda)$

, where the $s$ in first $\sum$ denotes for $S_{T+1}$ taking different $s$, and the $s$ in second $\sum$ denotes for $S_T$ taking different $s$.

In the above formula, the only unknown part is $P(S_T|O_{1:T},\lambda)$, however $\alpha_T(i) = P(O_{1:T},S_T=s_i | \lambda) = P(S_T|O_{1:T},\lambda)\cdot P(O_{1:T}|\lambda)$.

And I think $P(O_{1:T}|\lambda)$ is a constant? so I can ignore it and have equ(2):

$P(O_{T+1}|O_{1:T},\lambda)=\sum_S P(O_{T+1}|S_{T+1})\cdot \sum_S P(S_{T+1}|S_T=s_i)\cdot \alpha_T(i)$

Is equ(1) right? and is equ(2) right?

Did not check the page. But Eq. 1 looks right to me. In Eq 2, you do not need to drop the normalizing constant because

\begin{align*} \alpha_T(i) &= P(O_{1:T}, S_T=s_i |\lambda) \\ \sum_i \alpha_T(i) &= \sum _{s_i} P(O_{1:T}, S_T=s_i |\lambda) = P(O_{1:T} |\lambda) \\ P(S_T=s_i|O_{1:T},\lambda) &= \frac{\alpha_T(i)}{\sum_j \alpha_T(j)} \end{align*}