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$

For more details, see LC04, Sec. 3.7 and EC Zoo: Repetition code.

Notes

Parameters:

  • 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()
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
>>> code.coset_leader_weight_distribution()
[1, 16, 120, 560, 1820, 4368, 8008, 11440, 6435, 0, 0, 0, 0, 0, 0, 0, 0]