def rownorm(tmat):
    """
    Normalize the rows of a stochastic transition matrix
    using rescaling
    """
    for (ind,row) in enumerate(tmat):
        tmat[ind,:] = row/sum(row)
    return tmat