Skip to content

komm.ViterbiDecoder

Viterbi decoder for terminated convolutional codes. For more details, see LC04, Sec. 12.1.

Parameters:

  • code (TerminatedConvolutionalCode)

    The terminated convolutional code to be used for decoding.

  • snr (float)

    The signal-to-noise ratio (SNR) of the channel (linear, not decibel). Only used for soft-input decoding.

  • input_type (Literal['hard', 'soft'])

    The type of the input. Either 'hard' or 'soft'. Default is 'hard'.

Notes
  • Input type: hard or soft.
  • Output type: hard.

__call__

Decode received words. This method takes one or more sequences of received words and returns their corresponding estimated message sequences.

Parameters:

  • input (ArrayLike)

    The input sequence(s). Can be either a single sequence whose length is a multiple of $n$, or a multidimensional array where the last dimension is a multiple of $n$.

Returns:

  • output (NDArray[integer | floating])

    The output sequence(s). Has the same shape as the input, with the last dimension contracted from $bn$ to $bk$, where $b$ is a positive integer.

Examples:

>>> convolutional_code = komm.ConvolutionalCode(feedforward_polynomials=[[0b011, 0b101, 0b111]])
>>> code = komm.TerminatedConvolutionalCode(convolutional_code, num_blocks=5, mode="zero-termination")
>>> decoder = komm.ViterbiDecoder(code, input_type="hard")
>>> decoder([1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1])
array([1, 1, 0, 0, 1])
>>> convolutional_code = komm.ConvolutionalCode(feedforward_polynomials=[[0b111, 0b101]])
>>> code = komm.TerminatedConvolutionalCode(convolutional_code, num_blocks=4, mode="direct-truncation")
>>> decoder = komm.ViterbiDecoder(code, input_type="soft", snr=10.0)
>>> decoder([-0.7, -0.5, -0.8, -0.6, -1.1, +0.4, +0.9, +0.8])
array([1, 0, 0, 0])