English translation
Define matrix A
You can compute singular values manually by starting from the eigenvalues of . In practice, engineers delegate this task to numerical libraries—but understanding the underlying derivation helps interpret results correctly.
I verify that singular values are non-negative and typically ordered in descending order. If their ordering is incorrect, low-rank approximations will also be wrong.
In the previous article, we introduced the concept of Singular Value Decomposition (SVD) and discussed why it plays such a pivotal role in data science and machine learning. This article dives deeper into how singular values are computed—equipping you with mastery of this core technique and laying a solid foundation for subsequent applications.
1. Theoretical Foundation
Singular Value Decomposition (SVD) is a matrix factorization method that decomposes any matrix into the product of three matrices. Specifically, if is an matrix, it can be expressed as:
When computing singular values, consider: transpose–product relationships, eigenvalues, square-root mapping, singular vectors, dimensional changes, and numerical stability.
where:
- is an orthogonal matrix;
- is an diagonal matrix containing the singular values of ;
- is the transpose of , and is an orthogonal matrix.
Singular values represent a kind of “signature” of matrix , reflecting its structural properties and information content. To extract them from , follow these steps:
- Compute and .
- Obtain the eigenvalues of both matrices.
- Take the non-negative square roots of those eigenvalues to yield the singular values.
2. Step-by-Step Computation of Singular Values
To compute singular values, proceed as follows:
Step 1: Compute
Given a matrix , first compute its transpose , then multiply it by to obtain . The result is an matrix.
Step 2: Compute Eigenvalues
Next, compute the eigenvalues of . If is , then is , and its eigenvalues can be found by solving the characteristic polynomial.
Step 3: Compute Singular Values
Each singular value is the non-negative square root of the corresponding eigenvalue:
Apply this to all eigenvalues to obtain the full set of singular values.
3. Worked Example
Let’s demonstrate singular value computation using a concrete matrix. Consider:
“The Computation of Singular Values in SVD” can be read through four lenses: scenario, concept, action, and outcome. First align these four elements, then revisit parameters, code, or workflows in the main text.
Detailed Computation Steps
-
Compute :
So,
-
Compute eigenvalues: Solve
where is the identity matrix. Solving yields eigenvalues:
-
Compute singular values:
Thus, the singular values of are approximately and .
4. Python Implementation
Using NumPy, we can implement this computation concisely:
import numpy as np
# Define matrix A
A = np.array([[1, 2], [3, 4], [5, 6]])
# Compute SVD
U, s, VT = np.linalg.svd(A)
# Output singular values
print("Singular values:", s)
Running this code yields:
Singular values: [9.52551809 0.51449576]
After studying “The Computation of Singular Values in SVD”, try applying it to your own scenario—pay close attention to whether inputs, processing steps, and outputs align coherently.
To apply “The Computation of Singular Values in SVD” to your own task, begin by narrowing the scope—focus on validating just one critical decision point.
Summary
This article thoroughly explains how singular values are computed—including theoretical foundations, a step-by-step worked example, and a practical Python implementation. This knowledge is essential for deeply understanding SVD and its applications. In the next article, we’ll explore real-world use cases of SVD—for instance, in recommendation systems and image processing.
Stay tuned for our ongoing tutorial series—and deepen your grasp of linear algebra’s vital role in AI!
Continue