Weight Distributions

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

Contents

Hamming Weight

For an element x∈R for any finite ring R, the Hamming weight wH(x) is defined by: wH(x) = 0 iff x = 0, qquad wH(x) = 1 iff x ≠0 The Hamming weight wH(v) of a vector v∈(Rn) is defined to be the sum (in 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, wi say, and the number of codewords having weight wi.
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, wi say, and the number of codewords having weight wi.

Example CodeZ4_weight-dist-k8 (H165E16)

In this example, the weight distribution of a quadratic residue code over Z4 and its dual are computed.
> C := QRCodeZ4(17);
> C;
((17, 4^9 2^0)) Cyclic Linear Code over IntegerRing(4)
Generator matrix:
[1 0 0 0 0 0 0 0 0 1 1 3 0 3 0 3 1]
[0 1 0 0 0 0 0 0 0 3 0 2 3 1 3 1 2]
[0 0 1 0 0 0 0 0 0 2 1 2 2 1 1 1 3]
[0 0 0 1 0 0 0 0 0 1 3 0 2 1 1 0 2]
[0 0 0 0 1 0 0 0 0 2 3 1 0 0 1 3 2]
[0 0 0 0 0 1 0 0 0 2 0 1 1 2 0 3 1]
[0 0 0 0 0 0 1 0 0 3 1 1 1 2 2 1 2]
[0 0 0 0 0 0 0 1 0 2 1 3 1 3 2 0 3]
[0 0 0 0 0 0 0 0 1 1 3 0 3 0 3 1 1]
> WeightDistribution(C);
[ <0, 1>, <5, 34>, <6, 68>, <7, 748>, <8, 2567>, <9, 6817>, <10, 17612>,
  <11, 34340>, <12, 50014>, <13, 56168>, <14, 50728>, <15, 30872>,
  <16, 9826>, <17, 2349> ]
> DualWeightDistribution(C);
[ <0, 1>, <6, 68>, <8, 935>, <9, 1632>, <10, 4148>, <11, 8568>, <12, 12886>,
  <13, 14280>, <14, 11968>, <15, 7752>, <16, 2890>, <17, 408> ]

Lee Weight

For an element x∈Z4, the Lee weight wL(x) is defined by: wL(0) = 0, wL(1) = wL(3) = 1, wL(2) = 2. The Lee weight wL(v) of a vector v∈(Z4n) is defined to be the sum (in Z) of the Lee weights of its components. See [Wan97, p. 16].

LeeWeight(a) : RngIntRes -> RngIntElt
The Lee weight of the element a∈Z4.
LeeWeight(v) : ModTupRngElt -> RngIntElt
The Lee weight of the codeword v.
LeeDistance(u, v) : ModTupRngElt, ModTupRngElt -> RngIntElt
The Lee distance between the codewords u and v, where u and v belong to the same code C. This is defined to be the Lee weight of (u - v).
MinimumLeeWeight(C) : Code -> RngIntElt
MinimumLeeDistance(C) : Code -> RngIntElt
The minimum Lee weight of the code C.
LeeWeightDistribution(C) : Code -> SeqEnum
The Lee weight distribution of the code C.
DualLeeWeightDistribution(C) : Code -> SeqEnum
The Lee weight distribution of the dual of the code C (see LeeWeightDistribution)
WordsOfLeeWeight(C, w) : Code, RngIntElt -> SetEnum
    NumWords: RngIntElt                 Default: ∞
Given a linear code C, return the set of all words of C having Lee weight w. If NumWords is set to a non-negative integer c, then the algorithm will terminate after a total of c words have been found.
WordsOfBoundedLeeWeight(C, l, u) : Code, RngIntElt, RngIntElt -> SetEnum
    NumWords: RngIntElt                 Default: ∞
Given a linear code C, return the set of all words of C having Lee weight between l and u, inclusive. If NumWords is set to a non-negative integer c, then the algorithm will terminate after a total of c words have been found.

Example CodeZ4_lee-dist (H165E17)

We calculate the Lee weight distribution of a Reed Muller code over Z4 and enumerate all words of Lee weight 8.
> C := ReedMullerCodeZ4(1, 3);
> C;
(8, 256, 4) Linear Code over IntegerRing(4)
Generator matrix:
[1 0 0 0 3 1 2 1]
[0 1 0 0 2 1 1 3]
[0 0 1 0 1 1 3 2]
[0 0 0 1 3 2 3 3]
> LeeWeightDistribution(C);
[ <0, 1>, <6, 112>, <8, 30>, <10, 112>, <16, 1> ]
> W := WordsOfLeeWeight(C, 8);
> #W;
30

Euclidean Weight

For an element x∈Z4, the Euclidean weight wE(x) is defined by: wE(0) = 0, wE(1) = wE(3) = 1, wE(2) = 4. The Euclidean weight wE(v) of a vector v∈(Z4n) is defined to be the sum (in Z) of the Euclidean weights of its components. See [Wan97, p. 16].

EuclideanWeight(a) : RngIntRes -> RngIntElt
The Euclidean weight of the element a∈Z4.
EuclideanWeight(v) : ModTupRngElt -> RngIntElt
The Euclidean weight of the Z4-codeword v.
EuclideanDistance(u, v) : ModTupRngElt, ModTupRngElt -> RngIntElt
The Euclidean distance between the Z4-codewords u and v, where u and v belong to the same code C. This is defined to be the Euclidean weight of (u - v).
MinimumEuclideanWeight(C) : Code -> RngIntElt
MinimumEuclideanDistance(C) : Code -> RngIntElt
The minimum Euclidean weight of the Z4-code C.
EuclideanWeightDistribution(C) : Code -> SeqEnum
The Euclidean weight distribution of the Z4-code C.
DualEuclideanWeightDistribution(C) : Code -> SeqEnum
The Euclidean weight distribution of the dual of the Z4-code C.

Example CodeZ4_euclidean-dist (H165E18)

The Euclidean weight distribution is calculated for a quadratic residue code over Z4
> C := QRCodeZ4(17);
> C;
(17, 262144) Cyclic Code over IntegerRing(4)
Generator matrix:
[1 0 0 0 0 0 0 0 0 1 1 3 0 3 0 3 1]
[0 1 0 0 0 0 0 0 0 3 0 2 3 1 3 1 2]
[0 0 1 0 0 0 0 0 0 2 1 2 2 1 1 1 3]
[0 0 0 1 0 0 0 0 0 1 3 0 2 1 1 0 2]
[0 0 0 0 1 0 0 0 0 2 3 1 0 0 1 3 2]
[0 0 0 0 0 1 0 0 0 2 0 1 1 2 0 3 1]
[0 0 0 0 0 0 1 0 0 3 1 1 1 2 2 1 2]
[0 0 0 0 0 0 0 1 0 2 1 3 1 3 2 0 3]
[0 0 0 0 0 0 0 0 1 1 3 0 3 0 3 1 1]
> EuclideanWeightDistribution(C);
[ <0, 1>, <7, 136>, <8, 170>, <9, 170>, <10, 408>, <11, 544>, <12, 986>,
<13, 1768>, <14, 3128>, <15, 5032>, <16, 6120>, <17, 6360>, <18, 8432>,
<19, 12512>, <20, 12682>, <21, 11152>, <22, 14416>, <23, 17680>, <24, 16048>,
<25, 15164>, <26, 17952>, <27, 16864>, <28, 13328>, <29, 14144>, <30, 14144>,
<31, 10064>, <32, 7837>, <33, 8024>, <34, 6800>, <35, 4896>, <36, 3485>,
<37, 2992>, <38, 2992>, <39, 1768>, <40, 510>, <41, 1258>, <42, 1224>,
<44, 238>, <45, 408>, <46, 136>, <47, 136>, <48, 34>, <68, 1> ]
V2.28, 13 July 2023