3

Let's assume that I have a random set of observations:

obs = [1, 2, 3, 5, 5, 5, 5, 5]

These observations represent 1 state in the HMM. In Matlab, I want to model these observations so then I can use the Viterbi algorithm in order to create a kind of classifier.

The problem that I am having is that I don't really know where to start in terms of generating the models in Matlab. The functionality in the toolbox does not seem to have this.

Is there a specific library out there, which will enable me to carry out such a procedure in order to model a series of observations?

Phorce
  • 4,424
  • 13
  • 57
  • 107
  • to define a discret hmm you need atleast: a number of states `n` for your model, a `n X n` transition probability, a list of `m` posible observations (emissions) and a `m X n` matrix with the probabilities for each emission in each state. What you have is a series of observations, from that alone you can not define a HMM. – ben Mar 25 '14 at 13:16
  • @ben Thanks! But, I do have a library in C++ that can generate a HMM based just on observations and giving the total number of states? This calculates the transition probabilities and emissions. – Phorce Mar 25 '14 at 13:24

1 Answers1

2

to define a discret hmm you need atleast: a number of states n for your model, a n X n transition probability, a list of m posible observations (emissions) and a n X m matrix with the probabilities for each emission in each state. What you have is a series of observations, from that alone you can not define a HMM.

So i would start by having a look at this tutorial form mathworks to get a grasp of the basics. The functions used there are part of the statistics toolbox.

Then you start by creating a guess for the number of stats in your HMM. Let's say you have 2 stats(like in the tutorial mentioned above) The next step would be the create a initial guess for the emission and transition matrices. if your posible emissions are 1 2 3 4 5 and your states are 2then you get a 2x5 Emission probability matrix and a 2x2 transition matrix.

Now lets assume you guess that state 1 produces 1 2 3 and state 2 produces 4 5 then (evenly distributed) your emission matrix would look like this:

>> emis=[1/3 1/3 1/3 0 0; 0 0 0 1/2 1/2]
emis =
    0.3333    0.3333    0.3333         0         0
         0         0         0    0.5000    0.5000

you also guess that states do change from state 1 to 2 after a few emissins then stay there. your guess would kinda look like this:

>> trans = [.8 .2; 0 1]
trans =
    0.8000    0.2000
         0    1.0000

you can have a look what your HMM would generate:

>> [seq,states] = hmmgenerate(6, trans, emis)
seq =
     2     1     3     2     4     5

states =
     1     1     1     1     2     2

from that point you use observation series to train your HMM with the functions hmmestimate or hmmtrain.

ben
  • 1,380
  • 9
  • 14