Numpy-based routines for stochastic matrices