diff --git a/gdsc-test-rng/pom.xml b/gdsc-test-rng/pom.xml
index 8abd53c..1b1fc79 100644
--- a/gdsc-test-rng/pom.xml
+++ b/gdsc-test-rng/pom.xml
@@ -46,8 +46,7 @@ Contains utilities for use with Commons RNG for random tests.
org.apache.commons
- commons-math3
- 3.6.1
+ commons-statistics-inference
test
diff --git a/gdsc-test-rng/src/test/java/uk/ac/sussex/gdsc/test/rng/BaseLongUniformRandomProviderTest.java b/gdsc-test-rng/src/test/java/uk/ac/sussex/gdsc/test/rng/BaseLongUniformRandomProviderTest.java
index 1a30c45..940837a 100644
--- a/gdsc-test-rng/src/test/java/uk/ac/sussex/gdsc/test/rng/BaseLongUniformRandomProviderTest.java
+++ b/gdsc-test-rng/src/test/java/uk/ac/sussex/gdsc/test/rng/BaseLongUniformRandomProviderTest.java
@@ -24,10 +24,11 @@
import java.util.Arrays;
import java.util.stream.Stream;
-import org.apache.commons.math3.stat.inference.ChiSquareTest;
import org.apache.commons.rng.RandomProviderState;
import org.apache.commons.rng.RestorableUniformRandomProvider;
import org.apache.commons.rng.UniformRandomProvider;
+import org.apache.commons.statistics.inference.ChiSquareTest;
+import org.apache.commons.statistics.inference.SignificanceResult;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.TestInstance;
@@ -230,9 +231,8 @@ void testNextIntInRange(UniformRandomProvider rng, int limit, int bins) {
}
final double[] expected = new double[bins];
Arrays.fill(expected, (double) samples / bins);
- final ChiSquareTest test = new ChiSquareTest();
- final double pvalue = test.chiSquareTest(expected, observed);
- Assertions.assertFalse(pvalue < 0.01, "P-value = " + pvalue);
+ final SignificanceResult r = ChiSquareTest.withDefaults().test(expected, observed);
+ Assertions.assertFalse(r.reject(0.01), () -> "p-value = " + r.getPValue());
}
@ParameterizedTest
@@ -248,9 +248,8 @@ void testNextLongInRange(UniformRandomProvider rng, long limit, int bins) {
}
final double[] expected = new double[bins];
Arrays.fill(expected, (double) samples / bins);
- final ChiSquareTest test = new ChiSquareTest();
- final double pvalue = test.chiSquareTest(expected, observed);
- Assertions.assertFalse(pvalue < 0.01, "P-value = " + pvalue);
+ final SignificanceResult r = ChiSquareTest.withDefaults().test(expected, observed);
+ Assertions.assertFalse(r.reject(0.01), () -> "p-value = " + r.getPValue());
}
@ParameterizedTest
diff --git a/gdsc-test-rng/src/test/java/uk/ac/sussex/gdsc/test/rng/RngFactoryTest.java b/gdsc-test-rng/src/test/java/uk/ac/sussex/gdsc/test/rng/RngFactoryTest.java
index bdb3573..72489f7 100644
--- a/gdsc-test-rng/src/test/java/uk/ac/sussex/gdsc/test/rng/RngFactoryTest.java
+++ b/gdsc-test-rng/src/test/java/uk/ac/sussex/gdsc/test/rng/RngFactoryTest.java
@@ -25,8 +25,9 @@
import java.util.Arrays;
import java.util.SplittableRandom;
import java.util.concurrent.ThreadLocalRandom;
-import org.apache.commons.math3.stat.inference.ChiSquareTest;
import org.apache.commons.rng.UniformRandomProvider;
+import org.apache.commons.statistics.inference.ChiSquareTest;
+import org.apache.commons.statistics.inference.SignificanceResult;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
@@ -184,8 +185,7 @@ void testCreateIncrement(long seed) {
}
final double[] expected = new double[16];
Arrays.fill(expected, 1.0 / 16);
- final ChiSquareTest test = new ChiSquareTest();
- final double pvalue = test.chiSquareTest(expected, observed);
- Assertions.assertFalse(pvalue < 0.01, "P-value = " + pvalue);
+ final SignificanceResult r = ChiSquareTest.withDefaults().test(expected, observed);
+ Assertions.assertFalse(r.reject(0.01), () -> "p-value = " + r.getPValue());
}
}
diff --git a/gdsc-test-utils/pom.xml b/gdsc-test-utils/pom.xml
index 7a9679b..c55d672 100644
--- a/gdsc-test-utils/pom.xml
+++ b/gdsc-test-utils/pom.xml
@@ -41,8 +41,7 @@ Contains utilities for use with test frameworks.
org.apache.commons
- commons-math3
- 3.6.1
+ commons-statistics-inference
test
diff --git a/gdsc-test-utils/src/test/java/uk/ac/sussex/gdsc/test/utils/ByteScramblerTest.java b/gdsc-test-utils/src/test/java/uk/ac/sussex/gdsc/test/utils/ByteScramblerTest.java
index 3127f73..98fd17f 100644
--- a/gdsc-test-utils/src/test/java/uk/ac/sussex/gdsc/test/utils/ByteScramblerTest.java
+++ b/gdsc-test-utils/src/test/java/uk/ac/sussex/gdsc/test/utils/ByteScramblerTest.java
@@ -24,9 +24,10 @@
import java.util.Arrays;
import java.util.stream.DoubleStream;
-import org.apache.commons.math3.stat.inference.ChiSquareTest;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
+import org.apache.commons.statistics.inference.ChiSquareTest;
+import org.apache.commons.statistics.inference.SignificanceResult;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -71,9 +72,8 @@ void testBitScramblerIsUniform() {
}
}
// Do a chi-square test
- final ChiSquareTest chiSq = new ChiSquareTest();
final double[] expected = DoubleStream.generate(() -> 1.0 / 256).limit(256).toArray();
- final double pValue = chiSq.chiSquareTest(expected, histogram);
- Assertions.assertFalse(pValue < 0.01);
+ final SignificanceResult r = ChiSquareTest.withDefaults().test(expected, histogram);
+ Assertions.assertFalse(r.reject(0.01), () -> "p-value = " + r.getPValue());
}
}