the cardinality of a code in $\mathcal{C}_b$. From a counting argument, one can see that $M |\mathcal{C}_b| \geq L |(\mathcal{R}^n)^{*}|$. The following lemma shows how to bound averages of functions in $(\mathcal{R}^n)^*$.

Let $g : \mathcal{R}^n \to \mathbb{R}^+$ be a function. For a code $\mathcal{C}$, we define $g^*(\mathcal{C}) = \sum_{\mathbf{c} \in \mathcal{C} \cap (\mathcal{R}^n)^*} g(c)$. If $\mathcal{C}_b$ is the set of all codes of rank $k$ then $$E\left[g^*(\mathcal{C})\right] \leq \frac{\left| \mathcal{R} \right|^k}{\left|(\mathcal{R}^n)^*\right|} g^*(\mathcal{R}^n),$$ where the expectation is with respect to the uniform distribution on $\mathcal{C}_b$. \[lem:balancedRings\]

For any balanced set of codes with cardinality $M$, we have $$\begin{split}
    &E[g^*(\mathcal{C})]  = E\left[\sum_{\mathbf{c} \in \mathcal{C} \cap (\mathcal{R}^n)^*} g(c)\right] = E\left[\sum_{\mathbf{x} \in (\mathcal{R}^n)^*} g({\mathbf{x}}) \mathbbm{1}_{\mathcal{C}}({\mathbf{x}})\right]
    \\ & \sum_{\mathbf{x} \in (\mathcal{R}^n)^*} E\left[ g(x) \mathbbm{1}_{\mathcal{C}}(x)\right] = \sum_{\mathbf{x} \in (\mathcal{R}^n)^*} g(x) \frac{L}{|\mathcal{C}_b|} \leq \frac{M}{|(\mathcal{R}^n)^*|} g^*(\mathcal{R}^n).
    \end{split}$$ We now need to prove that the set of all codes of rank $k$ is balanced. Let ${\mathbf{y}}$ be any element in ${{\mathcal{R}^n}^*}$. There exists an invertible linear map $T({\mathbf{y}}) = (1,0,\ldots,0) = \mathbf{e}_1$. Since $T$ is rank-preserving, ${\mathbf{y}}\in \mathcal{C}$ if and only if $\mathbf{e}_1 \in T\mathcal{(\mathcal{C})}$, where $\mathcal{C}$ and $T(\mathcal{C})$ have same rank. This induces a bijection between the codes that contain ${\mathbf{y}}$ and the codes that contain $e_1$, 