How does the number of bits per key change a Bloom filter?
Sketch your own answer first, then compare it with the one below.
A strong answer
More bits per key means fewer collisions, so a lower false positive rate. The rate falls fast at first and then slowly. Each extra bit per key cuts the false positive rate by a similar factor, so going from a few bits to ten buys a lot, and going from ten to twenty buys a small share of the remaining errors for double the memory.
The number of hash functions matters too. Too few makes each test weak. Too many fills the array with set bits. The best count is about 0.69 times the bits per key.
A good answer gives the trade-off as memory against wasted lookups, and ties the choice to how costly a wasted lookup is.
Sources
- Burton H. Bloom (1970). Space/time trade-offs in hash coding with allowable errors.
- Andrei Broder, Michael Mitzenmacher (2004). Network Applications of Bloom Filters, A Survey.