Quiz 2
Registry Synced

Randomized SVD

190 words
1 min read

Reading compass

Now · 2.1 Motivation

Randomized SVD

2.1 Motivation

Computing the full SVD of a large matrix is O(mn2)O(mn^2) — infeasible for big data. Randomized SVD computes a near-optimal low-rank approximation much faster.

2.2 Algorithm

  1. Draw random projection matrix ΩRn×(k+p)\mathbf{\Omega} \in \mathbb{R}^{n\times (k+p)}
  2. Compute Y=AΩ\mathbf{Y} = \mathbf{A}\mathbf{\Omega}
  3. Compute QR factorization: Y=QR\mathbf{Y} = \mathbf{Q}\mathbf{R}
  4. Project: B=QTA\mathbf{B} = \mathbf{Q}^T\mathbf{A}
  5. Compute SVD of small matrix B=UBΣBVBT\mathbf{B} = \mathbf{U}_B \mathbf{\Sigma}_B \mathbf{V}_B^T
  6. Result: A(QUB)ΣBVBT\mathbf{A} \approx (\mathbf{Q}\mathbf{U}_B) \mathbf{\Sigma}_B \mathbf{V}_B^T

Python Implementation

python
import numpy as np
def randomized_svd(A, k, p=5):
    n, m = A.shape
    Omega = np.random.randn(m, k + p)
    Y = A @ Omega
    Q, _ = np.linalg.qr(Y)
    B = Q.T @ A
    U_B, S, Vt = np.linalg.svd(B, full_matrices=False)
    U = Q @ U_B[:, :k]
    return U[:, :k], S[:k], Vt[:k, :]
# Example
A = np.random.randn(1000, 500)
k = 10
U, S, Vt = randomized_svd(A, k)
print(f"Original: {A.shape}, Compressed: {U.shape} x {S.shape}")

2.3 Error Bound

E[AUkΣkVkTF](1+kp1)1/2AAkFE[||\mathbf{A} - \mathbf{U}_k \mathbf{\Sigma}_k \mathbf{V}_k^T||_F] \leq \left(1 + \frac{k}{p-1}\right)^{1/2} ||\mathbf{A} - \mathbf{A}_k||_F
Where Ak\mathbf{A}_k is the optimal rank-kk approximation and pp is the oversampling parameter. Join Discord PreviousConcentration InequalitiesNextSpectral Graph Theory
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.