Estimating Daily Distinct Users From the Smallest Hash Value

Last updated: November 29, 2026

Quick Overview

You hash every user ID seen today to a uniform value in (0,1) and keep only the minimum. Show how to estimate the number of distinct users from it, why a single minimum is too noisy, and how keeping the k smallest fixes that.

Google
Statistics & Math
Data Engineer
Google
November 29, 2026
Data Engineer
Onsite
Statistics & Math
Hard

0

0

0 solved


You hash every user ID seen today to a uniform value in (0,1) and keep only the minimum. Show how to estimate the number of distinct users from it, why a single minimum is too noisy, and how keeping the k smallest fixes that.

Approximate distinct counting underpins Google analytics systems and BigQuery's APPROX_COUNT_DISTINCT. This question checks whether a candidate can derive the estimator from order statistics, quantify its variance, and explain the k-minimum-values sketch.

What the Interviewer Expects
  • Explain that duplicates hash to the same value, so only distinct count n matters
  • Derive E[min] = 1/(n+1)
  • Show 1/min - 1 has huge variance (infinite mean)
  • Use the k-th smallest value with estimator (k-1)/U_(k)
  • Relative error about 1/sqrt(k)
Key Topics to Cover
order statistics
distinct counting
k minimum values
sketches
estimator variance
How to Approach This
  1. Define your hypotheses (H0 and H1) clearly before performing any test.
  2. Calculate required sample size BEFORE running an experiment, using power analysis.
  3. Remember the Central Limit Theorem: sample means become approximately normal with large n.
  4. Watch for Simpson's paradox. Always segment data by key dimensions.
  5. Distinguish between statistical significance and practical significance.
Possible Follow-up Questions
  • How does HyperLogLog improve memory per unit of accuracy compared with KMV?
  • How do you merge sketches from two days or two datacenters?
  • How would you estimate the size of an intersection of two user sets?
  • What happens if the hash function is not close to uniform?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Browse Statistics Questions
Sample Answer
Clarify

A uniform hash maps each distinct user to an independent Uniform(0,1) value; repeated events from the same user give the same hash. With nn distinct users, the minimum U(1)U_{(1)} is the minimum of nn...

Approach

Use the distribution of order statistics of uniforms. The kk-th smallest of nn uniforms is Beta(k,n−k+1k, n - k + 1). Invert its expectation, then check the variance....


Submit Your Answer
Markdown supported