Every item id is hashed with a 32-bit avalanching hash. The low bits of the hash pick one of m registers; the remaining bits are scanned for their longest run of leading zeros, ρ. Each register keeps only the largest ρ it has ever seen for its bucket — a single byte of state per bucket, no matter how many times that bucket is hit.
The cardinality estimate is the harmonic mean of 2^register across all m buckets, scaled by a bias-correction constant α_m:
E = α_m · m² / Σ 2^(-register[i])
- Small-range correction (linear counting) kicks in when the raw estimate is low and empty registers remain:
E = m · ln(m / zeros)
Accuracy. For raw HyperLogLog the relative standard error is σ ≈ 1.04/√m (Flajolet et al. 2007): m=64 gives 13 %, m=1024 gives 3.3 %. The chart plots the signed error of the live estimate; about 68 % of points should sit inside the 1σ band and 95 % inside 2σ. The Self-check button repeats this with 100 independent streams of 5,000 distinct ids and compares the measured RMS error with 1.04/√m, and also checks the estimator against exact counts.
Simplifications. A 32-bit hash is used (fine below ~108 items; no large-range correction), registers are stored as plain numbers instead of packed 6-bit fields, and no HLL++ bias tables are applied, so the first few hundred items rely on linear counting (m·ln(m/V)) where V is the number of empty registers.
The "Repeat bias" slider controls how fast the underlying population of unique ids grows relative to the stream — low bias means almost every item is brand new, high bias means the stream keeps re-hitting a small pool, similar to a popular page getting repeat visits.