The bernoulli distribution is defined by a single parameter ; it can be considered as the probability of success. The most common example used is a coin flip. Assuming the coin is fair, .
This type of distribution is also commonly used in Automatic Speech Recognition (ASR). A common approach to ASR models speech as a set of Hidden Markov Models (HMM). Within each HMM, there are multiple states; transitions between these states are modeled as bernoulli distributions. The probability of staying in the same state in the next time frame is and the probability of transitioning to the next state is .
One question I had recently is what is the expected length of a sample generated by the HMM. In the types of HMMs commonly used in ASR, answering this question requires knowing what is the expected number of times a state transitions to itself. Lets work our way up to answering this question.
The probability of number of self transitions is . The term is needed because if there were only self transitions, then it must have transitioned to another state in the next time step. To find the expected number of transitions we take the number times the probability of self transitions for every possible . Mathematically, we can write this as
To simplify the analysis, we can factor out the term.
If we ignore the factor, it looks very similar to a geometric series. It is known that the infinite sum for a geometric series is
The one insight required is that if we take the derivative of the geometric series, we end up with the exact series we are trying to solve—except for the term. Taking the derivative of both sides gives
Substituting that back into our original series gives us
So the expected number of self transitions for any state is , which is also the expected number of consecutive successes for a bernoulli distribution.
A couple of examples. If I hand you a fair coin and ask how many times do you expect to get heads before the first tails, the answer is . If I hand you a fair six-sided die and ask how many times do you expect to roll before you see a 1, the answer is .