How many hash functions does my bloom filter need?

前端 未结 5 432
旧巷少年郎
旧巷少年郎 2020-12-12 23:10

Wikipedia says:

An empty Bloom filter is a bit array of m bits, all set to 0. There must also be k different hash functions defined, each of which map

5条回答
  •  旧时难觅i
    2020-12-12 23:34

    Given a number of bits per key you want to "invest", the best k is:

    max(1, round(bitsPerKey * log(2)))
    

    Where max is the higher of the two, round rounds to the nearest integer, log is the natural logarithm (base e).

提交回复
热议问题