Expected duration in a state

I am going through Rabiner 1989 and he writes that the discrete probability density function of duration $$d$$ in state $$i$$ (that is, staying in a state for duration $$d$$, conditioned on starting in that state) is $$p_i(d) = {a_{ii}}^{d-1}(1-a_{ii})$$

($$a_{ii}$$ is the state transition probability from state $$i$$ to state $$i$$ - that is, staying in the same state).

He then continues to say that the expected durations in a state, conditioned on starting in that state, is $$\overline d_i = \sum_{i=1}^\infty d p_i(d) = \frac{1}{1-a_{ii}}$$

Where does the coefficient $$d$$ (in $$\sum_{i=1}^\infty d p_i(d)$$) come from?

• Looks like a typo and sum should be over $d$, not $i$, in the second equation. But I am not familiar with that tutorial. – Neil Slater Mar 2 '20 at 7:44
• @NeilSlater Still, even if it is summing over $d$, what does the coefficient $d$ represent? Is it adding $p_i(d)$ each time it stays in state $i$? – jstycrpsc Mar 2 '20 at 20:08
• You already state that: duration 𝑑 – Neil Slater Mar 2 '20 at 22:04
• @NeilSlater Sorry I was not clear. Why do we multiply $p_i(d)$ by $d$? – jstycrpsc Mar 3 '20 at 4:54
• . . . .because it is taking a mean/expected value by multiplying each possible value by its probability of occurring – Neil Slater Mar 3 '20 at 6:47