# [Numpy-discussion] finding eigenvectors etc

Matthieu Brucher matthieu.brucher@gmail....
Wed Feb 20 01:13:57 CST 2008

```Hi,

The results are OK, they are very close. Your matrix is almost singular, is
badly conditionned, ... But the results are very close is you check them in
a relative way. 3.84433376e-03 or -6.835301757686207E-4 is the same compared
to 2.76980401e+13

Matthieu

2008/2/20, devnew@gmail.com <devnew@gmail.com>:
>
> hi
> i was calculating eigenvalues and eigenvectors for a covariancematrix
> using numpy
>
> evalues,evect=eigh(covarmat)
>
> for a sample covarmat like
> [[  1.69365981e+13 , -5.44960784e+12,  -9.00346400e+12 , -2.48352625e
> +12]
> [ -5.44960784e+12,   5.08860660e+12,  -8.67539205e+11  , 1.22854045e
> +12]
> [ -9.00346400e+12,  -8.67539205e+11,   1.78184943e+13  ,-7.94749110e
> +12]
> [ -2.48352625e+12 ,  1.22854045e+12,  -7.94749110e+12 ,  9.20247690e
> +12]]
>
> i get these
> evalues
> [  3.84433376e-03,  4.17099934e+12 , 1.71771364e+13 ,  2.76980401e+13]
>
> evect
> [[ 0.5        -0.04330262  0.60041892 -0.62259297]
> [ 0.5        -0.78034307 -0.35933516  0.10928372]
> [ 0.5         0.25371931  0.3700265   0.74074753]
> [ 0.5         0.56992638 -0.61111026 -0.22743827]]
>
> what bothers me is that for the same covarmat i get a different set of
> eigenvectors and eigenvalues when i use java library Jama's methods
> Matrix faceM = new Matrix(faces, nrfaces,length);
> Matrix faceM_transpose = faceM.transpose();
> Matrix covarM = faceM.times(faceM_transpose);
> EigenvalueDecomposition E = covarM.eig();
> double[] eigValue = diag(E.getD().getArray());
> double[][] eigVector = E.getV().getArray();
>
> here the eigValue=
> [-6.835301757686207E-4, 4.170999335736721E12, 1.7177136443134865E13,
> 2.7698040117669414E13]
>
> and eigVector
> [
> [0.5, -0.04330262221379265, 0.6004189175979487, 0.6225929700052174],
> [0.5, -0.7803430730840767, -0.3593351608695496, -0.10928371540423852],
> [0.49999999999999994, 0.2537193127299541, 0.370026504572483,
> -0.7407475253159538],
> [0.49999999999999994, 0.5699263825679145, -0.6111102613008821,
> 0.22743827071497524]
> ]
>
> I am quite confused bythis difference in results ..the first element
> in eigValue is different and also the signs in last column of
> eigVectors are diff..can someone tell me why this happens?
> thanks
> dn
>
>
>
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>

--
French PhD student
Website : http://matthieu-brucher.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92