-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V* in SVD should be transposed #47
Comments
I think Vectorz is correct -
If you want V, you can just transpose it as you observe. Here's my test which I believe demonstrates that Vectorz has the correct behaviour: (let [m (array :vectorz [[1 2 3 ] [ 4 5 6 ] [7 8 9]])
{:keys [U S V*]} (svd m)]
(inner-product U (diagonal-matrix S) V*))
=> #<Matrix [[0.9999999999999991,1.9999999999999991,2.999999999999998],
[4.000000000000001,5.000000000000003,6.000000000000001],
[7.000000000000001,8.000000000000002,9.0]]> i.e. you can reconstruct the matrix from the decomposition (modulo minor numerical inaccuracy) |
I suspect this is Clatrix doing it wrong, and returning V instead of V* |
Closing this because not a vectorz-clj issue |
Yes, you are absolutely right. In contrast to what I said earlier, this is also in line with R. The subtle difference is, that So, everything is good. |
I am not 100% sure if vectorz does it wrong or other libs, I am continuing to investigate this. However, here is the issue, illustrated with an example:
This is done via Incanter / core.matrix. As you can see the resulting V* are different as one is the transpose of the other. There are also differences in the signs, but they are not significant for SVD and we don't need to bother.
R returns the same data as the clatrix implementation:
Thus I think vectorz does it wrong. The other parts of the return value (U,S) are correct (aka the same) in all implementations and R.
The text was updated successfully, but these errors were encountered: