def perturb_tmat(transmat, scale):
    '''
    Perturbs each nonzero entry in the MSM transition matrix by treating it as a Gaussian random variable
    with mean t_ij and standard deviation equal to the standard error computed using "create_perturb_params".
    Returns a sampled transition matrix that takes into consideration errors due to finite sampling
    (useful for boostrapping, etc.)

    Parameters:
    ----------
    transmat: np.ndarray:
        The transition matrix, whose elements serve as the means of the Gaussian random variables
    scale: np.ndarray:
        The matrix of standard errors. For transition probability t_ij, this is assumed to be the standard 
        error of the mean of a binomial distribution with p = transition probability and number of observations 
        equal to the summed counts in row i.

    '''
    output = np.vectorize(np.random.normal)(transmat, scale)
    output[np.where(output < 0)] = 0
    return (output.transpose() / np.sum(output, axis=1)).transpose()
Perturbs each nonzero entry in the MSM transition matrix by treating it as a Gaussian random variable
    with mean t_ij and standard deviation equal to the standard error computed using "create_perturb_params".
    Returns a sampled transition matrix that takes into consideration errors due to finite sampling
    (useful for boostrapping, etc.)

    Parameters:
    ----------
    transmat: np.ndarray:
        The transition matrix, whose elements serve as the means of the Gaussian random variables
    scale: np.ndarray:
        The matrix of standard errors. For transition probability t_ij, this is assumed to be the standard 
        error of the mean of a binomial distribution with p = transition probability and number of observations 
        equal to the summed counts in row i.