include "sets.m"; include "bloomfilter.m"; bloomfilter := load Bloomfilter Bloomfilter->PATH; init: fn(); filter: fn(d: array of byte, logm, k: int): Sets->Set;
Bloom filters can be combined by set union. The set represented by Bloom filter a is not a subset of another b if there are any members in a that are not in b. Together, logm, k, and n (the number of members in the set) determine the false positve rate (the probability that a membership test will not eliminate a member that is not in fact in the set). The probability of a false positive is approximately (1-e^(-kn/(2^logm))^k. For a given false positive rate, f, a useful formula to determine appropriate parameters is: k=ceil(-log₂(f)), and logm=ceil(log₂(nk)).
A, B, None: import Sets; for(i:=0; i<len elems; i++) f = f.X(A|B, filter(array of byte elems[i], 7, 6));Test whether the string s is a member of f. If there were 12 elements in elems, the probability of a false positive would be approximately 0.0063.
if(filter(array of byte s, 7, 6).X(A&~B, f).eq(None)) sys->print("'%s' might be a member of f\n", s);
BLOOMFILTER(2 ) | Rev: Thu Feb 19 12:40:06 GMT 2009 |