# HMM and State Duration Estimation [closed]

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?

• If the state sequence (including the starting state $1$) is $1-2-2-3-3-3-4$, is the answer not $6$ steps? Is the issue here that you are looking to average over other possible sequences, not just the most likely one? Or are you looking for a continuous time model? (Or am I misunderstanding something) – Juho Kokkala Jan 15 '18 at 7:20
• I see. I guess I was getting a bit confused between "time" and "transition". See my comment on @TitoOrt's answer. – Bruno Jan 15 '18 at 12:43

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.
• So I guess I shouldn't be thinking in terms of "time", but "transitions" or "steps", right? And even in HSMMs, the "duration time" is actually the number of transitions or steps. Does this mean that in a continuous time model, there's actually the notion of "time" to go from state i to state j? – Bruno Jan 15 '18 at 12:46