optimal_bits_needed

Function optimal_bits_needed 

Source
pub fn optimal_bits_needed(num_items: u32, fp_rate: f32) -> u32
Expand description

Computes the optimal bits needed to store n items with an expected false positive rate in the range [0, 1.0]. The formula is derived analytically as a well-known result for bloom filters, computed as follows:

n = num_items we expect to store in the bloom filter p = false positive rate optimal_bits_required = - n * ln(p) / ln(2) ^ 2

Rounds up to the nearest integer.