'Python package to estimate Perron-Frobenius Eigenvalue of real, square, non-negative matrix

Is there an optimized package or method that estimates the Perron-Frobenius eigenvalue of a real, square, non-negative matrix? This could be significantly faster (especially for large and/or sparse matrices) than an exact calculation -- given that the Perron-Frobenius eigenvalue can be arrived at by iterating the matrix. I am hoping an optimized package exists which does this.



Solution 1:[1]

If A is a square matrix, possibly in a sparse format, then you can get its largest magnitude (LM) eigenvalue, i.e. its Perron-Frobenius eigenvalue, and the corresponding eigenvector using SciPy’s eigs and eigsh functions:

from scipy.sparse.linalg import eigs

val, vec = eigs(a, k=1, which='LM')

SciPy has solvers for sparse eigenvalue problems of various forms that use the ARPACK library. You can read more in SciPy’s ARPACK tutorial.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 fpersyn