I am having a hard time understanding how to use the observation matrix B for continuous HMM assuming the observation of each hidden state Normal.

So far I defined the matrix B as an Nx2 matrix where N is the number of states and 2 is mean and variance of the Normal dist. Question 1: is this correct?

Now, I want to use the values inside the matrix B in the forward algorithm (let's call b the terms inside the matrix B). The forward algorithm I am referring is the following one:

enter image description here

In particular, in step (b), I have to multiply the bracket by bj(Ot) and I am not sure how to define it.

Online I found the following definition in terms of pdf: enter image description here

Question 2: Is this formula correct to be used in the forward alg.? In this formula I know the mean and variance for each hidden state that are contained in the matrix B. By the way, I do not know how to define Ot. In fact, my initial idea was to use the single observation at time t. By the way, knowing that the continuous pdf of a single number is 0, this makes no sense. Question 3: Am I missing something? How can I formulate this?

Thank you so much in advance!


1 Answer 1


Question 1: Yes, you will have one mean and one variance for each hidden state.

Question 2 and 3: $o_t$ is your observation, the realization of your observed random variable. In case of continuous observations it is then a scalar. Yes, the formula of the gaussian density function is the correct formula to plug in your observations. It is the quantity to be used in the forward-backward algorithm. It is not $0$ as you will see when you will implement the algorithm. This density has to be thought as a likelihood of the observations which gives a score at seeing this observation, not a probability in the strict sense.

  • $\begingroup$ The problem I have is when I implement the algorithm (Forward). Every iteration on t I obtain always a very small value of bj(t) (close to 10^-4/10^-5). For this reason, every iteration I obtain smaller and smaller values of alpha that lead to a final probability equal to 0. I am implementing the code in MATLAB and I am using the function normdist. $\endgroup$ Dec 8, 2020 at 22:35
  • $\begingroup$ For instance, b1(o1)=normpdf(786,mu=1151.6, std=181)=2.8660e-04. Is there a way to overcome this problem? Can normalizing the bj(ot) values be an idea? Thank you so much in advance! $\endgroup$ Dec 8, 2020 at 22:37
  • $\begingroup$ Yes renormalization at each time step of you forward and backward probabilities is permitted and is a way to handle this problem (this article deals with the topic) $\endgroup$
    – TheCG
    Dec 9, 2020 at 6:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.