-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Bug in pinv? #214
Comments
For what it is worth, I tested against
the docs for these routines say that |
The change is intentional. The default inverse condition number threshold was changed in 0.4; see Issue JuliaLang/julia#8859. julia> pinv(S, 1e-9) #On 0.4, basically reproduces the 0.3.8 answer
4x4 Array{Float64,2}:
0.500222 -0.00332121 -6.62205 0.94274
-0.00332121 2.26771e-5 0.0423813 -0.00603419
-6.62205 0.0423813 93.8221 -13.3545
0.94274 -0.00603419 -13.3545 1.90086 I suspect that numpy uses different regularizations in Note that your matrix has a condition number ~1e12 julia> cond(S)
8.461070041485869e11
julia> svdvals(S)
4-element Array{Float64,1}:
4.59266e6
30.6059
0.010396
5.42798e-6 and so the default in 0.3.8 produced essentially a rank 3 pseudoinverse. The default threshold in 0.4 is more conservative and produces a rank 4 pseudoinverse. julia> svdvals(pinv(S, 1e-9))
4-element Array{Float64,1}:
96.1906
0.0326735
2.17739e-7
4.10145e-16
julia> svdvals(pinv(S))
4-element Array{Float64,1}:
1.8423e5
96.1906
0.0326735
2.17739e-7 |
Thanks for the edited comment. Not being a numerical linear algebra expert myself, what does this mean for routines that use |
There is no general answer to your question, unfortunately. It depends on what you want to use the pseudoinverse for. |
The pseudo-inverse is not continuous when the rank of the matrix changes. The reason your result changes so much is that the rank estimate for your matrix changes between 0.3 and 0.4. To summarize the discussion that @jiahao links to, there exist two kinds of numerical rank deficient matrices: the first kind has a very well determined rank, say |
OK great, thank you both for the tips. |
Suppose we had this matrix:
Then consider the following code from v0.4 (master branch, 5-13-15):
Now on the latest 0.3.8 release:
Is there a reason why
pinv
gives such a different answer for the exact same input matrix?The text was updated successfully, but these errors were encountered: