numpy.linalg.pinv(a,rcond=1e-15)[source]¶Compute the (Moore-Penrose) pseudo-inverse of a matrix.
Calculate the generalized inverse of a matrix using itssingular-value decomposition (SVD) and including alllarge singular values.
| Parameters: | a : (M, N) array_like
rcond : float
|
|---|---|
| Returns: | B : (N, M) ndarray
|
| Raises: | LinAlgError
|
Notes
The pseudo-inverse of a matrix A, denoted
, isdefined as: “the matrix that ‘solves’ [the least-squares problem]
,” i.e., if
is said solution, then
is that matrix such that
.
It can be shown that if
is the singularvalue decomposition of A, then
, where
areorthogonal matrices,
is a diagonal matrix consistingof A’s so-called singular values, (followed, typically, byzeros), and then
is simply the diagonal matrixconsisting of the reciprocals of A’s singular values(again, followed by zeros).[R47]
References
| [R47] | (1,2) G. Strang,Linear Algebra and Its Applications, 2nd Ed., Orlando,FL, Academic Press, Inc., 1980, pp. 139-142. |
Examples
The following example checks thata*a+*a==a anda+*a*a+==a+:
>>>a=np.random.randn(9,6)>>>B=np.linalg.pinv(a)>>>np.allclose(a,np.dot(a,np.dot(B,a)))True>>>np.allclose(B,np.dot(B,np.dot(a,B)))True