Consider a coin-tossing event in which at each toss $i$ the probability of having H is $p_i$. What is the probability of having exactly $k$ consecutive H in $n$ toss? Let's say k=2 and n=6; then here we want to know the probability of all the outcomes listed below.
HHTTTT
TTHHTT
TTTTHH
THHTTT
THTHHT
HTTHHT
HHTTHH
$\vdots$