Paritian

Developers

Bloom Filter Calculator (Size, Hash Functions, False-Positive Rate)

How many bits, how much memory and how many hash functions a Bloom filter needs to hold a number of items at a false-positive rate you accept.

Results

Size of the bit array 9,585,059 bit
Memory 1.14 MiB
Number of hash functions 7
Bits per item 9.59
False-positive rate with that whole number of hashes 0.01004
How it changes
MemoryFalse-positive rate you accept 0.000 – 0.200. Memory: 2.28526 → 0.399331Memory00.511.522.50.0500.1000.1500.200False-positive rate you accept

The dashed line marks the value you entered.

What this tool does

A Bloom filter answers 'is this item in the set?' with either 'definitely not' or 'probably yes', using a small array of bits and several hash functions. For n items and a false-positive rate p, the optimal size is m = −n ln p ÷ (ln 2)² bits, and the best number of hashes is k = (m ÷ n) ln 2, which is just about 1.44 × log₂(1 ÷ p) bits per item. A 1 % rate costs about 9.6 bits per item and a tenth of a percent about 14.4, whatever the items are. The false-positive rate climbs quickly if you insert more items than planned, and a standard Bloom filter cannot delete.

Formula

m = −n ln p ÷ (ln 2)² · k = (m ÷ n) ln 2 · p = (1 − e^(−k n ÷ m))^k

Variables

SymbolMeaningUnit
nnNumber of items to store—
ppFalse-positive rate you accept—
MSize of the bit arraybit
MBMemoryMiB
KNumber of hash functions—
BPBits per item—
PRFalse-positive rate with that whole number of hashes—

Worked example

  • Number of items to store1,000,000
  • False-positive rate you accept0.01
  • Size of the bit array9,585,059 bit
  • Memory1.14 MiB
  • Number of hash functions7
  • Bits per item9.59
  • False-positive rate with that whole number of hashes0.01004

Limitations

  • The result is an estimate based only on the values you type. Real situations often include factors this calculator does not know about.
  • The formula assumes ideal conditions: no friction losses, no air resistance and no efficiency losses unless you enter them.