Labs

Bloom filter calculator

Pick items and a false-positive target, get bits and hashes, then overfill a toy filter and catch its false positives.

Size by
1/23

Empty filter: every bit is 0. Press play to insert the keys one by one, then test keys that were never inserted.

Inserted0Bits set0/96Predicted FP rate< 0.0001%0 keys in 96 bitsLookups: maybe0/00 false positives
Inserted (10):+4 more

Never inserted: pick one to see its bits

Of 1,000 never-inserted keys, 8 (0.8%) come back "maybe"; the formula predicts 1%.

Memory1.2 GB9.6 bits/key · exact set ≈ 100 GB
Hash functions7k = (m/n)·ln 2 = 6.64
FP rate as planned1%at n = 1B items
FP rate now1%1B items · 52% of bits set

x: items inserted ÷ n · y: false-positive rate (log)

1% false positives costs 9.6 bits and 7 hashes per key: 1B keys fit in 1.2 GB, against ~100 GB for an exact set. A "no" is certain, a "yes" means maybe, so check the real store when a wrong yes matters.

How it's calculated · assumptions

m = −n·ln p ÷ (ln 2)² · k = (m/n)·ln 2 · FP(x) ≈ (1 − e^(−k·x/m))^k

Size for the peak: at 2× the planned items the same filter answers 15.7% of new keys wrong.

Sizing formulas and the 1% → ~9.6 bits/key, 7 hashes figures are from the probabilistic-structures concept; FP(x) is the standard estimate for independent, uniform hashes (Broder & Mitzenmacher, Network Applications of Bloom Filters: A Survey, 2004). k is rounded to a whole number, so the rate at n can differ slightly from the target. ~100 B per key for an exact set is the concept's web-crawler assumption. Toy filter: same bits per key, k seeded hashes (FNV-1a with a murmur3 finalizer); keys are fixed strings, so it repeats.