refactor hiddenmarkovmodel.predict