Open Source Text Processing Project: GHMM

Deep Learning Specialization on Coursera

GHMM: The General Hidden Markov Model library

Project Website:

Github Link: None


The General Hidden Markov Model library (GHMM) is a freely available C library implementing efficient data structures and algorithms for basic and extended HMMs with discrete and continous emissions. It comes with Python wrappers which provide a much nicer interface and added functionality. The GHMM is licensed under the LGPL.

Defining a HMM with two states which output either heads or tails (think of two coins which get exchanged occasionally) is as easy as this:

> python
Python 2.6.4 (r264:75706, Mar 16 2010, 09:46:46)
[GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import ghmm
>>> sigma = ghmm.Alphabet([‘h’,’t’])
>>> m = HMMFromMatrices(sigma, ghmm.DiscreteDistribution(sigma),
… [[0.9, 0.1], [0.3, 0.7]], [[0.5, 0.5], [0.2, 0.8]], [1.0, 0.0])
>>> print m

>>> help(m)

Here the last three arguments for HMMFromMatrices are the transition matrix, the emission matrix, and the initial distribution. For example 0.9 is the probability of staying in the first state. The first state uniformly emits heads or tails, the second state produces tails with a probability of 0.8. The HMM always starts in the first state.


Discrete and continous emissions
Mixtures of PDFs for continous emissions
Non-homogenous Markov chains
Pair HMMs
Clustering and mixture modelling for HMMs
Graphical Editor HMMEd
Python bindings
XML-based file format
Portable (autoconf, automake)

Leave a Reply

Your email address will not be published. Required fields are marked *