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 single parity-check code has the following parameters:

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

For more details, see LC04, Sec. 3.7 and EC Zoo: Single parity-check code.

Notes

Parameters:

  • 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()
[1, 0, 120, 0, 1820, 0, 8008, 0, 12870, 0, 8008, 0, 1820, 0, 120, 0, 1]
>>> code.coset_leader_weight_distribution()
[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]