forward_p function

Forward algorithm with for periodically varying transition probability matrices