May-04-2019, 10:42 AM
This matrix is of shape (30, 20). Therefore, it couldn't be inverted in traditional sense. The main question here is why do you need to invert such matrix? May be you need to solve a system of linear equation with that matrix, e.g.
Even if the matrix has insufficient rank, e.g.
So, least squares solution could be obtained as follows:
b is known vector of shape
Ax = b
. In this case, your system is probably overdetermined and has no solution in classical sense, but it could be solved in least squares sense. Even if the matrix has insufficient rank, e.g.
rank(A) < 20
, you can obtain least squares solution using Moore-Penrose inversion. It is implemented in numpy
: np.linalg.pinv
.So, least squares solution could be obtained as follows:
x = np.linalg.pinv(A) @ b
, whereb is known vector of shape
(30, 1)
; you can use np.dot(np.linalg.pinv(A), b)
instead of @
(if you work with Py < 3.5).