function is_transition_matrix

deeptime.markov.tools.analysis.is_transition_matrix(T, tol=1e-12)

Check if the given matrix is a transition matrix.

Parameters:
  • T ((M, M) ndarray or scipy.sparse matrix) – Matrix to check

  • tol (float (optional)) – Floating point tolerance to check with

Returns:

is_transition_matrix – True, if T is a valid transition matrix, False otherwise

Return type:

bool

Notes

A valid transition matrix \(P=(p_{ij})\) has non-negative elements, \(p_{ij} \geq 0\), and elements of each row sum up to one, \(\sum_j p_{ij} = 1\). Matrices wit this property are also called stochastic matrices.

Examples

>>> import numpy as np
>>> from deeptime.markov.tools.analysis import is_transition_matrix
>>> A = np.array([[0.4, 0.5, 0.3], [0.2, 0.4, 0.4], [-1, 1, 1]])
>>> is_transition_matrix(A)
False
>>> T = np.array([[0.9, 0.1, 0.0], [0.5, 0.0, 0.5], [0.0, 0.1, 0.9]])
>>> is_transition_matrix(T)
True