## Forward Equations for the Segment HMM

### February 21, 2009

This is a derivation of the forward equations for the Segment HMM to follow on from my last post. Again I should say that this mostly based on Kevin Murphy’s Segment HMM tutorial which you should probably be reading instead of these posts.

My aim, for this post, is to describe the forward algorithm for segment HMMs, which will be used, along with the backward algorithm, in the Baum-Welch algorithm for estimation the paramters of the model. All the notation follows on from the post preceding this one, which defined the segment HMM. We’ll begin by defining the forward variable:

This is the joint probability of the th state and the observations up to and including . We want to know this probability for each different state, so we can figure out which one is more likely given our observations. We’ll use this to estimate the parameters of the model later on.

The point of the forward algorithm is to be able to calculate this probability at each point in time in a way that doesn’t melt our computers. To do this, we simply define an algorithm that expresses down as a function of past s. This is possible because we can exploit the structure in our model – namely that, given the abstract state, our observation sequences are independent from one another. To do this we’re going to need to include information about the duration of each segment, so let’s get that over with first:

where is the duration of the segment. This allows us to split up the current segment from the rest of the observations:

which is great, because now the first term is our observation distribution. OK, noting that , we can re-write in terms of the past s by introducing all of the durations and all of the states:

(I’ve dropped the notation in favour of just because these equations started to take up more than one line). This we can split up again, to give

which, because and are independent of the observations, gives

Now we apply an assumption that to give

which allows us to split up the sum a bit:

and, hey presto:

which is great – the variable written in terms of its previous entries, and the model distributions! Don’t forget that to actually do this on more than just a few observations you’re going to need to use logs. Check out Kevin’s tutorial paper for the details.