0
$\begingroup$

I am currently studying what Markov models are, and have a question. If we have a hidden Markov model with 2 hidden states or observations, then how do we find the probability of just the main state happening?

What I mean by this is that let's say we have the typical states of whether it's going to rain or not, where the observations are that we are using an umbrella or not and that we are happy or sad. If we are given the probability table for all of these, how do we find the probability of JUST the state happening (P(Rain1), P(Rain2), P(Rain3), etc) using those observations?

$\endgroup$

1 Answer 1

3
$\begingroup$

One solution to this problem is the forward-backward algorithm, which produces the probabilities that you need. The details of the computation are for example described in Section III.B of Rabiner (1989), A Tutorial on Hidden Markov Models, and I include some of the equations below (trying to stay as close as possible to Rabiner's notation).

Notation

Following Rabiner (1989), consider the notation:

  • $O_t$ = observation at time $t$ (e.g., $O_t \in \{ \text{Umbrella}, \text{No Umbrella}\}$)
  • $q_t$ = state at time $t$; for simplicity, the states can be indexed by positive integers (e.g., $q_t \in \{ 1, 2\}$ if there are two possible states)
  • $\lambda$ = vector of all model parameters (initial distribution, transition probabilities, and state-dependent observation parameters)
  • $T$ = length of the time series, i.e., time goes from $t = 1$ to $t = T$
  • $N$ = number of states (e.g., $N=2$ in your example for rain and no rain)

Forward and backward variables

The forward variable $\alpha_t(i)$ is defined (Rabiner, Equation 18) as $$ \alpha_t(i) = \Pr(O_1, O_2, \dots, O_t, q_t = i \mid \lambda), $$ i.e., the probability (or probability density for continuous observations) of observing the sequence $O_1, \dots, O_t$ up to time $t$ and being in state $i$ at time $t$, given the model described by $\lambda$.

Similarly, the backward variable $\beta_t(i)$ is defined (Rabiner, Equation 23) as $$ \beta_t(i) = \Pr(O_{t+1}, O_{t + 2}, \dots, O_T \mid q_t = i, \lambda), $$ i.e, the probability/density of observing a given sequence between times $t+1$ and $T$, given that the state at time $t$ is $i$, and given the model parameters $\lambda$.

Both forward and backward variables can be computed relatively easily using iterative algorithms, sometimes called the "forward" and "backward" algorithms, described in Equations 19-20 and 24-25 of Rabiner (1989), respectively.

State probabilities

The quantity that you are interested in is the state probability $$ \gamma_{t}(i) = \Pr(q_t = i \mid O_1, \dots, O_T, \lambda), $$ for all times $t \in \{ 1, \dots, T\}$ and states $i \in \{ 1, \dots, N\}$. From the definition of conditional probability, $$ \gamma_{t}(i) = \frac{\Pr(q_t = i, O_1, \dots, O_T \mid \lambda)}{\Pr(O_1, \dots, O_T \mid \lambda)} $$ where $$ \begin{aligned} \Pr(q_t = i, O_1, \dots, O_T \mid \lambda) & = \Pr(O_1, \dots, O_t, q_t = i \mid \lambda) \times \Pr(O_{t+1}, \dots, O_T \mid q_t = i, \lambda) \\ & = \alpha_t(i) \beta_t(i) \end{aligned} $$

From the law of total probability, we can also write the denominator as $$ \begin{aligned} \Pr(O_1, \dots, O_T \mid \lambda) & = \sum_{k=1}^N \Pr(q_t = k, O_1, \dots, O_T \mid \lambda) \\ & = \sum_{k=1}^N \alpha_t(k) \beta_t(k) \end{aligned} $$

Finally, the state probabilities can be computed from the forward and backward variables as $$ \gamma_t(i) = \frac{\alpha_t(i)\beta_t(i)}{\sum_{k=1}^N \alpha_t(k)\beta_t(k)} $$

In conclusion, to compute the state probabilities, we would start by running the forward and backward algorithms (collectively known as the forward-backward algorithm), and then use the last formula above.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .