You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2020/05/18 10:00:17 UTC
[commons-math] 02/03: MATH-1533: Add unit test.
This is an automated email from the ASF dual-hosted git repository.
erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-math.git
commit cd003cb29fe11d0ab08500e067863b9e1a1bd3fe
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Mon May 18 11:49:23 2020 +0200
MATH-1533: Add unit test.
Issue reported does not exist in the development version.
---
.../distribution/EnumeratedIntegerDistributionTest.java | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/test/java/org/apache/commons/math4/distribution/EnumeratedIntegerDistributionTest.java b/src/test/java/org/apache/commons/math4/distribution/EnumeratedIntegerDistributionTest.java
index 0725e51..3a32f98 100644
--- a/src/test/java/org/apache/commons/math4/distribution/EnumeratedIntegerDistributionTest.java
+++ b/src/test/java/org/apache/commons/math4/distribution/EnumeratedIntegerDistributionTest.java
@@ -18,6 +18,7 @@ package org.apache.commons.math4.distribution;
import static org.junit.Assert.assertEquals;
+import java.util.Arrays;
import org.apache.commons.statistics.distribution.DiscreteDistribution;
import org.apache.commons.math4.distribution.EnumeratedIntegerDistribution;
import org.apache.commons.math4.exception.DimensionMismatchException;
@@ -183,4 +184,18 @@ public class EnumeratedIntegerDistributionTest {
assertEquals(0.5, distribution.probability(2), 0);
assertEquals(0.5, distribution.cumulativeProbability(1), 0);
}
+
+ @Test
+ public void testMath1533() {
+ final EnumeratedIntegerDistribution d1 = new EnumeratedIntegerDistribution(new int[] {1, 2},
+ new double[] {0.3, 0.7});
+ final EnumeratedIntegerDistribution d2 = new EnumeratedIntegerDistribution(new int[] {2, 1},
+ new double[] {0.7, 0.3});
+
+ final int len = 24;
+ final RandomSource r = RandomSource.WELL_19937_C;
+ final int s = 42;
+ Assert.assertTrue(Arrays.equals(AbstractIntegerDistribution.sample(len, d1.createSampler(RandomSource.create(r, s))),
+ AbstractIntegerDistribution.sample(len, d2.createSampler(RandomSource.create(r, s)))));
+ }
}