# ML Review -- Hidden Markov Model

### Hidden Markov Models

A Hidden Markov Model($N$,$\sum$,$\Theta$) consists of the following elements:

1.$N$ is a positive integer specifying the number of states in the model. Without loss of generality, we will take the $N$th state to be a special state, the final or stop state.

2.$\sum$ is a set of output symbols, for example $\sum={a,b}$

3.$\Theta$ is a vector of parameters. It contains three types of parameters:

- $\pi*j$ for $j=1\ldots N$ is the probability of choosing state $j$ as an initial state. Note that $\sum*{j=1}^{N} \pi*j=1$
- $a*{j,k}$ for $j=1\ldots (N-1),k=1\ldots N$, is the probability of transitioning from state $j$ to state $k$. Note that for all $j$, $\sum

*{k=1}^{N}a*{j,k}=1$

- $b
*j(o)$ for $j=1\ldots N-1$, and $o \in \sum$, is the probability of emitting symbol $o$ from state j. Note that for all $j$, $\sum*{o\in \sum} b_j(o) =1$.

Thus it can be seen that $\Theta$ is a vector of $N+(N-1)N+(N-1)|\sum|$ parameters.

An HMM specifies a probability for each possible $(x,y)$ pair, where x is a sequence of symbols drawn from $\sum$, and y is a sequence of states drawn from the integers $1\ldots N-1$. The sequences $x$ and $y$ are restricted to have the same length. As an example, say we have an HMM with $N=3, \sum{a,b}$, and with some choice of the parameters $\Theta$. Take $x = a,a,b,b$ and $y=1,2,2,1$. Then in this case,

$P(x,y|\Theta) = \pi*1 a*{1,2} a*{2,2} a*{2,1} a*{1,3} b*1(a) b*2(a) b*2(b) b_1(b) $

Thus we have a product of terms specifying the probability of emitting each symbol from its associated state.

In general, if we have the sequence $x$, and the sequence$y$,
$P(x,y|\Theta) = \pi*y1 a*{y*n,N}\prod*{j=2}^{n}a*{y*{j-1,y*j}}\prod*{j=1}^{n}b*{y*j}(x_j)$

Thus we see that the probability is a simple function of the prameters $\Theta$.