I am working on analyzing some data, and I am interested in the expected number of consecutive repetitions of a particular value in a sequence (I am trying to determine whether the number of consecutive repetitions in the data exceeds the expected amount).
In particular, in a sequence $(a_n)$ of fixed length $N$, with each $a_n$ belonging to some alphabet of values $\{x_1, \ldots, x_m\}$, each occurring independently with corresponding probabilities of $\{p_1, \ldots, p_m\}$, what is the expected number of repetitions of consecutive values/letters of length $k$?
For instance, the sequence AABBCDEFG has two consecutive repetitions of length 2, and $AAAA$ has two consecutive repetitions of length 2, one consecutive repetition of length 3, and one consecutive repetition of length 4. How to calculate this expected value is not very clear to me, and any help would be greatly appreciated.