calculate the sensitivity matrix for entry j of the mean first passage time (MFPT) given transition matrix T.
    Parameters
    ----------
    T : numpy.ndarray shape = (n, n)
        Transition matrix
    target : int
        target state to which the MFPT is computed
    j : int
        entry of the mfpt vector for which the sensitivity is to be computed

    Returns
    -------
    x : ndarray, shape=(n, n)
        Sensitivity matrix for entry index around transition matrix T. Reversibility is not assumed.

def mfpt_sensitivity(T, target, j):
    """
    calculate the sensitivity matrix for entry j of the mean first passage time (MFPT) given transition matrix T.
    Parameters
    ----------
    T : numpy.ndarray shape = (n, n)
        Transition matrix
    target : int
        target state to which the MFPT is computed
    j : int
        entry of the mfpt vector for which the sensitivity is to be computed

    Returns
    -------
    x : ndarray, shape=(n, n)
        Sensitivity matrix for entry index around transition matrix T. Reversibility is not assumed.
    """

    n = len(T)

    matA = T - numpy.diag(numpy.ones((n)))
    matA[target] *= 0
    matA[target, target] = 1.0

    tVec = -1. * numpy.ones(n)
    tVec[target] = 0

    mfpt = numpy.linalg.solve(matA, tVec)
    aVec = numpy.zeros(n)
    aVec[j] = 1.0

    phiVec = numpy.linalg.solve(numpy.transpose(matA), aVec)

    # TODO: Check sign of sensitivity!

    sensitivity = -1.0 * numpy.outer(phiVec, mfpt)
    sensitivity[target] *= 0

    return sensitivity