Skip to content

Commit fe60df9

Browse files
committed
Fixed integer division.
1 parent 2702915 commit fe60df9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

hipparchus-core/src/test/java/org/hipparchus/random/KolmogorovSmirnovTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,14 @@ class KolmogorovSmirnovTest { // NOPMD - this is not a Junit test class, PMD fal
6767
public double kolmogorovSmirnovStatistic(RealDistribution distribution, double[] data) {
6868
checkArray(data);
6969
final int n = data.length;
70+
final double nd = n;
7071
final double[] dataCopy = new double[n];
7172
System.arraycopy(data, 0, dataCopy, 0, n);
7273
Arrays.sort(dataCopy);
7374
double d = 0d;
7475
for (int i = 1; i <= n; i++) {
7576
final double yi = distribution.cumulativeProbability(dataCopy[i - 1]);
76-
final double currD = FastMath.max(yi - (i - 1) / n, i / n - yi);
77+
final double currD = FastMath.max(yi - (i - 1) / nd, i / nd - yi);
7778
if (currD > d) {
7879
d = currD;
7980
}
@@ -507,8 +508,8 @@ private RealMatrix createRoundedH(double d, int n)
507508
private void checkArray(double[] array) {
508509
MathUtils.checkNotNull(array);
509510
if (array.length < 2) {
510-
throw new MathIllegalArgumentException(LocalizedCoreFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE, array.length,
511-
2);
511+
throw new MathIllegalArgumentException(LocalizedCoreFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE,
512+
array.length, 2);
512513
}
513514
}
514515

0 commit comments

Comments
 (0)