Beyond Enumerable: Counting Distinct with HyperLogLog

Counting distinct values exactly means remembering all of them. HyperLogLog does it in 16 kilobytes. This post builds from coin flips to bitmaps to the algorithm Redis uses behind PFCOUNT.