Closed DanielMartensson closed 4 years ago
The eigenvalues and the singular values are the same, aren't they? The eigenvectors and/or the singular vectors are not unique so you cannot require them to be the same as with some other tool.
The eigenvalues and the singular values are the same, aren't they? The eigenvectors and/or the singular vectors are not unique so you cannot require them to be the same as with some other tool.
But the data is the same?
Which data? Don't know what you mean.
Which data. Don't know what you mean.
Let's take the eigenvalue example first. I assume that solving that problem, the SVD problem would be much easier to solve later.
Here is the matlab code:
A = [0.0 1.0 2.0 3.0 4.0
1.0 2.0 3.0 4.0 5.0
2.0 3.0 4.0 5.0 6.0
3.0 4.0 5.0 6.0 7.0
4.0 5.0 6.0 7.0 8.0];
B = [0.7868535918842593 0.25206982118540255 0.8502514736661777 0.957057138020801 0.057816696367313236
0.13879101503702707 0.7128202999301166 0.1301621659119453 0.31855375514373074 0.5217887100001347
0.32528138064626044 0.375732472964022 0.8722279148638662 0.2623839802297663 0.6554277853039092
0.29653713361927037 0.5156537331156116 0.0769602762384829 0.5727731028190134 0.22446173846280937
0.48182976689909873 0.19256889992091686 0.6541198727551285 0.6268943810659438 0.42040774186487684];
% A*D = D*B*V - Find V and D
[V, D] = eig(pinv(B)*A)
A and B are data.
They will output this data:
V =
-0.8435341 -0.8140592 0.5179533 0.4271032 0.0036528
-0.0216503 0.0842064 -0.7341037 -0.0259704 -0.1009847
0.2626517 0.2944670 -0.1408616 -0.7128079 0.5296932
0.4528850 0.4815752 0.4122211 -0.2048857 -0.7710436
-0.1178591 -0.1076635 -0.0552091 0.5165609 0.3386822
D =
Diagonal Matrix
-7.2243e+01 0 0 0 0
0 1.9682e+01 0 0 0
0 0 1.2203e-12 0 0
0 0 0 1.0295e-14 0
0 0 0 0 -6.6871e-14
Compare that with my code above, it will not give the same result.
Are you referring to the fact that the V matrices are different? Eigenvectors are not unique which means the V matrix is not unique.
Are you referring to the fact that the V matrices are different? Eigenvectors are not unique which means the V matrix is not unique.
Yes. For eig - V is different. For svd - U is different.
Again, eigenvectors are not uniquely defined. https://stackoverflow.com/questions/13041178/could-we-get-different-solutions-for-eigenvectors-from-a-matrix
Again, eigenvectors are not uniquely defined. https://stackoverflow.com/questions/13041178/could-we-get-different-solutions-for-eigenvectors-from-a-matrix
So you mean that if eigenvectors can differ depending on what software and computer I'm using?
Depending on which software, yes. Eigenvalues are uniquely defined, but not vectors.
On 14 May 2020, at 16:23, Daniel Mårtensson notifications@github.com wrote:
Again, eigenvectors are not uniquely defined. https://stackoverflow.com/questions/13041178/could-we-get-different-solutions-for-eigenvectors-from-a-matrix
So you mean that if eigenvectors can differ depending on what software and computer I'm using?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
Depending on which software, yes. Eigenvalues are uniquely defined, but not vectors. … On 14 May 2020, at 16:23, Daniel Mårtensson @.***> wrote: Again, eigenvectors are not uniquely defined. https://stackoverflow.com/questions/13041178/could-we-get-different-solutions-for-eigenvectors-from-a-matrix So you mean that if eigenvectors can differ depending on what software and computer I'm using? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
Good to know. I assume that it was no issue after all?
Normaly, my MATLAB code want to solve: [V, D] = eig(A, B)
And I know that OjAlgo can solve generalized eigenvalue problem. But your examples shows that A and B must be symmetrical. Is that a requirement for generalized eigenvalue problem?
It’s a requirement for what what ojAlgo can handle at least. Essentially ojAlgo can handle the cases described here: https://www.netlib.org/lapack/lug/node54.html
On 14 May 2020, at 16:31, Daniel Mårtensson notifications@github.com wrote:
Depending on which software, yes. Eigenvalues are uniquely defined, but not vectors. … On 14 May 2020, at 16:23, Daniel Mårtensson @.***> wrote: Again, eigenvectors are not uniquely defined. https://stackoverflow.com/questions/13041178/could-we-get-different-solutions-for-eigenvectors-from-a-matrix So you mean that if eigenvectors can differ depending on what software and computer I'm using? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
Good to know. I assume that it was no issue after all?
Normaly, my MATLAB code want to solve: [V, D] = eig(A, B)
And I know that OjAlgo can solve generalized eigenvalue problem. But your examples shows that A and B must be symmetrical. Is that a requirement for generalized eigenvalue problem?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
It’s a requirement for what what ojAlgo can handle at least. Essentially ojAlgo can handle the cases described here: https://www.netlib.org/lapack/lug/node54.html
I understand. Well, perhaps I need to use [V, D] = eig(pinv(B)*A)
instead of [V, D] = eig(A, B)
Because only B is symmetrical. I'm not talking about MATLAB's routines here. I'm only using MATLAB code to describe math easily.
Thank you for the information.
It’s a requirement for what what ojAlgo can handle at least. Essentially ojAlgo can handle the cases described here: https://www.netlib.org/lapack/lug/node54.html … On 14 May 2020, at 16:31, Daniel Mårtensson @.> wrote: Depending on which software, yes. Eigenvalues are uniquely defined, but not vectors. … On 14 May 2020, at 16:23, Daniel Mårtensson @.> wrote: Again, eigenvectors are not uniquely defined. https://stackoverflow.com/questions/13041178/could-we-get-different-solutions-for-eigenvectors-from-a-matrix So you mean that if eigenvectors can differ depending on what software and computer I'm using? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Good to know. I assume that it was no issue after all? Normaly, my MATLAB code want to solve: [V, D] = eig(A, B) And I know that OjAlgo can solve generalized eigenvalue problem. But your examples shows that A and B must be symmetrical. Is that a requirement for generalized eigenvalue problem? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
En sak! Nu är denna tråd redan stängd så jag tar det på Svenska. Jag håller på skriva ett javaprogram som håller på med bildigenkänning med minimal data. Hittils har det visat sig goda resultat.
Jag skriver av ett 8-årigt MATLAB projekt som håller på med något som heter Fisherfaces. Det ska tydligen vara ett krångligt ämne. Men så länge jag skriver av MATLAB koden så blir det fint.
Men då finns det ett problem. MATLAB projektet använder sig utav egenvektorer från EIG och egenvektorer från SVD som multipliceras med varandra. Jag har ingen aning om hur matematiken går till då det inte finns beskrivet.
I MATLAB så blir det alltså bättre resulat (96%) men i mitt program så blir det 93.3% i validering. Nog är detta högt. Men jag misstänker att programmet är konstruerat för just MATLAB's SVD U och EIG V.
Finns det möjlighet inom OjAlgo att välja om så det blir "MATLAB-liknande" EIG V och SVD U? Typ någon val utav norm?
Det som skiljer mellan SVD U i MATLAB och SVD U i OjAlgo är att vissa värden är negativa, andra är positiva. Men själva nummret är det samma.
I EIG V så skiljer nummret och om det är positivt eller negativt.
Koden kommer jag lägga upp inom kort.
Here is a minimal example of the SVD code
The output looks like this:
But according to Octave, the output looks like this:
As you can see. the U matrix is not correct compared with Octave. Why? Is it because I'm using PRIMITIVE? Don't know what it means.
I have also a question about eigendecomposition. Here is my example code:
I call that code with this data and get the output:
But GNU Octave shows
From the same data
Notice that I'm using random matrices.