Initial commit based on http://webdocs.cs.ualberta.ca/~lindek/hmm.htm