Weight Distributions#

In the case of a linear code, weight and distance distributions are equivalent (in particular minimum weight and minimum distance are equivalent).

Hamming Weight#

For an element \(x\in{\mathbb{R}}\) for any finite ring \(R\), the Hamming weight \(w_H(x)\) is defined by:

\[w_H(x) = 0 \iff x = 0, \qquad w_H(x) = 1 \iff x \ne 0\]

The Hamming weight \(w_H(v)\) of a vector \(v\in {R^n}\) is defined to be the sum (in \({\mathbb{Z}}\)) of the Hamming weights of its components.

The Hamming weight is often referred to as simply the weight.

MinimumWeight(C): Code -> RngIntElt#
MinimumDistance(C): Code -> RngIntElt#

Determine the minimum (Hamming) weight of the words belonging to the code \(C\), which is also the minimum distance between any two codewords.

WeightDistribution(C): Code -> [ <RngIntElt, RngIntElt> ]#

Determine the (Hamming) weight distribution for the code \(C\). The distribution is returned in the form of a sequence of tuples, where the \(i\)-th tuple contains the \(i\)-th weight, \(w_i\) say, and the number of codewords having weight \(w_i\).

DualWeightDistribution(C): Code -> [ <RngIntElt, RngIntElt> ]#

Determine the (Hamming) weight distribution of the dual code of \(C\). The distribution is returned in the form of a sequence of tuples, where the \(i\)-th tuple contains the \(i\)-th weight, \(w_i\) say, and the number of codewords having weight \(w_i\).

Example: Weight Dist Cyc (ex-bb2d09)#

We calculate the weight distribution of a cyclic code over the Galois ring of size \(81\).

> R<w> := GR(9,2);
> P<x> := PolynomialRing(R);
> L := CyclotomicFactors(R, 4);
> g := L[3] * L[4];
> g;
x^2 + (8*w + 7)*x + w + 1
> C := CyclicCode(4, g);
> C;
(4, 6561, 3) Cyclic Code over GaloisRing(3, 2, 2)
Generator matrix:
[      1       0   w + 1 8*w + 7]
[      0       1       w 8*w + 8]
> WeightDistribution(C);
[ <0, 1>, <3, 320>, <4, 6240> ]

Run in calculator