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=(tij)T=(t_{ij}) is reversible with respect to a probability vector μ=(μi)\mu=(\mu_i) if the follwing holds,

μitij=μjtji.\mu_i \, t_{ij}= \mu_j \, t_{ji}.

In this case μ\mu is the stationary vector for TT, so that μTT=μT\mu^T T = \mu^T.

If the stationary vector is unknown it is computed from TT before reversibility is checked.

A reversible transition matrix has purely real eigenvalues. The left eigenvectors (li)(l_i) can be computed from right eigenvectors (ri)(r_i) via li=μiril_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