Let $n$ and $k$ be natural numbers. I will consider [North-East lattice paths](https://en.wikipedia.org/wiki/Lattice_path#North-East_lattice_paths) (NE-paths) from $(0,0)$ to $(n,n)$ and encode these as strings of length $2n$ with letters $\mathsf{N}$ and $\mathsf{E}$. A *peak* of such a lattice path $\mathsf{P} = \mathsf{x\_1x\_2\dots x\_{2n}}$ is an index $i$ such that $\mathsf{x\_i x\_{i+1}}=\mathsf{NE}$. The *major index* of $P$ is the sum of the peaks of $\mathsf{P}$. As an example, the NE-path $\mathsf{P} = \mathsf{ENNENEEENENN}$ has peaks at indices $3,5$ and $9$ and hence $\text{maj}(\mathsf{P})=3+5+9=17$. I have two questions regarding these paths.


1. From [this](http://oeis.org/search?q=1%2C1%2C1%2C1%2C4%2C1%2C1%2C9%2C9%2C1&sort=&language=&go=Search) OEIS-entry, I understand that the number NE-paths from $(0,0)$ to $(n,n)$ with exactly $k$ peaks is equal to $\binom{n}{k}^2$. Does someone know a proof or a reference for this?
2. I suspect that the $\text{maj}$-generating polynomial over this set of paths has the following nice closed form expression:
$$\sum\_\mathsf{P}q^{\text{maj}(\mathsf{P})}=q^{k^2}\begin{bmatrix}
n\\
k 
\end{bmatrix}\_q^2.$$
Here, the sum is taken over all NE-lattice paths from $(0,0)$ to $(n,n)$ with exactly $k$ peaks. I feel like this is a nice enough formula that it should be mentioned somewhere in the litterature but I have not managed to find it anywhere. Does someone know a reference for this?



NE-Lattice paths from $(0,0)$ to $(n,n)$ with $k$ peaks
The formula in 2 is a very special case of a result of Richard Stanley's, though it certainly could be older. (I wouldn't be surprised if it can be found in MacMahon's work.) See, e.g., my paper *[A historical survey of P-partitions](https://arxiv.org/abs/1506.03508)*, section 7.2, for references. Just in case the connection isn't clear, your problem is equivalent to counting shuffles of the words $00\cdots 0$ and $11\cdots1$, both of length $n$, with $k$ descents, by major index. Stanley's formula counts shuffles of two arbitrary (but disjoint) permutations with a given number of descents by major index.


