I have a 3 state HMM model ("state1", "state2", "state3"), with an alphabet of "1" ("hit") and "0" ("miss"). Here are the parameters (these are just for example's sake) that this HMM is defined by:
Start State Probabilities
startProbs=c(0.5,0.5,0)
State Transition Probability Matrix
transProbs=rbind(c(0.667,0.333,0), c(0.333,0.333,0.333), c(0,0.333,0.667))
Emission Probability Matrix
emissionProbs=cbind(c(0.95,0.05), c(0.75,0.25), c(0.05,0.95))
I'm using an R package called HMM. It makes it easy to initialize the model with the following call:
hmmModelApriori <- initHMM(States=c("S1", "S2", "S3"), Symbols=c("1", "0"),
startProbs=c(0.5,0.5,0),
transProbs=rbind(c(0.667, 0.333, 0),
c(0.333, 0.333, 0.333),
c(0, 0.333, 0.667)),
emissionProbs=cbind(c(0.95,0.05), c(0.75,0.25), c(0.05,0.95)))
Using the package, I can calculate the posterior of a given observation sequence, such as:
obs = c("1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1")
The HMM model outputs probabilities for each "time point", for all 3 states, where the probabilities of all states for a given time point sum to 1.
p = posterior(hmmModelApriori, obs)
My question is, how do I get the joint probability for my test sequence (the variable "obs" shown above)?
P(obs) = ?
The output of the function "posterior" gives you a matrix of probabilities with dimension #states x #observations. However, I want a single probability for the entire observation sequence, obs. How do I calculate P(obs) from the output of HMM's posterior()
function, stored as a variable "p" in the above code?