Skip to content

komm.SingleParityCheckCode

Single parity-check code. For a given length $n \geq 1$, it is the linear block code whose codewords are obtained by extending $n - 1$ information bits with a single parity-check bit. The repetition code has the following parameters:

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

Attributes:

  • n (int)

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

Examples:

>>> code = komm.SingleParityCheckCode(5)
>>> (code.length, code.dimension, code.redundancy)
(5, 4, 1)
>>> code.generator_matrix
array([[1, 0, 0, 0, 1],
       [0, 1, 0, 0, 1],
       [0, 0, 1, 0, 1],
       [0, 0, 0, 1, 1]])
>>> code.check_matrix
array([[1, 1, 1, 1, 1]])
>>> code.minimum_distance()
2
>>> code = komm.SingleParityCheckCode(16)
>>> code.codeword_weight_distribution()
array([    1,     0,   120,     0,  1820,     0,  8008,     0, 12870,
           0,  8008,     0,  1820,     0,   120,     0,     1])
>>> code.coset_leader_weight_distribution()
array([1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])