Estimating Distinct Viewers From the Smallest Hash Values
Last updated: November 29, 2026
Quick Overview
A Reels analytics service must estimate distinct viewers per video over streams with billions of events, keeping only a small fixed amount of memory per video. Explain the k-minimum-values estimator, why (k - 1) divided by the k-th smallest hash is unbiased, and how its error scales with k.
Meta
November 29, 20260
0
0 solved
A Reels analytics service must estimate distinct viewers per video over streams with billions of events, keeping only a small fixed amount of memory per video. Explain the k-minimum-values estimator, why (k - 1) divided by the k-th smallest hash is unbiased, and how its error scales with k.
Meta's analytics infrastructure uses sketches for distinct counts at scale, and engineers on these systems should understand the statistics behind them. This screen question checks order statistics of uniforms, an unbiasedness argument, and practical trade-offs like merging sketches.
What the Interviewer Expects
- Map hashed IDs to i.i.d. uniforms and note duplicates hash identically
- Explain why the k-th smallest of D uniforms is Beta distributed
- Show E[(k-1)/U_(k)] = D
- Derive relative standard error about 1/sqrt(k-2)
- Explain merge by union of sketches and compare with HyperLogLog
Key Topics to Cover
How to Approach This
- Define your hypotheses (H0 and H1) clearly before performing any test.
- Calculate required sample size BEFORE running an experiment, using power analysis.
- Remember the Central Limit Theorem: sample means become approximately normal with large n.
- Watch for Simpson's paradox. Always segment data by key dimensions.
- Distinguish between statistical significance and practical significance.
Possible Follow-up Questions
- How do you estimate the distinct count of the intersection of two videos' audiences?
- Why does this estimator struggle for small intersections?
- How would you choose k for a 1% target error?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Browse Statistics QuestionsSample Answer
Clarify
- Stream of viewer IDs with repeats; true distinct count .
- Hash maps IDs to , behaving like i.i.d. uniforms across distinct IDs.
- Keep only the smallest distinct hash values; memo...
Approach
Repeats of an ID give the same hash, so the set of hash values is i.i.d. draws. With points, the -th smallest and . A...