A Bloom Filter keeps an array of bits. To insert an element , set  with hash functions. To test membership of :

  • if any is definitely not in the set
  • if all is probably in the set (but false positives are possible)
    There are no false negatives, so if an element was inserted all its bits are set.

The probability that  is erroneously claimed to be in  is:

where is the number of inserted elements, is the array size, is the number of hash functions.
Typically:

  • is a small constant which depends on the desired false error rate
  • is proportional to

Insertion:

  • feed the element to the hash functions to get array positions
  • set positions bits to 1
    Testing:
  • feed the element to the hash functions to get array positions
  • two cases
    • any of the position is at 0 = element def not in the set
    • otherwise = either:
      • the element is in the set
      • bits have by chance been set to 1 during insertion of other elements (no way to tell the difference)

See also

References