VOOZH about

URL: https://qiita.com/shingo_toku/items/7e7c7cb54f570ad876f3

⇱ 固有値・固有ベクトルを求める #Python - Qiita


👁 Image
6

Go to list of users who liked

4

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

More than 5 years have passed since last update.

@shingo_toku

固有値・固有ベクトルを求める

6
Last updated at Posted at 2015-01-28

以前、pythonを使って固有値・固有ベクトルを求めることをテストとして記述したのだが忘れてしまったので復習のため記述しなおしてみた。

EigenValue.py
# encoding:UTF-8

import numpy
import scipy.linalg


def EigenValue():
 
 #固有値をいくつ求めるかを設定する
 hi = 2
 lo = 0

 #適当な行列を作る 
 A = numpy.matrix([[1,2,3],[4,5,6],[7,8,9]])

 #固有値、固有ベクトルを計算
 eigen_value,eigen_vector = scipy.linalg.eigh(A,eigvals=(lo,hi))

 #固有値の大きい順番で並べ替える
 eigen_id = numpy.argsort(eigen_value)[::-1]
 eigen_value = eigen_value[:,eigen_id]
 eigen_vector = eigen_vector[:,eigen_id]
 
 print eigen_value
 print eigen_vector

if __name__=="__main__":
 EigenValue()

パラメータ

http://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigh.html

6

Go to list of users who liked

4
1

Go to list of comments

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6

Go to list of users who liked

4