Size a Bloom filter, HyperLogLog or count-min sketch, and see which direction each one is wrong in before you choose between them.
A filter sized for a million and filled with ten million is far worse than its stated rate.
0.01 is one in a hundred. There is no zero: that would need infinite memory.
A Bloom filter can say “probably present” about something absent. It can never say “absent” about something present. That asymmetry is why it is safe in front of a database: a false positive costs one wasted lookup and nothing else.
9,585,059 bits, 7 hash functions. The ideal count is 6.64, and rounding it is why the achieved rate is 1.00% rather than exactly 1.00%.
An exact set of the same items would need roughly 45.8 MB — about 40× more.
Probabilistic Structure Sizing runs entirely on your device — this is arithmetic in your browser, and nothing you type is sent anywhere.
You’re on the Free plan. Compare plans
These three structures make the same bargain: answer a question in a fraction of the memory an exact answer needs, and be wrong in one direction at a known rate. The bargain is only worth taking if you know the rate, and the formulas are easy to apply to the wrong variable.
The direction of the error matters more than its size, and it is what people get backwards. A Bloom filter never reports absent for something present — a false negative is impossible — which is exactly what makes it safe in front of a database: a false positive costs one wasted lookup and nothing else. A count-min sketch never under-counts, which makes it safe for rate limiting and wrong for anything needing the opposite guarantee.
For a Bloom filter, enter how many distinct items you expect and the false-positive rate you can live with. You get the bit count, the memory, the optimal number of hash functions, and the rate you will actually achieve once that count is rounded to a whole number — which is not quite the one you asked for. A table shows what other rates would cost, because the shape of that curve is the decision.
HyperLogLog takes no item count at all, and that is the surprising part: memory does not depend on cardinality. Precision 14 counts a thousand distinct items and a billion in the same 12 KB, to the same accuracy.
Everything here is arithmetic over the standard formulas in double precision. Nothing is sampled, estimated or simulated.
Because the optimal number of hash functions is almost never a whole number, and a filter cannot use 6.6 of them. Rounding it moves the achieved rate slightly either way. Both numbers are shown so the difference is visible rather than hidden.
The false-positive rate rises sharply — it is exponential in the fill ratio, not linear. A filter sized for a million and given ten million is far worse than its stated rate, not ten times worse. Size for the maximum you expect, not the average.
Because its memory does not depend on that. It holds a fixed number of registers whatever you feed it, which is the property that makes it useful: you can count distinct visitors across a year in twelve kilobytes.
A Bloom filter answers whether something was seen. A count-min sketch answers roughly how often, which is what you need for rate limiting or finding heavy hitters. It costs more memory for the same number of keys, and it only ever over-counts.
No. This is arithmetic in your browser. Nothing you type leaves the page.
If a tool here saved you some time, you can put something towards the hosting.Buy me a coffee, on Ko-fi, opens in a new tab