Count-Min Sketch updates and estimates
medium 4 minIncrement one hashed counter in each row.
Video lesson · Chapter 1 of 5
Three rows follow the same request stream
Why the estimate is the smallest counter
1:15Reel
Theory
Read or listen first. About 1 min.
What it is
A Count-Min Sketch hashes a key into one counter in each row. A query addresses those same cells and uses their smallest value as its frequency estimate.
Query one endpoint across three hash rows
Why it exists
With nonnegative increments, collisions can add extra traffic to a counter. The smallest addressed counter contains the least contamination among those rows.
Words to know
- Collision
- Two different keys mapping to the same counter in a sketch row.
How it works
Step through the idea, or press Play.
Update rows. Hash the endpoint once per row and increment each selected counter.
Understand it
Worked example
Count-Min Sketch updates and estimates in practice
A known endpoint has candidate counters 17, 12 and 14. The estimate is 12. If its exact count is 10, at least the cleanest row still contains two increments from other keys.
Related case
Three questions for a tiny memory budget
A telemetry service needs to skip pointless disk reads, estimate traffic for a known endpoint, and count unique devices across regions. Each question allows a different error.
Estimate the union of observed identities.