How to get the probability of number t element in HMM? Suppose I have 3 hidden states. I want to get the probability of the last element belongs to state 2. How do I achieve this probability?
I have looked at the forward algorithm,

It doesn't seem like the sum of probability of being state 1,2,3 equals 100%.
Which algorithm is proper for inference?

The forward algorithm is the correct choice. The formulae you posted have to be repeated because the forward algorithm is recursive. Fortunately, you only have three states, so the recursion would not take long. You end up with the sum over $h_1$ and $h_2$.
But, instead of doing it manually, I suggest using one of the many available implementations.
