Every second, internet routers log billions of packets, stock exchanges record millions of trades, and search engines process hundreds of millions of queries. Storing that entire stream is hopeless. Even reading it more than once is often too slow. Yet analysts need to answer questions about the stream: which items dominate? How skewed is the distribution?
The AMS sketch — named after Noga Alon, Yossi Matias and Mario Szegedy, who introduced it in 1996 — solves a central instance of this problem. It estimates the second frequency moment , where is the number of times item appears. captures how concentrated the stream is: a perfectly uniform stream of distinct items has , while a stream dominated by one repeated item has .
The algorithm needs only a constant number of counters — space logarithmic in the universe size — and makes a single pass through the data. The price is a small probabilistic error, but with high probability the estimate is within a factor of of the truth.
This was one of the founding results of the field of streaming algorithms, and it earned Alon, Matias and Szegedy the 2005 Gödel Prize.
Comments
Loading comments...