I am looking for some simple Mathematica code to model an HMM with just a few states and an equal number of observable signals (emissions). I am hoping to generate sample paths and keep track of the posterior probability of the system being in a given state. Any help would be appreciated.

  • $\begingroup$ Is this the sort of thing? $\endgroup$
    – cormullion
    Jun 12, 2013 at 14:33
  • 4
    $\begingroup$ Here's a tutorial on fitting hidden markov models in Mathematica including an example applied to financial data. ams.sunysb.edu/~frey/QuantitativeFinance/Resources/… $\endgroup$
    – bill s
    Jun 12, 2013 at 14:49
  • 2
    $\begingroup$ @Tox If you want to simulate paths this might be useful. $\endgroup$
    – Rod
    Jun 12, 2013 at 15:08
  • 2
    $\begingroup$ This needs a v10 answer :) $\endgroup$
    – Rojo
    Jul 13, 2014 at 0:03

2 Answers 2


Mathematica V10 introduced the following two functions:

- HiddenMarkovProcess

- FindHiddenMarkovStates

Examples of their usage can be found here and here.

I've also used HiddenMarkovProcess[] here: Detecting components in timeseries.


Thanks. I also found that there is a package with inbuilt functions, although super pricey, at http://scientificcomputing.blogspot.co.uk/2006/02/statistical-inference-package-for.html


Your Answer

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

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