Why Thorup and Zhang built the sparse sketch
- Both authors were at AT&T Research, which operates a very large number of routers
42:28. - The vector:
n= number of destination IP addresses;xᵢ= how many packets destinationireceived in a time window. Deletions were not even needed42:51. - Why L2:
‖x‖₂²measures spikes / skewness in the traffic distribution — used as part of a system for detecting denial-of-service attacks42:51,43:37. - Why not L∞: the infinity norm measures spikes best, but no space-efficient streaming algorithm for
‖x‖_∞exists. The largestpfor which a space-efficientLpalgorithm exists isp = 2— a known, proven boundary43:17,43:37. - Why speed mattered so much: the sketch runs on the router at network line rate. At 1% error,
1/ε² = 100² = 10,000— so the sparse construction removed a factor of 10,000 from their update cost44:03.
Cosine similarity between documents
- Contrast with Jaccard similarity from a problem set, which used the minimum of a hash function to compare sets (e.g. web pages)
44:27,44:48. - Setup:
xᵢ= number of occurrences of wordiin documentx; normalizexto unit norm so all documents lie on a sphere44:48,45:32. - Similarity of two documents = the angle
θbetween them; small angle ⇒ similar45:56. - The trick: forget streaming — treat
Πxas a compression (a "sketch") of the document, and estimate⟨x, y⟩ = cos θby⟨Πx, Πy⟩with the sameΠ46:23,46:49. - Guarantee: an expectation/variance analysis gives additive
εerror on the true dot product with probability1 − δ47:16.
Norms ⇒ dot products, via the polarization identity
‖a − b‖² = ‖a‖² + ‖b‖² − 2⟨a,b⟩, hence⟨a,b⟩ = (‖a‖² + ‖b‖² − ‖a−b‖²)/247:40.- Apply with
a = Πx,b = Πy. SinceΠpreserves the squared norms ofx,y, andx − y(which is just another vector), each of the three terms is preserved up toε48:15,48:43. - Takeaway used repeatedly for the rest of the lecture: preserving L2 norms ⇒ preserving dot products ⇒ preserving cosines of angles
48:43,48:58.