FAILURE MAP
← Case archive

FA-73237 / Probabilistic sketches / Member archive

K-minimum-values distinct counting: repeated hashes occupy sketch slots · case 02

A stream that repeats one small hash looks like it has few distinct values beyond it, inflating the estimate.

Member previewVariant 2 · 3 implementations · 8 checks per implementation

Case contract

Input {k, a, b} lists of 32-bit hashes. Each sketch keeps the k smallest distinct hashes. With fewer than k kept values the count is exact (their number); otherwise the estimate is round((k-1) * 2^32 / v_k) with v_k the k-th smallest. The union sketch is the k smallest distinct values of both kept sets. The intersection is exact when the union has fewer than k values, else round(c/k * union estimate) where c counts union-sketch values kept by both inputs. Return [estA, estB, estUnion, estIntersection].

Why this case matters

KMV sketches power approximate COUNT(DISTINCT) with set operations in analytics engines; the unbiased (k-1)/v_k form and the union rule are easy to get subtly wrong.

One recorded failure

Sample boundary fixture

This sample comes from the broken implementation of a controlled reproducer.

Boundary fixtureActualExpectedOutcome
streams 0 k=4[21, 12, 13, 6][12, 12, 13, 6]Failed

MEMBER ARCHIVE

The complete case is available to members.

This record includes three runnable implementations, regression fixtures, execution results, and source hashes.

Member access is invitation-based. Sign in with your invited account to inspect the sources.

Sign in to the archive ↗