0

For a matrix A, when using numpy version 1.16.4 to run numpy.linalg.inv(A.T.dot(A)) will result in: numpy.linalg.LinAlgError: Singular matrix. When using numpy version 1.21.6, no error raised. So I thought all I need is a newer numpy version. However, when using numpy version 1.24.x on the same matrix, the same error returns numpy.linalg.LinAlgError: Singular matrix.

My three questions are:

  1. Which/what updates are included between 1.16.4 and 1.21.6 that made numpy functional?
  2. numpy does not support backward capability? It seems that for this general library it should.
  3. When developing a project, which steps I should take to ensure I have a stable version?

If A.T.dot(A) is indeed a singular matrix, all I can think of is there might be a problem with decimal calculation precision. I am clueless here. Please help.

Jace Yang
  • 31
  • 1
  • 5
  • 3
    If the matrix is nearly singular, there's a fine line between saying it is singular, and giving some nearly meaningless inverse. Floatting point inverse (and determinant) is never exact. See this recent question comparing numpy and matlab, https://stackoverflow.com/questions/75998775/python-vs-matlab-why-my-matrix-is-singular-in-python?r=SearchResults&s=8%7C0.0000 – hpaulj Apr 26 '23 at 02:44
  • @hpaulj This is great info, thanks. Indeed the determinant of the matrix I'm using is very close to zero. I've also found out that the error is removed when I upgrade numpy from 1.18.5 to 1.19.0 (versions below 1.18.5 does not work, versions above 1.19.0 inclusive all work). Any insight into what might have changed in the new release? – Jace Yang Apr 26 '23 at 03:41

0 Answers0