HMM and State Duration Estimation State duration in HMMs follows a geometric distribution by construction. How can one estimate the state duration, since it is not explicitly modeled (e.g., in HSMMs)? I'm particularly interested in the following packages: hmmlearn (Python) and depmixS4 or hmm (R).
For example, a left-right HMM starts in state 1. Suppose the model has been learned. After getting some observations, suppose I obtain the following best state sequence by applying the Viterbi algorithm: 2-2-3-3-3-4. How do I estimate the time it took from state 1 to state 4? Do I have to sample from a geometric distribution (where its parameter p is the state transition probability) for each state transition (i.e., 1-2, 2-2, 2-2, 2-3, etc.), and then add up all sampled values until state 4 is reached? If that's correct, then I would carry out this procedure several times to get summary statistics (mean, standard deviation, etc.) of the total "time" from state 1 to 4. But sampling from the geometric distribution gives me an integer value. What does that mean? Am I missing some concepts?
 A: I will try to give you some ideas to see if this helps:
First of all, as long as you work with HMM (as you mention you do) avoid using "time" concept. Here, you are working with transitions. This might be time related if transitions happen always after some determined time. But I would not use "total time" and would use "total number of transitions" instead.
Having said that, of course the number of transitions the system will remain in a certain state a is geometrically distributed in the case of HMM. Imagine a state has a self transition probability of P(a->a) = 0.5. The probability of remaining in that step for two transitions or steps would be 0.5*0.5=0.25, three 0.125 and so on... This defines a geometric distribution with parameter p as you indicated.
Sampling from that geometrical distribution will therefore give you an integer corresponding to the number of steps the state remains unchanged (self transition). But again, careful with the time concept. As @Juho Kokkala suggested, that particular sequence of states took 6 steps or transitions.
