Implemented P function for estimating probabilities of w state given x state for k steps