Routines for stochastic matrices