function is_reversible¶
- deeptime.markov.tools.analysis.is_reversible(T, mu=None, tol=1e-12)¶
Check reversibility of the given transition matrix.
- Parameters:
T ((M, M) ndarray or scipy.sparse matrix) – Transition matrix
mu ((M,) ndarray (optional)) – Test reversibility with respect to this vector
tol (float (optional)) – Floating point tolerance to check with
- Returns:
is_reversible – True, if T is reversible, False otherwise
- Return type:
bool
Notes
A transition matrix is reversible with respect to a probability vector if the follwing holds,
In this case is the stationary vector for , so that .
If the stationary vector is unknown it is computed from before reversibility is checked.
A reversible transition matrix has purely real eigenvalues. The left eigenvectors can be computed from right eigenvectors via .
Examples
>>> import numpy as np >>> from deeptime.markov.tools.analysis import is_reversible
>>> P = np.array([[0.8, 0.1, 0.1], [0.5, 0.0, 0.5], [0.0, 0.1, 0.9]]) >>> is_reversible(P) False
>>> T = np.array([[0.9, 0.1, 0.0], [0.5, 0.0, 0.5], [0.0, 0.1, 0.9]]) >>> is_reversible(T) True