docs: def is_transition_matrix(T, tol=1e-10):
      """
      Tests whether T is a transition matrix
  
      Parameters
      ----------
      T : ndarray shape=(n, n)
          matrix to test
      tol : float
          tolerance to check with
  
      Returns
      -------
      Truth value : bool
          True, if all elements are in interval [0, 1]
              and each row of T sums up to 1.
          False, otherwise
      """
      if T.ndim != 2:
          return False
      if T.shape[0] != T.shape[1]:
          return False
      dim = T.shape[0]
      X = np.abs(T) - T
      x = np.sum(T, axis=1)
      return np.abs(x - np.ones(dim)).max() < dim * tol and X.max() < 2.0 * tol