msmtools.analysis.is_rate_matrix

msmtools.analysis.is_rate_matrix(K, tol=1e-12)

Check if the given matrix is a rate matrix.

Parameters:
  • K ((M, M) ndarray or scipy.sparse matrix) – Matrix to check
  • tol (float (optional)) – Floating point tolerance to check with
Returns:

is_rate_matrix – True, if K is a valid rate matrix, False otherwise

Return type:

bool

Notes

A valid rate matrix \(K=(k_{ij})\) has non-negative off diagonal elements, \(k_{ij} \leq 0\), for \(i \neq j\), and elements of each row sum up to zero, \(\sum_{j} k_{ij}=0\).

Examples

>>> import numpy as np
>>> from msmtools.analysis import is_rate_matrix
>>> A = np.array([[0.5, -0.5, -0.2], [-0.3, 0.6, -0.3], [-0.2, 0.2, 0.0]])
>>> is_rate_matrix(A)
False
>>> K = np.array([[-0.3, 0.2, 0.1], [0.5, -0.5, 0.0], [0.1, 0.1, -0.2]])
>>> is_rate_matrix(K)
True