HyperLogLog registers and uncertainty 00:00:01 One visitor returns through another device signal A colleague signs in on a phone and then a laptop. The analytics report says two devices. Is that an error? It depends on whether our metric promised devices or people. For this experiment count stable device identifiers during one day. Two devices contribute two distinct IDs even if they have one owner. Repeated visits from the same device should count only once. A sketch cannot repair a weak identity definition. Cookie renewal, shared logins or inconsistent normalization change the apparent set before any probabilistic mathematics happens. First choose whether the subject is a logged-in account, a device, or a browser cookie. The same human can own two devices, and two people can share one account. The estimator counts the identifiers you actually supply. 00:00:52 Turn a hash into two observations In this worked configuration, hash the identifier and use ten leading bits to select one of a thousand twenty-four registers. The remaining bits provide independent-looking evidence about rarity. Count the leading zero bits in that suffix, then add one. Under a uniformly distributed hash, a long run is progressively less likely on a single draw. The rank records the position of the first one in the suffix, with a convention for a suffix containing no one. A large observed rank is evidence about many opportunities for a rare event. Assume the suffix starts zero, zero, one. There are two leading zero bits, so the rank is three. It would be a mistake to include zeros from the prefix because those bits already selected the register. 00:01:38 Keep a maximum, not a visit tally I update the register only if the new rank is greater than the current value, keeping the highest evidence. The same visitor ID always maps to the same register and produces the same rank every time it appears. One unusually high rank is noisy evidence. Combine the register pattern using the estimator’s formula; an ordinary arithmetic average of ranks is not the HyperLogLog estimator. Start the chosen register at two. A rank of three raises it to three. Send the same identifier again and it stays three. A different identifier with rank one in the same register also leaves it unchanged. 00:02:16 Combine many small witnesses The classic raw estimate combines powers of two from the register ranks using a harmonic-mean-style calculation and a calibration constant. Implementations may apply separate corrections, particularly at low cardinality. In the usual operating range, the approximate relative standard error is one point zero four divided by the square root of the register count. For a thousand twenty-four registers, that is about three point two five percent. Relative standard error summarizes variability over suitable randomized trials. It does not guarantee every daily number is within three point two five percent, and it is not automatically a ninety-five percent interval. Precision trades memory for accuracy gradually. Under the large-range approximation, doubling the number of registers improves standard error by a factor of about the square root of two. Halving it takes roughly four times as many registers. 00:03:18 Choose when an estimate is enough For analytics, a 3.25 percent uncertainty is acceptable, but billing needs exact counts instead. We choose the number of registers and the time window before we start counting, based on required precision. We never reconstruct the list of visitors from register values—only the total count matters. Check sketches on test traffic where the true distinct set is affordable to keep. Compare many independent samples or runs. A single fortunate exact estimate does not demonstrate zero error across the application.