eigenvector

eigenvalue and eigenvectors in python vs matlab

醉酒当歌 提交于 2019-12-01 09:42:45
I have noticed there is a difference between how matlab calculates the eigenvalue and eigenvector of a matrix, where matlab returns the real valued while numpy's return the complex valued eigen valus and vector. For example: for matrix: A= 1 -3 3 3 -5 3 6 -6 4 Numpy: w, v = np.linalg.eig(A) w array([ 4. +0.00000000e+00j, -2. +1.10465796e-15j, -2. -1.10465796e-15j]) v array([[-0.40824829+0.j , 0.24400118-0.40702229j, 0.24400118+0.40702229j], [-0.40824829+0.j , -0.41621909-0.40702229j, -0.41621909+0.40702229j], [-0.81649658+0.j , -0.66022027+0.j , -0.66022027-0.j ]]) Matlab: [E, D] = eig(A) E -0

eigenvalue and eigenvectors in python vs matlab

混江龙づ霸主 提交于 2019-12-01 07:26:34
问题 I have noticed there is a difference between how matlab calculates the eigenvalue and eigenvector of a matrix, where matlab returns the real valued while numpy's return the complex valued eigen valus and vector. For example: for matrix: A= 1 -3 3 3 -5 3 6 -6 4 Numpy: w, v = np.linalg.eig(A) w array([ 4. +0.00000000e+00j, -2. +1.10465796e-15j, -2. -1.10465796e-15j]) v array([[-0.40824829+0.j , 0.24400118-0.40702229j, 0.24400118+0.40702229j], [-0.40824829+0.j , -0.41621909-0.40702229j, -0

eigenvectors created by numpy.linalg.eig don't seem correct

北城以北 提交于 2019-12-01 04:17:48
I create an arbitrary 2x2 matrix: In [87]: mymat = np.matrix([[2,4],[5,3]]) In [88]: mymat Out[88]: matrix([[2, 4], [5, 3]]) I attempt to calculate eigenvectors using numpy.linalg.eig: In [91]: np.linalg.eig(mymat) Out[91]: (array([-2., 7.]), matrix([[-0.70710678, -0.62469505], [ 0.70710678, -0.78086881]])) In [92]: eigvec = np.linalg.eig(mymat)[1][0].T In [93]: eigvec Out[93]: matrix([[-0.70710678], [-0.62469505]]) I multiply one of my eigenvectors with my matrix expecting the result to be a vector that is a scalar multiple of my eigenvector. In [94]: mymat * eigvec Out[94]: matrix([[-3

What is the difference between 'eig' and 'eigs'?

我是研究僧i 提交于 2019-12-01 02:56:54
I've searched a lot for this but I can't find any answer about how the two methods 'eig' and 'eigs' differ. What is the difference between the eigenvalues and eigenvectors received from them? They use different algorithms, tailored to different problems and different goals. eig is a good, fast, general use eigenvalue/vector solver. It is appropriate for use when your matrix is of a realistic size that fits well in memory, and when you need all of the eigenvalues/vectors. Sparse matrices do not work at all in eig . Eigs is a solver that is more appropriate for when you need only a limited

eigenvectors created by numpy.linalg.eig don't seem correct

余生长醉 提交于 2019-12-01 00:12:41
问题 I create an arbitrary 2x2 matrix: In [87]: mymat = np.matrix([[2,4],[5,3]]) In [88]: mymat Out[88]: matrix([[2, 4], [5, 3]]) I attempt to calculate eigenvectors using numpy.linalg.eig: In [91]: np.linalg.eig(mymat) Out[91]: (array([-2., 7.]), matrix([[-0.70710678, -0.62469505], [ 0.70710678, -0.78086881]])) In [92]: eigvec = np.linalg.eig(mymat)[1][0].T In [93]: eigvec Out[93]: matrix([[-0.70710678], [-0.62469505]]) I multiply one of my eigenvectors with my matrix expecting the result to be a

Incorrect EigenValues/Vectors with Numpy

雨燕双飞 提交于 2019-11-30 21:55:36
I am trying to find the eigenvalues/vectors for the following matrix: A = np.array([[1, 0, 0], [0, 1, 0], [1, 1, 0]]) using the code: from numpy import linalg as LA e_vals, e_vecs = LA.eig(A) I'm getting this as the answer: print(e_vals) [ 0. 1. 1.] print(e_vecs) [[ 0. 0.70710678 0. ] [ 0. 0. 0.70710678] [ 1. 0.70710678 0.70710678]] However, I believe the following should be the answer. [1] Real Eigenvalue = 0.00000 [1] Real Eigenvector: 0.00000 0.00000 1.00000 [2] Real Eigenvalue = 1.00000 [2] Real Eigenvector: 1.00000 0.00000 1.00000 [3] Real Eigenvalue = 1.00000 [3] Real Eigenvector: 0

Compute eigenvectors of image in python

空扰寡人 提交于 2019-11-30 21:18:22
I'm trying to fit a 2D Gaussian to an image. Noise is very low, so my attempt was to rotate the image such that the two principal axes do not co-vary, figure out the maximum and just compute the standard deviation in both dimensions. Weapon of choice is python. However I got stuck at finding the eigenvectors of the image - numpy.linalg.py assumes discrete data points. I thought about taking this image to be a probability distribution, sampling a few thousand points and then computing the eigenvectors from that distribution, but I'm sure there must be a way of finding the eigenvectors (ie.,

Eigenvalues in MATLAB

倾然丶 夕夏残阳落幕 提交于 2019-11-30 19:38:01
In MATLAB, when I run the command [V,D] = eig(a) for a symmetric matrix, the largest eigenvalue (and its associated vector) is located in last column. However, when I run it with a non-symmetric matrix, the largest eigenvalue is in the first column. I am trying to calculate eigenvector centrality which requires that I take the compute the eigenvector associated with the largest eigenvalue. So the fact that the largest eigenvalue appears in two separate places it makes it difficult for me to find the solution. gnovice You just have to find the index of the largest eigenvalue in D , which can

Incorrect EigenValues/Vectors with Numpy

こ雲淡風輕ζ 提交于 2019-11-30 17:53:10
问题 I am trying to find the eigenvalues/vectors for the following matrix: A = np.array([[1, 0, 0], [0, 1, 0], [1, 1, 0]]) using the code: from numpy import linalg as LA e_vals, e_vecs = LA.eig(A) I'm getting this as the answer: print(e_vals) [ 0. 1. 1.] print(e_vecs) [[ 0. 0.70710678 0. ] [ 0. 0. 0.70710678] [ 1. 0.70710678 0.70710678]] However, I believe the following should be the answer. [1] Real Eigenvalue = 0.00000 [1] Real Eigenvector: 0.00000 0.00000 1.00000 [2] Real Eigenvalue = 1.00000

Eigenvalues in MATLAB

柔情痞子 提交于 2019-11-30 03:35:59
问题 In MATLAB, when I run the command [V,D] = eig(a) for a symmetric matrix, the largest eigenvalue (and its associated vector) is located in last column. However, when I run it with a non-symmetric matrix, the largest eigenvalue is in the first column. I am trying to calculate eigenvector centrality which requires that I take the compute the eigenvector associated with the largest eigenvalue. So the fact that the largest eigenvalue appears in two separate places it makes it difficult for me to