HyperLogLog registers and uncertainty
medium 4 minSplit a uniform hash into a register address and remaining bits.
Video lesson · Chapter 1 of 5
One visitor returns through another device signal
What a run of zeros tells us about visitors
1:25Reel
Theory
Read or listen first. About 1 min.
What it is
HyperLogLog splits a hash into an address and a suffix. The address selects a small register. The length of the initial zero run in the suffix determines the observed rank.
Decode one device hash
Why it exists
Seeing an identity again repeats the same observation. New identities occasionally produce unusually large ranks, which let an estimator infer cardinality using bounded memory.
Words to know
- Rank
- The number of leading zeros in the hash suffix plus one, within the available hash width.
How it works
Step through the idea, or press Play.
Hash a device. Use part of the hash to select a register.
Understand it
Worked example
HyperLogLog registers and uncertainty in practice
Seeing a device repeatedly gives the same hash and cannot keep increasing its register. Many distinct devices spread over registers and occasionally produce larger ranks.
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.