# How to calculate using probability using hidden Markov model

So a hidden markov model consists of hidden states $$H_i \in \{1,2,...,n\}, i \in \{1,...,\infty\}$$, observable states $$O_j \in \{1,...,p\}, j \in \{1,...,\infty \}$$, transition probabilities $$P(X_i=x|X_{i-1}=y), \forall i\in\{2,...,\infty\}, \forall x,y \in \{1,...,n\}$$, emission probabilities $$P(O_j=k|H_j=m), \forall k\in\{1,...,p\}, \forall m \in \{1,...,n\}$$.

The probability of observing a sequence $$x_1,...,x_k$$ is $$P(x_1,...,x_k)=\sum_{i_1}P(O_1=x_1|H_1=i_1)P(H_1=i_1)\sum_{i_2}P(O_2=x_2|H_2=i_2)P(H_2=i_2|H_1=i_1)...\sum_{i_k}P(O_k=x_k|H_k=i_k)P(H_k=i_k|H_{k-1}=i_{k-1})$$

Fist question is is the calculation of probability correct?

Second question is can you show this computation as matrix products(I know it can)?