Interactive visualizations of HyperLogLog, Balls-into-Bins, and the Hat Problem
HyperLogLog estimates the number of distinct elements using only O(loglogn) space. Each item is hashed, and we compute ρ — the position of the leftmost 1-bit — like counting coin flips until heads (Pr[ρ=k]=2−k). The first p bits select one of m=2p=16 registers, each storing the max ρ seen. Since max{ρ}≈log2n, the harmonic-mean estimator n^=αmm2/∑2−Rj recovers cardinality with relative error ≈1.04/m.
Estimated cardinality
0
Actual unique items
0
0 total insertions
Relative error
proof
0%
Theoretical: ≈26.0%
m1.04=161.04
Space used
16 regs (10 bytes)
O(m)=O(2p) registers
HyperLogLog: Union & Intersection
HyperLogLog registers are mergeable: the element-wise max gives the sketch for the union. For intersection, we maintain bottom-k MinHash sketches (the k smallest hash values per server) to estimate Jaccard similarity, then compute ∣A∩B∣≈J^(A,B)⋅∣A∪B∣.