I want to train a sequence classifier with Hidden Markov Model. The length of observation sequences is not fixed. I tried some HMM packages such as Matlab's HMM toolbox and Kevin Murphy's library. All of them seem to require the user to specify the size of transition probability matrix and emission probability matrix.

I understand that for a Hidden Markov Model (HMM), the sizes of the transition probability matrix and emission probability matrix are dependent on the number of hidden states and the length of observation sequence.

For example if:

states = ('Rainy','Sunny')
observations = ('walk', 'shop', 'clean')

The number of states is 2, the length of observation is 3. Then, transition probability would be a 2x2 matrix. Whereas, emission probability would be a 2x3 matrix.

What if the length of observation sequence is not fixed?

For example:

observation 1 = ('walk', 'shop', 'clean')
observation 2 = ('walk', 'shop', 'clean','eat pizza')
observation 3 = ('walk', 'shop', 'clean','drink beer','eat pizza')
...so on

What's the size of emission probability matrix in this case? Or can I just make the observation sequence the same length by padding with zeros?


1 Answer 1


No worries, length of observation would help in training of model. longer the length, training for Forward-backward Algo/baum Welch algo would be better. But length of observation is nothing to do with forecasting. read my blog below-


transition probabilities would give next hidden state. and from next hidden state you can get next observation.So number of observation would not matter as long as u have trained model( emission and transition probabilities). Also if are intrested to know in detail that how next state would be calculated, follow below article.



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.