Bloom Filter
For a candidate set of n elements, bloom filter creates an array of size of m, and use k hash function:
Steps
- for each element in
nelements: Hash them and use the result as index to set the corresponding bit to1 - Given the test element, do the same hash and check if all the result bits are
1. If notfalse; otherwise,true
Probability
Check Probability of false positives wiki The key idea is:
- Calculate the probability of a certain bit in the array is
1afterncandidates insertion. - Calculate the
kpower of the above probability