GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — python_reference/useful_scripts/principal_eigenvector.py at master · l3ldon/python_reference Expand file tree/ Copy pathprincipal_eigenvector.pyMore file actions 20 lines (14 loc) · 598 Bytes / Copy pathprincipal_eigenvector.pyFile metadata and controls20 lines (14 loc) · 598 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 # Select a principal eigenvector via NumPy # to be used as a template (copy & paste) script import numpy as np # set A to be your matrix A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) eig_vals, eig_vecs = np.linalg.eig(A) idx = np.absolute(eig_vals).argsort()[::-1] # decreasing order sorted_eig_vals = eig_vals[idx] sorted_eig_vecs = eig_vecs[:, idx] principal_eig_vec = sorted_eig_vecs[:, 0] # eigvec with largest eigval normalized_pr_eig_vec = np.real(principal_eig_vec / np.sum(principal_eig_vec)) print(normalized_pr_eig_vec) # eigvec that sums up to one |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |