Bloom Filter X-Ray — Watch False Positives Appear
See every salted hash strike the bit array, then run a deterministic experiment until a value that was never added lights up as “maybe present.”
What this is
Bloom Filter X-Ray is a deterministic, single-file lab for seeing a probabilistic membership test from the inside. Choose the bit count and hash count, load a seeded dataset or add your own values, and watch every salted hash land on the array. Queries are checked against a private exact ledger only so the lab can label the filter’s answer as a true positive, true negative, false positive, or an invariant-breaking false negative.
Why this is mind-blowing
A Bloom filter never stores the values it answers questions about. It stores only shared bits, yet one zero can prove a value was never added. Increase occupancy and unrelated values begin covering one another’s landing positions until an absent probe looks present. The experiment counts only known-absent probes, compares the measured collision rate with (1 - exp(-kn/m))^k, and makes the gap between a mathematical expectation and a finite deterministic run visible.
Prompt
Build “Bloom Filter X-Ray — Watch False Positives Appear,” an accurate, polished, single-file probabilistic-data-structure lab. Visualize the bit array and each hash landing position. Let users choose bit count and hash count, add/query values, generate deterministic datasets, run an experiment, and compare measured false-positive rate with the theoretical estimate (1 - exp(-kn/m))^k. Clearly distinguish true positive, true negative, false positive, and explain why false negatives should be zero. Show occupancy, n/m, optimal k, measured/theoretical error, and an event trace. Include reset, deterministic seed, autoplay/pause/step experiment, keyboard/touch/accessibility, responsive phone layout, reduced motion. Inline HTML/CSS/JS only, no external assets/deps/network/build, <=160KB.
Paste into your favorite AI and adapt it to your context.
What I learned shipping it
- A Bloom filter’s “no” is stronger than its “yes”: one zero landing proves absence, while all-one landings only establish possible membership.
- Measured false-positive rate is meaningful only when its denominator contains known-absent queries and the filter population stays fixed for the run.
- The theoretical curve assumes uniform independent hashes; an X-ray of actual landings makes collisions, occupancy, and finite-sample error impossible to hand-wave.