The difference of pseudo-inverse between SciPy and Numpy

后端 未结 1 1381
情深已故
情深已故 2021-01-04 18:48

I found that there\'re two versions of pinv() function, which calculates the pseudo-inverse of a matrix in Scipy and numpy, the docume

相关标签:
1条回答
  • 2021-01-04 19:25

    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.

    0 讨论(0)
提交回复
热议问题