I just read (here (Theorem 1.2): http://www.jams.or.jp/scm/contents/e-2006-6/2006-52.pdf) the following statement:
If C is a non-degenerate [n,k] linear code, then it holds that $$ n = \frac{1}{q^k - q^{k-1}} \sum_{x \in C}{w(x)}$$
But why does this hold true?
Thanks for any help!
Well, its a double counting argument.
Take the $q^k\times n$ matrix $M$ whose rows are the codewords of $C$.
Calculate the number of nonzero entries in $M$.
1) Row-wise: For the row labeled by codeword $c$, the number of nonzero entries is $w(c)$, the Hamming weight of $c$. That's easy.
2) Column-wise: As I have explained in another question, today, in each column each value from ${\Bbb F}_q$ is taken on an equal number of times. Here the prerequisite comes in that the code $C$ is non-degenerate, i.e., has no all-zero column. Then the number of nonzero values per column is $q^{k-1}(q-1)$, and we have $n$ columns.
This gives totally, $$n (q^k-q^{k-1}) = \sum_{c\in C} w(c).$$