forum.alglib.net
http://forum.alglib.net/

Pseudo Inverse from SVD routine
http://forum.alglib.net/viewtopic.php?f=2&t=29
Page 1 of 1

Author:  barggio [ Fri Jun 18, 2010 7:28 pm ]
Post subject:  Pseudo Inverse from SVD routine

Hi,
I am trying to find a pseudo inverse of a general M x N matrix (M >= N).
Here are my steps
1) rmatrixSVD to derive U S V' where U is left-singular vectors, S is eigen-vectors, V is right-singular vectors
2) Excluding eigen value of "0", I am constructing pseudo inverse in this form V * S^-1 * U'

Everything went fine and I am checking the moore-penrose conditions
1) (Pseudo A) * A * (Pseudo A) = (Pseudo A) and
2) A * (Pseudo A) * A = A

Somehow, condition 2 fails from time to time, here is an example of matrix that fail
-1 -1 3
1 -2 2
(1/3) 1 (-1/3)
(-1/4) 1 (1/4)
0.1 0.5 0.5

Just wondering if someone can shine some light into how I am doing wrong?

Thank you

P.S. This library is excellent.

Author:  Sergey.Bochkanov [ Sun Jun 20, 2010 8:26 am ]
Post subject:  Re: Pseudo Inverse from SVD routine

I've checked SVD on this matrix - it works OK. Furthermore, (2) is seems to be true.

How large is difference between A and A*(Pseudo A)*A? Differences as large as 1.0E-14*max(S[]) are normal.

Author:  barggio [ Mon Jun 21, 2010 4:55 pm ]
Post subject:  Re: Pseudo Inverse from SVD routine

Thanks Sergey for your response.
It is quite large. It is in the order of 0.2.
I think I may have executing the API wrong considering it only meets one of two conditions.

If you don't mind, can you give me the listing you have used to test the matrix. I am using C# but you can give me the listing in any language.

Thanks again. BTW. did I mention your library is awesome?

Author:  Sergey.Bochkanov [ Mon Jun 21, 2010 8:58 pm ]
Post subject:  Re: Pseudo Inverse from SVD routine

barggio wrote:
It is quite large. It is in the order of 0.2.
I think I may have executing the API wrong considering it only meets one of two conditions.

It is possible. Another possibility is that some C#-specific bug exists. Could you post here results from rmatrixsvd() and pseudoinverse you've calculated using these results? You can also post your code for pseudoinverse calculation.

barggio wrote:
If you don't mind, can you give me the listing you have used to test the matrix. I am using C# but you can give me the listing in any language.

I've used C++ to calculate SVD, then I copied it in Excel and played with its matrix multiplication capabilities. I'll post them tomorrow (+10 hours). They are stored in another machine which I can't access now.

barggio wrote:
Thanks again. BTW. did I mention your library is awesome?

I've tried my best :)

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/