Skip to main content

Library to compute the best path through a trellis graph using the Viterbi algorithm.

Project description

Library to compute the best path through a trellis graph using the Viterbi algorithm.

The source for this project is available here.


This library provides the class ViterbiTrellis. At present it can only do one thing: compute the best path through a trellis graph. The user must provide three inputs:

  1. Trellis layer structure, specified as a list of lists. Each inner list corresponds to a single layer of the trellis. The first item in the outer list is the start layer, while the final item is the end layer. Each innermost item is an object representing the state. This could be a primitive type such as an int, or it could be a tuple or user-defined class.

  2. A cost function giving the cost for being in a given state.

  3. A transition function giving the cost of transitioning between two particular states.

The best path is chosen by globally minimizing the sum of the state costs and transitions via the Viterbi algorithm.

Example usage:

from viterbi_trellis import ViterbiTrellis
v = ViterbiTrellis([[2, 6, 4], [4, 6], [0, 2, 6]], lambda x: x / 2.0, lambda x, y: abs(y - x))
best_path = v.viterbi_best_path()

The return value in best_path is a list of indices of the states in the best path:

>>> best_path
[2, 0, 1]

This result corresponds to the states labeled [4, 4, 2] in the input trellis.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

viterbi_trellis-0.0.3.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

viterbi_trellis-0.0.3-py2.py3-none-any.whl (7.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file viterbi_trellis-0.0.3.tar.gz.

File metadata

File hashes

Hashes for viterbi_trellis-0.0.3.tar.gz
Algorithm Hash digest
SHA256 93ec0be923da7143a73c186e3b5322980b131ba209f666679ae8718f1f7e1bf6
MD5 65c958a1ffa560454f0b9c2d5e9188e5
BLAKE2b-256 0305ad07dce92829f59a695f9c2b3474fdbb8e5032f183c81ca7f078a801c6fb

See more details on using hashes here.

File details

Details for the file viterbi_trellis-0.0.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for viterbi_trellis-0.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 76417a1c6c032392f91ee816be31202087954834006a5758f4244ffdefa92b71
MD5 66daae82bed6413828a701f17b2b3116
BLAKE2b-256 9bd9ebcecf39ea01767aa9eb1a268acd5d2eeaf55a6039f24257ba5e14ad5a52

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page