This is an automated email from the ASF dual-hosted git repository. aherbert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-statistics.git
commit b774694323f271c0deaf10e9848edb575fa8250c Author: Alex Herbert <aherb...@apache.org> AuthorDate: Wed Oct 27 12:31:30 2021 +0100 Sonar fix: Create double from sum of integers for power function --- .../org/apache/commons/statistics/distribution/ZipfDistribution.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/ZipfDistribution.java b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/ZipfDistribution.java index addc503..08d1c3a 100644 --- a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/ZipfDistribution.java +++ b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/ZipfDistribution.java @@ -143,10 +143,10 @@ public final class ZipfDistribution extends AbstractDiscreteDistribution { // See http://www.math.wm.edu/~leemis/chart/UDR/PDFs/Zipf.pdf // S(x) = P(X > x) = ((x+1)^a Hn,a - (x+1)^a Hx+1,a + 1) / ((x+1)^a Hn,a) // where a = exponent and Hx,a is the generalized harmonic for x with exponent a. - final double z = Math.pow(x + 1, exponent); + final double z = Math.pow(x + 1.0, exponent); // Compute generalizedHarmonic(x, exponent) and generalizedHarmonic(x+1, exponent) final double hx = generalizedHarmonic(x, exponent); - final double hx1 = hx + Math.pow(x + 1, -exponent); + final double hx1 = hx + Math.pow(x + 1.0, -exponent); // Compute the survival function final double p = (z * (nthHarmonic - hx1) + 1) / (z * nthHarmonic); // May overflow for large exponent so validate the probability.