How do I find out eigenvectors corresponding to a particular eigenvalue of a matrix?

2024/10/10 20:16:23

How do I find out eigenvectors corresponding to a particular eigenvalue?

I have a stochastic matrix(P), one of the eigenvalues of which is 1. I need to find the eigenvector corresponding to the eigenvalue 1.

The scipy function scipy.linalg.eig returns the array of eigenvalues and eigenvectors.

D, V = scipy.linalg.eig(P)

Here D(array of values) and V(array of vectors) are both vectors.

One way is to do a search in D and extract the corresponding eigenvector in V. Is there an easier way?

Answer

If you are looking for one eigenvector corresponding to one eigenvalue, it could be much more efficient to use the scipy.sparse.linalg implementation of the eig function. It allows to look for a fixed number of eigenvectors and to shift the search around a specific value. You could do for instance :

values, vectors = scipy.sparse.linalg.eigs(P, k=1, sigma=1)
https://en.xdnf.cn/q/69855.html

Related Q&A

How to install my custom Python package with its custom dependencies?

I would like to find a way to install my own python package which depends on other custom python packages. I followed this guide to create my own python packages: https://python-packaging.readthedocs.i…

How to call a function only Once in Python [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.Want to improve this question? Add details and clarify the problem by editing this post.Closed 8 years ago.The com…

Generating Compound Pie, or Pie of Pie Charts

Below is an example of a compound pie chart, also known as a pie of pie chart drawn using Excel. Is it possible to create a figure like this using python?

GitPython : git push - set upstream

Im using GitPython to clone a master branch and do a checkout of a feature branch, I do my local updates, commit and push back to git. The code snippet looks like below, Note : my branch name is featur…

How to access multi-level index in pandas data frame?

I would like to call those row with same index.so this is the example data frame, arrays = [np.array([bar, bar, baz, baz, foo, foo, qux, qux]), np.array([one, two, one, two, one, two, one, two])]df = p…

How to represent graphs with IPython

Recently I discovered IPython notebook which is a powerful tool. As an IT student, I was looking for a way to represent graphs in Python. For example, I would like to know if theres a library (like num…

How to check TypeVars Type at runtime

I have a generic class Graph[Generic[T], object]. My question, is there any function which returns type passed as generic to the class Graph>>> g = Graph[int]() >>> magic_func(g) <…

Can django-pagination do multiple paginations per page?

If it cant then are there any other alternatives (either Djangos native pagination or an alternate package) that allows multiple paginations per page?I would like to display a list of about 5 objects …

List directory file contents in a Django template

Im just learning Python & Django. (Thanks to everyone who contributes here -- its been an invaluable resource!)One seemingly basic thing that Im having trouble with is rendering a simple list of s…

Produce PDF files, draw polygons with rounded corners

Whats the right tool for the job if I want to write a Python script that produces vector graphics in PDF format? In particular, I need to draw filled polygons with rounded corners (i.e., plane figures…