egttools.numerical.stationary_distribution_from_sparse¶
- stationary_distribution_from_sparse(P, tol=1e-12, max_iter=1000)[source]¶
Compute the stationary distribution of an explicit sparse transition matrix.
Uses
scipy.sparse.linalg.eigs(ARPACK) on the transpose of P to find the leading eigenvector, which is the stationary distribution π satisfyingP^T π = π.This is the fastest available local method for moderate state spaces (up to the RAM limit for storing P) and is the recommended approach when P has already been assembled via
PairwiseComparison.calculate_transition_matrix.- Parameters:
P (scipy.sparse matrix) – Row-stochastic transition matrix of shape
(n, n). Typically the output ofPairwiseComparison.calculate_transition_matrix(beta, mu).tol (float) – ARPACK convergence tolerance (default 1e-12; 0 → machine precision).
max_iter (int) – Maximum number of ARPACK iterations (default 1000).
- Returns:
Normalised stationary distribution of length
n, non-negative and summing to 1.- Return type:
- Raises:
scipy.sparse.linalg.ArpackNoConvergence – If ARPACK fails to converge within max_iter iterations.