Module: ghmm  /amd/bernoulli/1/home/abt_vin/georgi/hmm/0.7/ghmm//ghmmwrapper/ghmm.py  

Python bindings for the GHMM Clibrary. The Design of ghmm.py HMMs are stochastic models which encode a probability density over sequences of symbols. These symbols can be discrete letters (A,C,G and T for DNA; 1,2,3,4,5,6 for dice), real numbers (weather measurement over time: temperature) or vectors of either or the combination thereof (weather again: temperature, pressure, percipitation). Note: We will always talk about emissions, emission sequence and so forth when we refer to the sequence of symbols. Another name for the same object is observation resp. observation sequence. The objects one has to deal with in HMM modelling are the following 1) The domain the emissions come from: the EmissionDomain. Domain is to be understood mathematically and to encompass both discrete, finite alphabets and fields such as the real numbers or intervals of the reals. For technical reasons there can be two representations of an emission symbol: an external and an internal. The external representation is the view of the application using ghmm.py. The internal one is what is used in both ghmm.py and the ghmm Clibrary. Representations can coincide, but this is not guaranteed. Discrete alphabets of size k are represented as [0,1,2,...,k1] internally. It is the domain objects job to provide a mapping between representations in both directions. NOTE: Do not make assumptions about the internal representations. It might change. 2) Every domain has to afford a distribution, which is usually parameterized. A distribution associated with a domain should allow us to compute $\Prob[x distribution parameters]$ efficiently. The distribution defines the type of distribution which we will use to model emissions in every state of the HMM. The type of distribution will be identical for all states, their parameterizations will differ from state to state. 3) We will consider a Sequence of emissions from the same emission domain and very often sets of such sequences: SequenceSet 4) The HMM: The HMM consists of two major components: A Markov chain over states (implemented as a weighted directed graph with adjacency and inverseadjacency lists) and the emission distributions perstate. For reasons of efficiency the HMM itself is static, as far as the topology of the underlying Markov chain (and obviously the EmissionDomain) are concerned. You cannot add or delete transitions in an HMM. Transition probabilities and the parameters of the perstate emission distributions can be easily modified. Particularly, BaumWelch reestimation is supported. While a transition cannot be deleted from the graph, you can set the transition probability to zero, which has the same effect from the theoretical point of view. However, the corresponding edge in the graph is still traversed in the computation. States in HMMs are referred to by their integer index. State sequences are simply list of integers. If you want to store application specific data for each state you have to do it yourself. Subclasses of HMM implement specific types of HMM. The type depends
on the EmissionDomain, the Distribution used, the specific
extensions to the 5) HMMFactory: This provides a way of constucting HMMs. Classes derived from HMMFactory allow to read HMMs from files, construct them explicitly from, for a discrete alphabet, transition matrix, emission matrix and prior or serve as the basis for GUIbased model building. There are several ways of using the HMMFactory. Static construction: HMMOpen(fileName) # Calls an object of type HMMOpen instantiated in ghmm HMMOpen(fileName, type=HMM.FILE_XML) HMMFromMatrices(emission_domain, distribution, A, B, pi) # B is a list of distribution parameters Examples: hmm = HMMOpen(
