Advanced Viterbi Path Calculator

Build trellises for discrete Hidden Markov Models instantly. Compare transitions, emissions, scores, and backpointers clearly. Export results, inspect steps, and verify decoded paths fast.

Calculator Inputs

Comma-separated states, such as Rainy,Sunny.
Comma-separated observation labels used by the emission matrix.
Enter the observed sequence in time order.
One value per state, aligned with the states field.
Log mode is better for long sequences and tiny probabilities.
Choose how many decimals to show in the results.
Use one row per state. Labels are optional but recommended. Values follow the states order.
Use one row per state. Values follow the observation symbols order.
Clear

Example Data Table

Component Example Value Notes
Hidden States Rainy, Sunny These are the unknown states to decode.
Observation Symbols walk, shop, clean These labels define emission columns.
Observation Sequence walk, shop, clean This is the time-ordered observed data.
Start Probabilities 0.6, 0.4 The sequence starts more often in Rainy.
Transition Matrix Rainy: 0.7,0.3
Sunny: 0.4,0.6
Each row maps from a current state to next-state probabilities.
Emission Matrix Rainy: 0.1,0.4,0.5
Sunny: 0.6,0.3,0.1
Each row maps from a hidden state to observation probabilities.
Expected Best Path Sunny → Rainy → Rainy This is the classic Viterbi decoding outcome for the sample data.

Formula Used

The calculator applies the Viterbi dynamic programming recurrence for Hidden Markov Models. It finds the single most likely hidden-state sequence that explains the observed symbols.

Initialization: δ₀(j) = πⱼ × bⱼ(o₀)
Recurrence: δₜ(j) = maxᵢ [δₜ₋₁(i) × aᵢⱼ] × bⱼ(oₜ)
Backpointer: ψₜ(j) = argmaxᵢ [δₜ₋₁(i) × aᵢⱼ]
Termination: P* = maxⱼ δₜ(j)
Path reconstruction: q*ₜ = ψₜ₊₁(q*ₜ₊₁)

Variable Meaning

Why Log Mode Helps

Multiplying many tiny probabilities can underflow. Log mode converts products into sums, preserving the same winning path while keeping calculations stable for longer sequences.

How to Use this Calculator

  1. Enter the hidden states as a comma-separated list.
  2. Enter the complete set of observation symbols used by the model.
  3. Enter the observed sequence in the exact order it occurred.
  4. Provide one start probability for each hidden state.
  5. Fill the transition matrix with one row per state.
  6. Fill the emission matrix with one row per state and one value per observation symbol.
  7. Select log mode for better numerical stability on long sequences.
  8. Click Calculate Viterbi Path to see the decoded path, trellis, and diagnostics above the form.

Input Tips

Frequently Asked Questions

1) What does this Viterbi Path Calculator do?

It identifies the most likely hidden-state sequence that produced your observations. The calculator applies dynamic programming, shows trellis scores, traces backpointers, and reports the decoded path.

2) How is Viterbi different from the forward algorithm?

The forward algorithm sums probabilities across all paths. Viterbi keeps only the best path reaching each state, so it is designed for decoding rather than total likelihood.

3) Do my probabilities need to sum to one?

Ideally yes. Start, transition, and emission probabilities should each sum to one within their groups. The calculator still computes results when they do not, but it flags model-quality warnings.

4) Why should I use log mode?

Log mode reduces underflow when sequences are long or probabilities are tiny. It preserves the same winning path while making intermediate calculations more numerically stable.

5) Can I use words instead of numbers for observations?

Yes. States and observations can be words, codes, or symbols. Just keep labels consistent across the observation list, sequence, and emission matrix.

6) What happens if some probabilities are zero?

Zero values make some paths impossible. That is valid in many models. If too many zeros block every route, revise the matrices or observation sequence.

7) What are backpointers used for?

Backpointers store the best previous state for each cell. They let the calculator reconstruct the final optimal path after the trellis has been filled.

8) Where is the Viterbi method commonly used?

It is useful in speech tagging, bioinformatics, digital communications, error correction, and any Hidden Markov Model problem where sequence decoding matters.

Related Calculators

state transition diagram toolforward algorithm calculatorstationary distribution solver

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.