Calculating the Pseudo Inverse of a Matrix

To evaluate the (Moore-Penrose) pseudo-inverse of a matrix, scipy.linalg.pinv is used.

Syntax: scipy.linalg.pinv(a , cond , rcond , return_rank , check_finite)

Parameters:

  • a: It is the Input Matrix.
  • cond, rcond (Optional): It is the cutoff factor for small singular values.
  • return_rank (Optional): It returns the effective rank of the matrix if the value is True.
  • check_finite (Optional): It checks if the input matrix consists of only finite numbers.

Returns:

  • scipy.linalg.pinv returns the pseudo-inverse of the input matrix.

Example: The scipy.linalg.pinv takes a matrix x to be pseudo-inverted. It returns the pseudo-inverse of matrix x and the effective rank of the matrix.

Python




# Import the required libraries
from scipy import linalg
import numpy as np
  
# Initializing the matrix
x = np.array([[8 , 2] , [3 , 5] , [1 , 3]])
  
# finding the pseudo inverse of matrix x
y = linalg.pinv(x)
print(y)


Output:

SciPy Linear Algebra – SciPy Linalg

The SciPy package includes the features of the NumPy package in Python. It uses NumPy arrays as the fundamental data structure. It has all the features included in the linear algebra of the NumPy module and some extended functionality. It consists of a linalg submodule, and there is an overlap in the functionality provided by the SciPy and NumPy submodules.

Let’s discuss some methods provided by the module and its functionality with some examples.

Similar Reads

Solving the linear equations

The linalg.solve function is used to solve the given linear equations. It is used to evaluate the equations automatically and find the values of the unknown variables....

Calculating the Inverse of a Matrix

...

Calculating the Pseudo Inverse of a Matrix

The scipy.linalg.inv is used to find the inverse of a matrix....

Finding the Determinant of a Matrix

...

Singular Value Decomposition

To evaluate the (Moore-Penrose) pseudo-inverse of a matrix, scipy.linalg.pinv is used....

Eigenvalues and EigenVectors

...

Calculating the norm

The determinant of a square matrix is a value derived arithmetically from the coefficients of the matrix. In the linalg module, we use the linalg.det() function to find the determinant of a matrix....

More Matrix Functions

...