Skip to content

komm.RepetitionCode

Repetition code. For a given length $n \geq 1$, it is the linear block code whose only two codewords are $00 \cdots 0$ and $11 \cdots 1$. The repetition code has the following parameters:

  • Length: $n$
  • Dimension: $k = 1$
  • Redundancy: $m = n - 1$
  • Minimum distance: $d = n$
Notes

Attributes:

  • n (int)

    The length $n$ of the code. Must be a positive integer.

Examples:

>>> code = komm.RepetitionCode(5)
>>> (code.length, code.dimension, code.redundancy)
(5, 1, 4)
>>> code.generator_matrix
array([[1, 1, 1, 1, 1]])
>>> code.check_matrix
array([[1, 1, 0, 0, 0],
       [1, 0, 1, 0, 0],
       [1, 0, 0, 1, 0],
       [1, 0, 0, 0, 1]])
>>> code.minimum_distance()
5
>>> code = komm.RepetitionCode(16)
>>> code.codeword_weight_distribution()
array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
>>> code.coset_leader_weight_distribution()
array([    1,    16,   120,   560,  1820,  4368,  8008, 11440,  6435,
           0,     0,     0,     0,     0,     0,     0,     0])

minimum_distance cached

Returns the minimum distance $d$ of the code. This is equal to the minimum Hamming weight of the non-zero codewords.

Examples:

>>> code = komm.BlockCode(generator_matrix=[[1, 0, 0, 1, 1], [0, 1, 1, 1, 0]])
>>> code.minimum_distance()
3

coset_leader_weight_distribution cached

Returns the coset leader weight distribution of the code. This is an array of shape $(n + 1)$ in which element in position $w$ is equal to the number of coset leaders of weight $w$, for $w \in [0 : n]$.

Examples:

>>> code = komm.BlockCode(generator_matrix=[[1, 0, 0, 1, 1], [0, 1, 1, 1, 0]])
>>> code.coset_leader_weight_distribution()
array([1, 5, 2, 0, 0, 0])