Let $n$ and $k$ be natural numbers. I will consider 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.

- From this 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?
- 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?

(a)in UMN Fall 2018 Math 5705 midterm #3, since you can encode NE-paths from $\left(0,0\right)$ to $\left(n,n\right)$ as $2n$-tuples with entries in $\left\{0,1\right\}$ having exactly $n$ $1$-positions (just replacing $N$ and $E$ by $1$ and $0$, respectively). $\endgroup$ – darij grinberg Nov 15 '19 at 23:11