![]() |
VOOZH | about |
Singular Value Decomposition (SVD) is a factorization method in linear algebra that decomposes a matrix into three other matrices, providing a way to represent data in terms of its singular values.
SVD helps you split that table into three parts:
Lets understand this with help of an example: Suppose you have a small table of people’s ratings for two movies,
Name | Movie 1 Rating | Movie 2 Rating |
|---|---|---|
Amit | 5 | 3 |
Sanket | 4 | 2 |
Harsh | 2 | 5 |
Here:
To perform Singular Value Decomposition (SVD) for the matrix , let's break it down step by step.
Step 1: Compute
First, we need to calculate the matrix (where is the transpose of matrix ):
Now, compute :
Step 2: Find the Eigenvalues of
To find the eigenvalues of , we solve the characteristic equation:
Thus, the eigenvalues are and . These eigenvalues correspond to the singular values and , since the singular values are the square roots of the eigenvalues.
Step 3: Find the Right Singular Vectors (Eigenvectors of )
Next, we find the eigenvectors of for and .
For :
Solve :Row-reduce this matrix to:
The eigenvector corresponding to is:
For :
Solve :
The eigenvector corresponding to is:For the third eigenvector :
Since v3 must be perpendicular to and , we solve the system and , leading to:
Step 4: Compute the Left Singular Vectors (Matrix U)
To compute the left singular vectors U, we use the formula . This results in:
Step 5: Final SVD Equation
Finally, the Singular Value Decomposition of matrix is:
Where:
Thus, the SVD of matrix is:
This is the Result SVD matrix of matrix A.
1. Calculation of Pseudo-Inverse (Moore-Penrose Inverse)
2. Solving a Set of Homogeneous Linear Equations
3. Rank, Range, and Null Space
The rank, range, and null space of a matrix can be derived from its SVD.
4. Curve Fitting Problem
Singular Value Decomposition can be used to minimize the least square error in the curve fitting problem. By approximating the solution using the pseudo-inverse, we can find the best-fit curve to a given set of data points.
5. Applications in Digital Signal Processing (DSP) and Image Processing
In this code, we will try to calculate the Singular value decomposition using Numpy and Scipy. We will be calculating SVD, and also performing pseudo-inverse. In the end, we can apply SVD for compressing the image
Output:
[[ 3 3 2]
[ 2 3 -2]]
---------------------------
U: [[-0.7815437 -0.6238505]
[-0.6238505 0.7815437]]
---------------------------
Singular array [5.54801894 2.86696457]
---------------------------
V^{T} [[-0.64749817 -0.7599438 -0.05684667]
[-0.10759258 0.16501062 -0.9804057 ]
[-0.75443354 0.62869461 0.18860838]]
--------------------------
# Inverse
array([[ 0.11462451, 0.04347826],
[ 0.07114625, 0.13043478],
[ 0.22134387, -0.26086957]])
---------------------------
The output consists of subplots showing the compressed image for different values of r (5, 10, 70, 100, 200), where r represents the number of singular values used in the approximation. As the value of r increases, the compressed image becomes closer to the original grayscale image of the cat, with smaller values of r leading to more blurred and blocky images, and larger values retaining more details.