Skip to content

Commit c7bc0d1

Browse files
authored
Fix Bloom documented formulas
1 parent 77d567e commit c7bc0d1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

content/commands/bf.reserve/index.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ Though the filter can scale up by creating sub-filters, it is recommended to res
4646
sub-filters requires additional memory (each sub-filter uses an extra bits and hash function) and consume further CPU time than an equivalent filter that had
4747
the right capacity at creation time.
4848

49-
The number of hash functions is `-log(error)/ln(2)^2`.
50-
The number of bits per item is `-log(error)/ln(2)` ≈ 1.44.
49+
The optimal number of hash functions is `ceil(-ln(error_rate) / ln(2))`.
5150

52-
* **1%** error rate requires 7 hash functions and 10.08 bits per item.
53-
* **0.1%** error rate requires 10 hash functions and 14.4 bits per item.
54-
* **0.01%** error rate requires 14 hash functions and 20.16 bits per item.
51+
The required number of bits per item, given the desired `error_rate` and the optimal number of hash functions, is `-ln(error_rate) / ln(2)^2`. Hence, the required number of bits in the filter is `capacity * -ln(error_rate) / ln(2)^2`.
52+
53+
* **1%** error rate requires 7 hash functions and 9.585 bits per item.
54+
* **0.1%** error rate requires 10 hash functions and 14.378 bits per item.
55+
* **0.01%** error rate requires 14 hash functions and 19.170 bits per item.
5556

5657
## Required arguments
5758

@@ -86,7 +87,7 @@ Non-scaling filters requires slightly less memory than their scaling counterpart
8687
When `capacity` is reached, an additional sub-filter is created.
8788
The size of the new sub-filter is the size of the last sub-filter multiplied by `expansion`, specified as a positive integer.
8889

89-
If the number of elements to be stored in the filter is unknown, you use an `expansion` of `2` or more to reduce the number of sub-filters.
90+
If the number of items to be stored in the filter is unknown, you use an `expansion` of `2` or more to reduce the number of sub-filters.
9091
Otherwise, you use an `expansion` of `1` to reduce memory consumption. The default value is `2`.
9192
</details>
9293

0 commit comments

Comments
 (0)