Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 746
gabe Avatar asked Jan 22 '13 03:01

gabe


1 Answers

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.

like image 176
Jaime Avatar answered Nov 14 '22 14:11

Jaime