A casino switches between a fair die and a die loaded towards six. You see only the rolls. The filtered curve (gold) is the probability of the loaded die given the rolls so far (forwards algorithm); the smoothed curve (teal) uses all the rolls (forwards-backwards); the Viterbi panel shows the single most probable state sequence. Grey bars are the true loaded periods. The rolls were generated by the default casino; you change what the model believes.
The die is loaded towards six, so a run of sixes raises the filtered curve at once; the smoothed curve also looks ahead, so it rises before a streak is complete and stays up after it ends. Viterbi commits to one sequence and can differ from the per-roll best guess of the smoothed curve. Formulas (9.5)–(9.8), (9.12), (9.43)–(9.45), (9.48).
code/ch09_message_passing.py (forwards, backwards, forwards_backwards, viterbi, ffbs_sample; Figures 9.3 and 9.6).