Quiz 2
Registry Synced

Matrix Sketching

127 words
1 min read

Reading compass

Now · 8.1 Frequent Directions

Matrix Sketching

8.1 Frequent Directions

Maintain a sketch of ARn×dA \in \mathbb{R}^{n \times d} that approximates its covariance structure. Processes rows one at a time, keeping only 2k2k rows.
python
import numpy as np
def frequent_directions(A, k):
    n, d = A.shape
    sketch = np.zeros((2*k, d))
    for i in range(n):
        sketch[0] = A[i]
        U, S, Vt = np.linalg.svd(sketch, full_matrices=False)
        delta = S[k-1]**2
        S = np.sqrt(S**2 - delta)
        sketch = np.diag(S[:k]) @ Vt[:k]
    return sketch

8.2 Count-Min Sketch

Purpose: Approximate frequency counts in a stream. Structure: d×wd \times w table of counters, dd hash functions hjh_j mapping items to [w][w]. Update: For item ii, increment C[j][hj(i)]C[j][h_j(i)] for j=1,,dj = 1, \dots, d. Query: f^i=minjC[j][hj(i)]\hat{f}_i = \min_j C[j][h_j(i)] (always an overestimate). Join Discord PreviousRandomized RegressionNextFrequency Estimation
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.