I found that there\'re two versions of pinv()
function, which calculates the pseudo-inverse of a matrix in Scipy
and numpy
, the docume
I can't speak as to why there are implementations in both scipy and numpy, but I can explain why the behaviour is different.
numpy.linalg.pinv
approximates the Moore-Penrose psuedo inverse using an SVD (the lapack method dgesdd
to be precise), whereas scipy.linalg.pinv
solves a model linear system in the least squares sense to approximate the pseudo inverse (using dgelss
). This is why their performance is different. I would expect the overall accuracy of the resulting pseudo inverse estimates to be somewhat different as well.
You might find that scipy.linalg.pinv2
performs more similarly to numpy.linalg.pinv
, as it too uses an SVD method, rather than a least sqaures approximation.