Singular matrix issue with Numpy

前端 未结 4 628
灰色年华
灰色年华 2021-01-01 10:39

I am trying to multiply a vector(3 by 1) by its transpose(1 by 3). I get a (3 by 3) array but I cannot get its inverse. Any idea why?

import numpy as np

c=a         


        
相关标签:
4条回答
  • 2021-01-01 11:10

    As it was already mentioned in previous answers, your matrix cannot be inverted, because its determinant is 0. But if you still want to get inverse matrix, you can use np.linalg.pinv, which leverages SVD to approximate initial matrix.

    0 讨论(0)
  • 2021-01-01 11:14

    The matrix you pasted

    [[   1,    8,   50],
     [   8,   64,  400],
     [  50,  400, 2500]]
    

    Has a determinant of zero. This is the definition of a Singular matrix (one for which an inverse does not exist)

    http://en.wikipedia.org/wiki/Invertible_matrix

    0 讨论(0)
  • 2021-01-01 11:22

    By definition, by multiplying a 1D vector by its transpose, you've created a singular matrix.

    Each row is a linear combination of the first row.

    Notice that the second row is just 8x the first row.

    Likewise, the third row is 50x the first row.

    There's only one independent row in your matrix.

    0 讨论(0)
  • 2021-01-01 11:30

    Use SVD or QR-decomposition to calculate exact solution in real or complex number fields:

    numpy.linalg.svd numpy.linalg.qr

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