Karen tosses a coin $n$ times, with probability of $\frac{1}{3}$ for $H$ and probability of $\frac{2}{3}$ for $T$. For $1\le k \le n$, let $N_k$ - the number of consecutive sequence of $H$'s of length k. For example if the sequence is $HHHTH$, then $N_1=4$, $N_2=2$, $N_3=1$, $N_4=0$ and $N_5=0$.
Prove:
$Var(N_k) = (n-k+1)3^{-k}(1-3^{-k})+2\sum\limits_{m=1}^{k-1}(n-2k+m+1)3^{-2k}(3^m-1)$
My try:
We'll define indicator $n_i$ $(i=1,\dots ,n)$ - a sequence of length $k$ starts in the index $i$.
Thus, $Var(N_k)= Var(\sum\limits_{i=1}^{n-k+1}n_i)=\sum\limits_{i=1}^{n-k+1}Var(n_i)+2\sum\limits_{i<j}Cov(n_i,n_j)$
$\sum\limits_{i=1}^{n-k+1}Var(n_i)= (n-k+1)3^{-k}(1-3^{-k})$ which is the first element of the formula.
Now, we'll denote with $l$ the distance $|i-j|$. if $l\ge k$ then $n_i$ and $n_j$ are independent so $Cov(n_i,n_j)=0$.
Else, for $l<k$: $\space Cov(n_i,n_j)= \mathbb{P}(n_i=1,n_j=1)-\mathbb{P}(n_i=1)\cdot\mathbb{P}(n_j=1)=3^{-(k+l)}-3^{-2k}$.
The number of such pairs for $l<k$ is: $n-k-l$.
$\implies 2\sum\limits_{i<j}Cov(n_i,n_j)=2\sum\limits_{l=1}^{k-1}(n-k-l)\cdot(3^{-(k+l)}-3^{-2k})\ne2\sum\limits_{m=1}^{k-1}(n-2k+m+1)3^{-2k}(3^m-1)$
Could anyone tell me what am I missing?
The number of such pairs for $l<k$ is: $n-(k+l)+1$.
$\implies 2\sum\limits_{i<j}Cov(n_i,n_j)=2\sum\limits_{l=1}^{k-1}(n-k-l+1)\cdot(3^{-(k+l)}-3^{-2k})=\\ 2\sum\limits_{m=1}^{k-1}(n-2k+m+1)3^{-2k}(3^m-1)$
where $m=k-l$.