def is_rate_matrix(K, tol=1e-10):
    """
    True if K is a rate matrix
    Parameters
    ----------
    K : numpy.ndarray matrix
        Matrix to check
    tol : float
        tolerance to check with

    Returns
    -------
    Truth value : bool
        True, if K negated diagonal is positive and row sums up to zero.
        False, otherwise
    """
    R = K - K.diagonal()
    off_diagonal_positive = np.allclose(R, abs(R), 0.0, atol=tol)

    row_sum = K.sum(axis=1)
    row_sum_eq_0 = np.allclose(row_sum, 0.0, atol=tol)

    return off_diagonal_positive and row_sum_eq_0