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 R\) for any finite ring \(R\), the Hamming weight \(w_H(x)\) is defined by:
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 Distribution of a Quadratic Residue Code (ex-601dad)
Run in calculator (opens in a new tab)
In this example, the weight distribution of a quadratic residue code over \({\mathbb{Z}}_4\) 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\in{\mathbb{Z}}_4\), the Lee weight \(w_L(x)\) is defined by:
The Lee weight \(w_L(v)\) of a vector \(v\in{{\mathbb{Z}}_4^n}\) is defined to be the sum (in \({\mathbb{Z}}\)) of the Lee weights of its components. See [Wan97, p. 16].
- 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\).
- 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: Infinity()
Given a linear code \(C\), return the set of all words of \(C\) having Lee weight \(w\). If
NumWordsis 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: Infinity()
Given a linear code \(C\), return the set of all words of \(C\) having Lee weight between \(l\) and \(u\), inclusive. If
NumWordsis set to a non-negative integer \(c\), then the algorithm will terminate after a total of \(c\) words have been found.
- Example: Lee Weight Distribution (ex-587036)
We calculate the Lee weight distribution of a Reed Muller code over \({\mathbb{Z}}_4\) 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\in{\mathbb{Z}}_4\), the Euclidean weight \(w_E(x)\) is defined by:
The Euclidean weight \(w_E(v)\) of a vector \(v\in{{\mathbb{Z}}_4^n}\) is defined to be the sum (in \({\mathbb{Z}}\)) of the Euclidean weights of its components. See [Wan97, p. 16].
- EuclideanWeight(a): RngIntRes -> RngIntElt
The Euclidean weight of the element \(a\in{\mathbb{Z}}4\).
- EuclideanWeight(v): ModTupRngElt -> RngIntElt
The Euclidean weight of the \({\mathbb{Z}}_4\)-codeword \(v\).
- EuclideanDistance(u, v): ModTupRngElt, ModTupRngElt -> RngIntElt
The Euclidean distance between the \({\mathbb{Z}}_4\)-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 \({\mathbb{Z}}_4\)-code C.
- EuclideanWeightDistribution(C): Code -> SeqEnum
The Euclidean weight distribution of the \({\mathbb{Z}}_4\)-code C.
- DualEuclideanWeightDistribution(C): Code -> SeqEnum
The Euclidean weight distribution of the dual of the \({\mathbb{Z}}_4\)-code C.
- Example: Euclidean Weight Distribution (ex-9f8213)
Run in calculator (opens in a new tab)
The Euclidean weight distribution is calculated for a quadratic residue code over \({\mathbb{Z}}_4\)
> 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> ]