Consider a binary sequence $\mathbf{a}\_n$ consisting of 1s and 0s.
Let us denote by $f(\mathbf{a}\_n)$ the number of $(1, 1)$ and $(0, 0)$ in $\mathbf{a}\_n$; I am not sure whether there is a formal name for $f(\mathbf{a}\_n)$.
Is there a closed expression for the number of $\mathbf{a}\_n$'s such that $f(\mathbf{a}\_n) = i$ for
$i = 0, 1, \dotsc, n - 1$?



Number of binary sequences in which the number of $(1, 1)$ and $(0, 0)$ is prespecified
Consider the related binary sequence $\widetilde{a\_n}$ of length $n-1$ defined by $\widetilde{a\_n}(k) := (a\_n(k+1)-a\_n(k))\text{ mod }2$ for $k = 0\ldots n-2$; the number of 0's in $\widetilde{a\_n}$ is exactly the number of $(0,0)'s$ and $(1,1)'s$ in $a\_n$. Now, the number of binary sequences of length $(n-1)$ which have exactly $i$ 0's is just $\binom{n-1}{i}$, and each $\widetilde{a\_n}$ arises from two distinct $a\_n$'s (one with $a\_n(0) = 0$ and one with $a\_n(0) = 1$), so it follows that $\left|\{a\_n|f(a\_n) = i\}\right| = 2\binom{n-1}{i}$.


