Original viterbialgorithm