Calculator Inputs
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.
Variable Meaning
- πⱼ = start probability for hidden state j.
- aᵢⱼ = transition probability from state i to state j.
- bⱼ(oₜ) = probability of observing symbol oₜ while in state j.
- δₜ(j) = best score ending in state j at time t.
- ψₜ(j) = best predecessor state index used for traceback.
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
- Enter the hidden states as a comma-separated list.
- Enter the complete set of observation symbols used by the model.
- Enter the observed sequence in the exact order it occurred.
- Provide one start probability for each hidden state.
- Fill the transition matrix with one row per state.
- Fill the emission matrix with one row per state and one value per observation symbol.
- Select log mode for better numerical stability on long sequences.
- Click Calculate Viterbi Path to see the decoded path, trellis, and diagnostics above the form.
Input Tips
- Row labels in the matrices must match the state names exactly.
- Observation labels are case-sensitive, so keep them consistent.
- Probabilities should usually stay between 0 and 1 and sum to 1 within each group.
- You can use words, symbols, or short codes as state and observation names.
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.