10-605 · Randomized algorithms
A countmin sketch keeps t real vectors r1,…,rt
of length m, one per hash function hi.
Increment(x,v) adds v to ri[hi(x)] in every row;
Retrieve(x) returns the minimum of those t cells. Collisions can only
add to a cell, so the estimate is never too small — and it is wrong only if
x collides in every row. Step through a stream of cartoon characters below,
and click any name to Retrieve it.
Increment(x, v) calls Increment.Initialize(ε, δ): m = ⌈e/ε⌉; t = ⌈ln(1/δ)⌉ r1 = … = rt = 0mIncrement(x, v): for i = 1, …, t: ri[hi(x)] = ri[hi(x)] + vRetrieve(x): return min(r1[h1(x)], …, rt[ht(x)])
| x | a[x] | Retrieve | error |
|---|
Click a row to Retrieve it. Grey rows were never incremented
(a[x] = 0); a nonzero Retrieve for them is a Bloom-filter-style false positive.
Cormode–Muthukrishnan: with m = ⌈e/ε⌉ and t = ⌈ln 1/δ⌉, Retrieve(x) ≥ a[x] always, and Retrieve(x) ≤ a[x] + ε‖a‖1 with probability ≥ 1 − δ.