On this page
Picture a sign-up form that must tell you instantly whether "aarav_2009" is taken, out of a million names already registered, without reading the full list from disk. A Bloom filter is a small bit array kept in memory that answers "definitely not" or "probably yes", and it can be wrong in only one direction.
What is a Bloom filter?
Burton Bloom described the idea in 1970 in Communications of the ACM, showing that if you accept a small fraction of wrong "yes" answers, you can use a much smaller hash area. The standard description, from Broder and Mitzenmacher's survey of Bloom filters, goes like this:
Start with an array of m bits, all set to 0.
Choose k hash functions, each turning an item into a position from 1 to m.
To add an item, hash it k times and set those k bits to 1.
To check an item, hash it k times. If any of those bits is 0, the item was never added. If all are 1, it was probably added.
A Bloom filter never gives a false negative, because an item you added always finds its own k bits set. It can give a false positive, when other items happen to have set all k bits of a newcomer.
How do you derive the Bloom filter false positive rate?
Follow a single bit. Each hash lands on it with probability 1/m, so each hash misses it with probability 1 − 1/m. After n items there have been kn hashes, so the bit is still 0 with probability (1 − 1/m)^(kn).
Because (1 − 1/m)^m is close to 1/e when m is large, that probability is about e^(−kn/m). It is the same limit that powers the Poisson approximation to the binomial.
So any given bit is 1 with probability about 1 − e^(−kn/m). An item that was never added is a false positive only if all k of its bits are 1.
The false positive rate of a Bloom filter is f ≈ (1 − e^(−kn/m))^k, the formula in Broder and Mitzenmacher's survey, which assumes the hash functions behave like random choices.
What is the optimal number of hash functions?
More hash functions give an outsider more chances to hit a 0, but they also fill the array with 1s faster. The survey shows the balance point is k = (m/n) ln 2, where about half the bits are 1 and the error rate is (1/2)^k, about 0.6185^(m/n).
Set f equal to your target error ε and solve: the bits you need per item are m/n = log2(1/ε) / ln 2, about 1.44 log2(1/ε). The survey also shows that any scheme with no false negatives and a false positive rate of at most ε needs essentially log2(1/ε) bits per item, so a Bloom filter is within a factor of about 1.44 of that lower bound. That log2(1/ε) counts bits of information, the idea behind Shannon entropy.
Worked example: 1 million items at 1% error
Using the survey's formulas:
Target: n = 1,000,000 items, ε = 0.01.
Bits per item: ln(100) / (ln 2)² = 4.605 / 0.4805 ≈ 9.59. Round up to 9.6.
Size: m = 9.6 million bits = 1.2 million bytes, about 1.2 MB.
Hash functions: k = 9.6 × 0.693 ≈ 6.65. Use k = 7, since you cannot run part of a hash.
Check: f = (1 − e^(−7/9.6))^7 = (1 − 0.4823)^7 ≈ 0.00996, just under 1%.
Real systems land close to the formula: the RocksDB wiki lists 9.9 bits per key for a 1% false positive rate, a little above the ideal 9.6.
Where are Bloom filters used?
Databases: Apache Cassandra uses Bloom filters so a read can avoid checking every SSTable data file for the requested partition. Its default false positive chance is 0.1 for tables using levelled compaction and 0.01 otherwise.
Key-value stores: RocksDB builds a filter into each data file to decide whether that file may contain the key.
Networks: the survey groups uses into peer-to-peer collaboration, resource routing, packet routing and measurement.
The survey sums this up as the Bloom filter principle: wherever a list or set is used and space is at a premium, consider a Bloom filter if the effect of false positives can be mitigated.
How can you practise the derivation?
Redo the worked example with the survey's formulas for 10 million items at 0.5% error. You should get about 11 bits per item (roughly 13.8 MB) and k ≈ 7.6, so 8 hash functions.
If the step from (1 − 1/m)^(kn) to e^(−kn/m) feels shaky, look it up in the Fermi Concept Library. To check your working, the Fermi Problem Library has a step-by-step solver that explains the reasoning. For another place where randomness proves something exact, read about the probabilistic method.



