HMM Code
From SGenomics
This page contains a simple Viterbi implementation which I've made for my own amusement. If you wish you can take it and use it under the GPL version 2 or 3 or a BSD license or MIT license. Take it, use it, do what you want with it (but I don't owe you anything).
http://sgenomics.org/mediawiki/upload/4/43/Viterbi.tar.gz
wikipedia viterbi
The following worked through example relates to the Viterbi example currently on wikipedia (June 2009)
Forward probability from brute force calculation:
(0.6*0.1*0.7*0.4*0.7*0.5*0.7)+(0.6*0.1*0.7*0.4*0.7*0.5*0.3)+(0.6*0.1*0.7*0.4*0.3*0.1*0.4)+(0.6*0.1*0.7*0.4*0.3*0.1*0.6)+(0.6*0.1*0.3*0.3*0.4*0.5*0.7)+(0.6*0.1*0.3*0.3*0.4*0.5*0.3)+(0.6*0.1*0.3*0.3*0.6*0.1*0.4)+(0.6*0.1*0.3*0.3*0.6*0.1*0.6)+(0.4*0.6*0.4*0.4*0.7*0.5*0.7)+(0.4*0.6*0.4*0.4*0.7*0.5*0.3)+(0.4*0.6*0.4*0.4*0.3*0.1*0.4)+(0.4*0.6*0.4*0.4*0.3*0.1*0.6)+(0.4*0.6*0.6*0.3*0.4*0.5*0.7)+(0.4*0.6*0.6*0.3*0.4*0.5*0.3)+(0.4*0.6*0.6*0.3*0.6*0.1*0.4)+(0.4*0.6*0.6*0.3*0.6*0.1*0.6)
= 0.0336120
