"Evenness" of weak k-compositions of n For every weak $k$-composition of $n$, $x_0 + x_1 + ... + x_{k-1} = n$ with $x_i \geq 0$, we define the "evenness" of that composition to be $\left\lfloor{\frac{x_0}{2}}\right\rfloor + \left\lfloor{\frac{x_1}{2}}\right\rfloor + ... + \left\lfloor{\frac{x_{k-1}}{2}}\right\rfloor$, i.e. how many times 2 fits into its individual terms. I'm interested in how many weak $k$-compositions of $n$ there are with evenness $p$.
It is fairly easy to define a function $E_p(k,n)$ to compute this. To construct a $k$-composition of $n$ with evenness $p$, we can either set $x_0 = 0$ and follow up with a $k-1$-composition of $n$ with evenness $p$, or set $x_0 = 1$ and follow up with a $k-1$-composition of $n-1$ with evenness $p$, or set $x_0 = 2$ and follow up with a $k-1$-composition of $n-2$ with evenness $p-1$, etc.:
$$\begin{align*}
E_p(k,n) \;&=\; \sum_{i\,=\,0}^{p} {E_{p-i}(k-1,\, n-2i) + E_{p-i}(k-1,\, n-2i-1)} \\
           &=\; E_p(k-1,\, n) + E_p(k-1,\, n-1) \\ &\;\;\;\;+ \sum_{i\,=\,1}^{p} {E_{p-i}(k-1,\, n-2i) + E_{p-i}(k-1,\, n-2i-1)} \\
           &=\; E_p(k-1,\, n) + E_p(k-1,\, n-1) \\ &\;\;\;\;\;+ \sum_{i\,=\,0}^{p} {E_{p-1-i}(k-1,\, n-2-2i) + E_{p-1-i}(k-1,\, n-2-2i-1)} \\
           &=\; E_p(k-1,\, n) + E_p(k-1,\, n-1) + E_{p-1}(k,\, n-2)
\end{align*}$$
with the initial conditions
$$\begin{align*}
E_{-1}(k,n) &= 0, \\
E_0(k,0) &= 1, \\
E_p(k,0) &= 0, \\
E_p(0,n) &= 0.
\end{align*}$$
This gives $E_0(k,n) = {k\choose n}$, since the recursive formula for $E_0(k,n)$ reduces to that of the binomial coefficient. (This result has been described before in Number of compositions of $n$ into $k$ parts with each part at most $1$.) It also seems like $E_1(k,n) = k{k\choose n-2}$ for $n \geq 3$, and $E_p(k, 2p) = {k+p-1\choose p}$ and $E_p(k, 2p + 1) = k{k+p-1\choose p}$ for $p \geq 2$. The latter must surely be connected to multisets somehow (the number of ways you can choose $k$ elements from $p$ total with repetitions), but I don't have proofs for any of those results and arrived at them only after looking up the series $E_p(0,n), E_p(1,n), E_p(2,n), ...$ for different values of $p$ and $n$ in OEIS and noticing the similarities.
Is there a closed-form expression for $E_p(k,n)$? Looking up some of the series for larger $n$ on OEIS, the expressions get rather ugly, but they are indeed listed and described by another author. Here, $E_p(k,n)$ seems to have been identified as "the number of $n$-subsequences of $[1,k]$ with exactly $p$ contiguous pairs" (A027777, A027765, A027789, A027766). This sounds similar enough to my question to obviously be equivalent, but I don't know enough about the theory here (what is a $n$-subsequence in this context?) to make much further progress with that information, and I cannot find any relevant resources linked either.
 A: This can be done with standard generating function techniques. The generating function for weak $k$-compositions is $(1 + z + z^2 + \dots)^k = \frac{1}{(1 - z)^k}$; here each term $z^i$ in each factor corresponds to one of the terms in the composition taking value $i$. Keeping track of evenness can be done by introducing a second variable $t$ and replacing each $z^i$ with $t^{\lfloor \frac{i}{2} \rfloor} z^i$, which gives
$$\sum_{n, p \ge 0} E_p(k, n) t^p z^n = (1 + z + tz^2 + tz^3 + \dots)^k = \left( \frac{1 + z}{1 - tz^2} \right)^k.$$
We have $(1 + z)^k = \sum_{i=0}^k {k \choose i} z^i$ and
$$\frac{1}{(1 - tz^2)^k} = \sum_{i \ge 0} {i+k-1 \choose k-1} t^i z^{2i}$$
and isolating the coefficient of $t^p z^n$ in their product gives
$$\boxed{ E_p(k, n) = {p + k - 1 \choose k - 1} {k \choose n - 2p} }.$$
This specializes to all of the special cases you listed; probably there is a nice combinatorial proof to be extracted from this argument also.
Edit: Okay, the combinatorial argument is quite straightforward. If the total evenness is $p$ then we can first "distribute the evenness" among the $x_i$; that is, the number of ways to write $\sum \lfloor \frac{x_i}{2} \rfloor = p$ is the number of weak $k$-compositions of $p$ which is counted by the first factor. Having fixed the evennesses, what remains is a choice of whether each $x_i$ is even or odd, subject to the constraint that $\sum \left( x_i - \lfloor \frac{x_i}{2} \rfloor \right) = n - 2p$, which is counted by the second factor. (This is actually exactly what the generating function argument is saying although it takes a little familiarity with these techniques to make the translation.)
