HMM Viterbi Decoder Calculator

Map observations to the most likely hidden state path. Check matrices, scores, and dynamic tables. Export results and inspect every decoding stage with confidence.

Calculator Input

Use comma or line-separated labels. Use one matrix row per line. The decoder runs in log space for numerical stability.

Example: Rainy, Sunny
Example: Walk, Shop, Clean
Example: Walk, Shop, Clean
Count must match hidden states.
One state row per line. Columns equal hidden states.
One state row per line. Columns equal observation symbols.
Used in displayed scores and export files.

Example data table

Component Example values
Hidden states Rainy, Sunny
Observation symbols Walk, Shop, Clean
Observed sequence Walk, Shop, Clean
Start probabilities 0.6, 0.4
Transition matrix Rainy → 0.7, 0.3
Sunny → 0.4, 0.6
Emission matrix Rainy → 0.1, 0.4, 0.5
Sunny → 0.6, 0.3, 0.1
Expected best path Sunny → Rainy → Rainy

Formula used

The calculator applies the Viterbi dynamic programming algorithm to find the most likely hidden state sequence for a given observation stream.

δ₁(j) = πⱼ × bⱼ(o₁)
δₜ(j) = maxᵢ [δₜ₋₁(i) × aᵢⱼ] × bⱼ(oₜ)
ψₜ(j) = argmaxᵢ [δₜ₋₁(i) × aᵢⱼ]
P* = maxⱼ δₜ(j)

To avoid underflow, the page computes in log space:

log δ₁(j) = log πⱼ + log bⱼ(o₁)
log δₜ(j) = maxᵢ [log δₜ₋₁(i) + log aᵢⱼ] + log bⱼ(oₜ)

After the last time step, the decoder picks the highest final score, then backtracks through ψ to reconstruct the optimal path.

How to use this calculator

  1. Enter hidden state names, one per line or comma-separated.
  2. Enter all observation symbols used by the HMM.
  3. Provide the observed sequence in time order.
  4. Fill the start probability vector, transition matrix, and emission matrix.
  5. Enable normalization if your rows are not perfectly scaled.
  6. Click Decode Sequence to view the best path, tables, and graph.
  7. Export the decoded report with the CSV or PDF buttons.

FAQs

1) What does this calculator return?

It returns the most likely hidden state path for your observation sequence, along with path probability, log scores, normalized confidence by step, and the backpointer table used for reconstruction.

2) Why does the calculator use log scores?

Long sequences can make raw probabilities extremely small. Log space converts repeated multiplication into addition, which prevents underflow and keeps the decoder numerically stable.

3) What if my rows do not sum to 1?

Turn on normalization. The tool rescales the start vector and every matrix row so they sum to 1 before decoding. Leave it off only when your probabilities are already valid.

4) Can I use zero probabilities?

Yes. A zero means that a start, transition, or emission is impossible. Too many zeros can remove all valid paths, so check your model carefully if decoding fails.

5) What does the normalized score table mean?

It rescales Viterbi scores across states at each time step. These percentages help compare state dominance by step, but they are not full posterior probabilities.

6) How should I format the matrices?

Use one row per hidden state. Transition rows must have one value for each hidden state. Emission rows must have one value for each observation symbol.

7) What sequence length can I test?

You can test short or long sequences, but very large models may slow down in the browser. Performance grows with time steps multiplied by the square of state count.

8) When is Viterbi decoding useful?

It is useful in speech tagging, bioinformatics, error correction, finance regimes, signal decoding, and any task where hidden states generate visible observations over time.

Related Calculators

euler maruyama methodgalton watson processm m c queuehitting time calculatorrandom walk calculatorqueueing model calculatorbrownian motion toolrandom process variancetransition matrix solverwiener process calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.