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 \(T=(t_{ij})\) is reversible with respect to a probability vector \(\mu=(\mu_i)\) if the follwing holds,
\[\mu_i \, t_{ij}= \mu_j \, t_{ji}. \]In this case \(\mu\) is the stationary vector for \(T\), so that \(\mu^T T = \mu^T\).
If the stationary vector is unknown it is computed from \(T\) before reversibility is checked.
A reversible transition matrix has purely real eigenvalues. The left eigenvectors \((l_i)\) can be computed from right eigenvectors \((r_i)\) via \(l_i=\mu_i r_i\).
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