diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/hasher/Shape.java b/src/main/java/org/apache/commons/collections4/bloomfilter/hasher/Shape.java index 427452f9f..0f1156acd 100644 --- a/src/main/java/org/apache/commons/collections4/bloomfilter/hasher/Shape.java +++ b/src/main/java/org/apache/commons/collections4/bloomfilter/hasher/Shape.java @@ -29,7 +29,7 @@ import java.util.Objects; * *
log(1 / 2^log(2)) = log(1) - log(2^log(2)) = -log(2) * log(2) */ - private static final double DENOMINATOR = Math.log(1.0 / Math.pow(2.0, LOG_OF_2)); + private static final double DENOMINATOR = -LOG_OF_2 * LOG_OF_2; /** * Number of items in the filter. AKA: {@code n}. @@ -402,7 +404,7 @@ public final class Shape { /** * Calculates the probability of false positives ({@code p}) given * numberOfItems ({@code n}), numberOfBits ({@code m}) and numberOfHashFunctions ({@code k}). - *
p = (1 - exp(-kn/m))^k+ *
p = pow(1 - exp(-k / (m / n)), k)* *
This is the probability that a Bloom filter will return true for the presence of an item * when it does not contain the item.