\mathcal{C} \colon \mathrm{rk}(M)=i\}|$. The *rank distribution* of $\mathcal{C}$ is the vector $(A_i)_{i \in \mathbb{N}}$. MacWilliams identities for RM codes are stated in Theorem \[th:MacWilliams\] and were first obtained by Delsarte in [@Delsarte] using the machinery of association schemes; see also [@Ravagnani] for a different approach. Recall that the $q$-binomial coefficient of two integers $s$ and $t$ is $${s \brack t}_q=\left\{ \begin{array}{lll} 0 & \text{if}\,\, s<0,\,\,\text{or}\,\,t<0,\,\, \text{or}\,\, t>s,\\ 
1 & \text{if}\,\, t=0\,\, \text{and}\,\, s\geq 0,\\
\displaystyle\prod_{i=1}^t \frac{q^{s-i+1}-1}{q^i-1} & \text{otherwise}. \end{array} \right.$$

([@Delsarte Theorem 3.3],[@Ravagnani Theorem 31])\[th:MacWilliams\] Let $\mathcal{C}$ be an RM code in $\mathbb{F}_q^{m\times n}$. Let $(A_i)_{i\in \mathbb{N}}$ and $(B_j)_{j\in \mathbb{N}}$ be the rank distribution of $\mathcal{C}$ and $\mathcal{C}^\perp$, respectively. For any integer $\nu \in \{ 0,\ldots,m \}$ we have $$\sum_{i=0}^{m-\nu} A_i  {m-i \brack \nu}_q = \frac{|\mathcal{C}|}{q^{n\nu}} \sum_{j=0}^\nu B_j {m-j \brack \nu -j}_q.$$

As a consequence, Delsarte in [@Delsarte] and later Gabidulin in [@Gabidulin] determined precisely the weight distribution of MRD codes.

\[th:weightdistribution\] Let $\mathcal{C}$ be an MRD code in $\mathbb{F}_q^{m\times n}$ with minimum distance $d$. Let $m'=\min\{m,n\}$ and $n'=\max\{m,n\}$. Then $$A_{d+\ell}={m'\brack d+\ell}_q \sum_{t=0}^\ell (-1)^{t-\ell}{\ell+d \brack \ell-t}_q q^{\binom{\ell-t}{2}}(q^{n'(t+1)}-1)$$ for any $\ell \in \{0,1,\ldots,n'-d\}$.

In particular, Lemma \[lemma:weight\] holds.

([@LTZ2 Lemma 2.1],\[lemma:weight\][@Ravagnani Lemma 52])\[lemma:complete weight\] Let $\mathcal{C}$ be an MRD code in 