Skip to content

komm.ViterbiStreamDecoder

Convolutional stream decoder using Viterbi algorithm. Decode a (hard or soft) bit stream given a convolutional code, assuming a traceback length (path memory) of $\tau$. At time $t$, the decoder chooses the survivor with best metric and outputs its information bits from time $t - \tau$. The output stream has a delay equal to $k \tau$, where $k$ is the number of input bits of the convolutional code. As a rule of thumb, the traceback length is chosen as $\tau = 5\mu$, where $\mu$ is the memory order of the convolutional code.

Parameters:

  • convolutional_code (ConvolutionalCode) –

    The convolutional code.

  • traceback_length (int) –

    The traceback length (path memory) $\tau$ of the decoder. Must be a non-negative integer.

  • initial_state (int) –

    The initial state of the decoder. Must be in $[0 : 2^\sigma)$, where $\sigma$ is the degree of the convolutional code. The default value is 0.

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

    The type of the input sequence, either hard or soft. The default value is hard.

decode()

Parameters:

  • input (ArrayLike) –

    The (hard or soft) bit sequence to be decoded. Must be a 1D-array whose length is a multiple of $n$, the number of output bits of the convolutional code.

Returns:

  • output (Array1D[integer]) –

    The decoded bit sequence.

Examples:

>>> decoder = komm.ViterbiStreamDecoder(
...     convolutional_code=komm.ConvolutionalCode([[0b111, 0b101]]),
...     traceback_length=10,
... )
>>> decoder.decode([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
array([0, 0, 0, 0, 0, 0, 0, 0])
>>> decoder.decode([1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1])
array([0, 0, 0, 0, 0, 0, 0, 0])
>>> decoder.decode([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
array([0, 0, 1, 0, 1, 1, 1, 0])

flush()

Returns the last $k \tau$ bits of the stream, taken from the survivor with best metric, and resets the decoder to its initial state.

Returns:

  • output (Array1D[integer]) –

    The last decoded bits.

Examples:

>>> decoder = komm.ViterbiStreamDecoder(
...     convolutional_code=komm.ConvolutionalCode([[0b111, 0b101]]),
...     traceback_length=4,
... )
>>> decoder.decode([1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1])
array([0, 0, 0, 0, 1, 0])
>>> decoder.flush()
array([1, 1, 1, 0])