1
$\begingroup$

For one of my projects I need to find posterior probability of visiting a state S and emitting a symbol. I have built a HMM in R and later I get one observation sequence. But, I am not able to interpret the output.

> # Sequence of observations
> observations = c("L","L","R","R")
> # Calculate posterior probablities of the states
> posterior = posterior(hmm, observations) ## ---> hmm is hidden markov model
> print(posterior)  
      index
states         1       2       3         4
     A 0.6037344 0.56639 0.43361 0.3962656
     B 0.3962656 0.43361 0.56639 0.6037344

How do I interpret this? This matrix gives output w.r.t time. But, I need posterior probability of visiting a state S and emitting a symbol say A. How can I get it?


Thanks for the response.The description says it combines forward and backward probabilities to get posterior details...But,as i have read in papers, the forward-backward algorithm gives the probability of being in a state say A and emitting a symbol say L.. which i do not see here. Here is all the details of HMM - # Initialise HMM # init HMM format: A and B are hidden states,L and R are observations,transprob: initial # transition probabilities and emissionprobs IS EMISSION probability hmm = initHMM(c("A","B"), c("L","R"), transProbs=matrix(c(.8,.2,.2,.8),2), emissionProbs=matrix(c(.6,.4,.4,.6),2)) print(hmm)

Sequence of observations

observations = c("L","L","R","R")

Calculate posterior probablities of the states

posterior = posterior(hmm,observations) print(posterior)

Description of POSTERIOR: This function computes the posterior probabilities of being in state X at time k for a given sequence of observations and a given Hidden Markov Model.

Details The posterior probability of being in a state X at time k can be computed from the forward and backward probabilities: Ws(X_k = X | E_1 = e_1, ... , E_n = e_n) = f[X,k] * b[X,k] / Prob(E_1 = e_1, ... , E_n = e_n) Where E_1...E_n = e_1...e_n is the sequence of observed emissions and X_k is a random variable that represents the state at time k.

But,in general how can we calculate posterior probability without using this algo

$\endgroup$
1
  • $\begingroup$ Thank you for the detail! I do not understand why you would like to calculate the posterior probabilities without the Foward-Backward (FB) algorithm, because the FB is the algorithm to get the posterior probabilities. $\endgroup$
    – gui11aume
    Commented Jun 1, 2012 at 15:29

1 Answer 1

1
$\begingroup$

The forward-backward algorithm requires a transition matrix and prior emission probabilities. It is not clear where they were specified in your case because you do not say anything about the tools you used (like the package that contains the function posterior) and earlier events of your R session.

Anyway, if you are looking for the probability of emitting symbol A in state S, it is there, in the prior emission probabilities. But they are priors, not posteriors. In addition, your symbols seem to be "L" and "R" and your states "A" and "B", so it looks your questions is not phrased properly.

Now, regarding how to interpret the posterior, those are the probabilities of being in state "A" (or "B") for each index given the priors and the full set of observations. For instance, given the emission probabilites (not shown), the transition matrix (not shown) and the observation sequence ("L","L","R","R"), the probability that the HMM was initially in state "A" is 0.60.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.