building the stochastic matrix