Repetition Coding¶
Repetition codes are among the most basic channel coding schemes. The achieve redundancy by repeating all bits within a block during encoding.
- class RepetitionEncoder(bit_block_size=32, repetitions=3)[source]¶
Bases:
Encoder
,Serializable
A channel coding scheme based on block-wise repetition of bits.
During encoding, the repetition encoder repeats a block of \(K_n\)
bit_block_size()
bits \(\tilde{M}\)repetitions()
times, leading to acode_block_size()
of\[L_n = \tilde{M} \cdot K_n\]bits and a coding rate of
\[R_n = \frac{K_n}{L_n} = \frac{1}{\tilde{M}} \mathrm{.}\]Let
\[\mathbf{x} = \left[ x_1, x_2, \dots, x_{K_n} \right]^\intercal \in \left\lbrace 0, 1 \right\rbrace^{K_n}\]be the vector of input bits and
\[\mathbf{y} = \left[ y_1, y_2, \dots, y_{K_n} \right]^\intercal \in \left\lbrace 0, 1 \right\rbrace^{L_n}\]be the vector of repeated output bits. The implemented block repetition scheme can be described by
\[y_k = x_{k \mod{K_n}} \mathrm{,}\]assigning input bits to output bits by index.
- Parameters:
- Raises:
ValueError – If bit_block_size times repetitions is smaller than code_block_size.
- decode(encoded_bits)[source]¶
Decodes a single block of bits.
Bit decoding routine during data reception, decoding a block of \(L_n\) code bits into a block of \(K_n\) data bits.
- Parameters:
encoded_bits (np.ndarray) – A numpy vector of \(L_n\) code bits, representing a single code block to be decoded.
- Returns:
A numpy vector of \(K_n\) bits, representing a single data block.
- Return type:
np.ndarray
- Raises:
ValueError – If the length of
encoded_bits
does not equalcode_block_size()
.
- encode(bits)[source]¶
Encodes a single block of bits.
Bit encoding routine during data transmission, encoding a block of \(K_n\) input bits into a block of \(L_n\) code bits.
- Parameters:
bits (np.ndarray) – A numpy vector of \(K_n\) bits, representing a single bit block to be encoded.
- Returns:
A numpy vector of \(L_n\) bits, representing a single code block.
- Return type:
np.ndarray
- Raises:
ValueError – If the length of
bits
does not equalbit_block_size()
.
- property bit_block_size: int¶
Data bit block size of a single coding operation.
In other words, the number of input bits within a single code block during transmit encoding, or the number of output bits during receive decoding. Referred to as \(K_n\) within the respective equations.
Returns: Number of bits \(K_n\).
- property code_block_size: int¶
Code bit block size of a single coding operation.
In other words, the number of input bits within a single code block during receive decoding, or the number of output bits during transmit encoding. Referred to as \(L_n\) within the respective equations.
Returns: Number of bits \(L_n\).
- property repetitions: int¶
Number of times the bit block is repeated during encoding.
- Returns:
Number of repetitions \(\tilde{M}\).
- Return type:
- Raises:
ValueError – If repetitions is smaller than one.
ValueError – If repetitions is even.
- yaml_tag: Optional[str] = 'Repetition'¶
YAML serialization tag.