HMM Code

From SGenomics

Jump to: navigation, search

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).

Image:Viterbi.tar.gz

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)

The model from the wikipedia page.
The model from the wikipedia page.

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
Paths for brute force evaluation
Paths for brute force evaluation
The Viterbi algorithm
The Viterbi algorithm
The forward algorithm
The forward algorithm