diff --git a/src/main/java/org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.java b/src/main/java/org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.java index bec7294d6..aaab91440 100644 --- a/src/main/java/org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.java +++ b/src/main/java/org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.java @@ -41,9 +41,7 @@ import org.apache.commons.math3.random.Well19937c; import org.apache.commons.math3.util.CombinatoricsUtils; import org.apache.commons.math3.util.FastMath; import org.apache.commons.math3.util.MathArrays; - -import static org.apache.commons.math3.util.MathUtils.PI_SQUARED; -import static org.apache.commons.math3.util.FastMath.PI; +import org.apache.commons.math3.util.MathUtils; /** * Implementation of the @@ -540,7 +538,7 @@ public class KolmogorovSmirnovTest { double sum = 0; double increment = 0; double kTerm = 0; - double z2Term = PI_SQUARED / (8 * z2); + double z2Term = MathUtils.PI_SQUARED / (8 * z2); int k = 1; for (; k < MAXIMUM_PARTIAL_SUM_COUNT; k++) { kTerm = 2 * k - 1; @@ -565,7 +563,7 @@ public class KolmogorovSmirnovTest { for (k = 0; k < MAXIMUM_PARTIAL_SUM_COUNT; k++) { kTerm = k + 0.5; kTerm2 = kTerm * kTerm; - increment = (PI_SQUARED * kTerm2 - z2) * FastMath.exp(-PI_SQUARED * kTerm2 / twoZ2); + increment = (MathUtils.PI_SQUARED * kTerm2 - z2) * FastMath.exp(-MathUtils.PI_SQUARED * kTerm2 / twoZ2); sum += increment; if (FastMath.abs(increment) < PG_SUM_RELATIVE_ERROR * FastMath.abs(sum)) { break; @@ -574,7 +572,7 @@ public class KolmogorovSmirnovTest { if (k == MAXIMUM_PARTIAL_SUM_COUNT) { throw new TooManyIterationsException(MAXIMUM_PARTIAL_SUM_COUNT); } - final double sqrtHalfPi = FastMath.sqrt(PI / 2); + final double sqrtHalfPi = FastMath.sqrt(FastMath.PI / 2); // Instead of doubling sum, divide by 3 instead of 6 ret += sum * sqrtHalfPi / (3 * z4 * sqrtN); @@ -583,15 +581,15 @@ public class KolmogorovSmirnovTest { final double z4Term = 2 * z4; final double z6Term = 6 * z6; z2Term = 5 * z2; - final double pi4 = PI_SQUARED * PI_SQUARED; + final double pi4 = MathUtils.PI_SQUARED * MathUtils.PI_SQUARED; sum = 0; kTerm = 0; kTerm2 = 0; for (k = 0; k < MAXIMUM_PARTIAL_SUM_COUNT; k++) { kTerm = k + 0.5; kTerm2 = kTerm * kTerm; - increment = (z6Term + z4Term + PI_SQUARED * (z4Term - z2Term) * kTerm2 + - pi4 * (1 - twoZ2) * kTerm2 * kTerm2) * FastMath.exp(-PI_SQUARED * kTerm2 / twoZ2); + increment = (z6Term + z4Term + MathUtils.PI_SQUARED * (z4Term - z2Term) * kTerm2 + + pi4 * (1 - twoZ2) * kTerm2 * kTerm2) * FastMath.exp(-MathUtils.PI_SQUARED * kTerm2 / twoZ2); sum += increment; if (FastMath.abs(increment) < PG_SUM_RELATIVE_ERROR * FastMath.abs(sum)) { break; @@ -604,7 +602,7 @@ public class KolmogorovSmirnovTest { kTerm2 = 0; for (k = 1; k < MAXIMUM_PARTIAL_SUM_COUNT; k++) { kTerm2 = k * k; - increment = PI_SQUARED * kTerm2 * FastMath.exp(-PI_SQUARED * kTerm2 / twoZ2); + increment = MathUtils.PI_SQUARED * kTerm2 * FastMath.exp(-MathUtils.PI_SQUARED * kTerm2 / twoZ2); sum2 += increment; if (FastMath.abs(increment) < PG_SUM_RELATIVE_ERROR * FastMath.abs(sum2)) { break; @@ -618,7 +616,7 @@ public class KolmogorovSmirnovTest { // K_3(z) One more time with feeling - two doubly infinite sums, all k powers even. // Multiply coefficient denominators by 2, so omit doubling sums. - final double pi6 = pi4 * PI_SQUARED; + final double pi6 = pi4 * MathUtils.PI_SQUARED; sum = 0; double kTerm4 = 0; double kTerm6 = 0; @@ -628,8 +626,8 @@ public class KolmogorovSmirnovTest { kTerm4 = kTerm2 * kTerm2; kTerm6 = kTerm4 * kTerm2; increment = (pi6 * kTerm6 * (5 - 30 * z2) + pi4 * kTerm4 * (-60 * z2 + 212 * z4) + - PI_SQUARED * kTerm2 * (135 * z4 - 96 * z6) - 30 * z6 - 90 * z8) * - FastMath.exp(-PI_SQUARED * kTerm2 / twoZ2); + MathUtils.PI_SQUARED * kTerm2 * (135 * z4 - 96 * z6) - 30 * z6 - 90 * z8) * + FastMath.exp(-MathUtils.PI_SQUARED * kTerm2 / twoZ2); sum += increment; if (FastMath.abs(increment) < PG_SUM_RELATIVE_ERROR * FastMath.abs(sum)) { break; @@ -642,8 +640,8 @@ public class KolmogorovSmirnovTest { for (k = 1; k < MAXIMUM_PARTIAL_SUM_COUNT; k++) { kTerm2 = k * k; kTerm4 = kTerm2 * kTerm2; - increment = (-pi4 * kTerm4 + 3 * PI_SQUARED * kTerm2 * z2) * - FastMath.exp(-PI_SQUARED * kTerm2 / twoZ2); + increment = (-pi4 * kTerm4 + 3 * MathUtils.PI_SQUARED * kTerm2 * z2) * + FastMath.exp(-MathUtils.PI_SQUARED * kTerm2 / twoZ2); sum2 += increment; if (FastMath.abs(increment) < PG_SUM_RELATIVE_ERROR * FastMath.abs(sum2)) { break;