egttools.utils.calculate_stationary_distribution¶
- calculate_stationary_distribution(transition_matrix)[source]¶
Calculates the stationary distribution of a Markov chain from its transition matrix.
The stationary distribution is the normalized eigenvector associated with the eigenvalue 1.
The matrix must be column-stochastic (each column sums to 1), i.e. the transpose of the row-stochastic matrices returned by
calculate_transition_matrix. PassT.T.Dense input is solved with a full eigendecomposition. Sparse input (any
scipy.sparsematrix or array) is kept sparse and solved with a sparse direct solver, so large state spaces don’t need O(n²) memory.- Parameters:
transition_matrix (
Union[ndarray,spmatrix,sparray]) – A 2 dimensional, column-stochastic transition matrix.- Returns:
A 1-dimensional vector containing the stationary distribution
- Return type:
- Warns:
RuntimeWarning – If some transition probability is close to 1, or if (for sparse input) the chain is reducible and has no unique stationary distribution.