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 2021/12/01 01:37:29 UTC
[commons-math] branch master updated (142dcaa -> 620b330)
This is an automated email from the ASF dual-hosted git repository.
erans pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-math.git.
from 142dcaa Javadoc.
new 226c1fc MATH-1636: Remove "isSupportedConnected" (as per STATISTICS-48).
new c6094cf MATH-1635: Unit test demonstrating the reported issue.
new 620b330 Comment out test case that fails too often.
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../distribution/AbstractRealDistribution.java | 29 +--
.../legacy/distribution/EmpiricalDistribution.java | 15 --
.../EnumeratedIntegerDistribution.java | 12 --
.../distribution/EnumeratedRealDistribution.java | 12 --
.../interpolation/AkimaSplineInterpolatorTest.java | 31 ++++
.../AbstractIntegerDistributionTest.java | 5 -
.../distribution/AbstractRealDistributionTest.java | 201 ---------------------
.../EnumeratedIntegerDistributionTest.java | 8 -
.../EnumeratedRealDistributionTest.java | 8 -
.../std_test_func.simplex.hedar_fukushima.csv | 2 +-
10 files changed, 36 insertions(+), 287 deletions(-)
delete mode 100644 commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/AbstractRealDistributionTest.java
[commons-math] 03/03: Comment out test case that fails too often.
Posted by er...@apache.org.
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 620b330f47878c0316701eefe775cd18f9774620
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Wed Dec 1 02:36:17 2021 +0100
Comment out test case that fails too often.
---
.../nonlinear/scalar/noderiv/std_test_func.simplex.hedar_fukushima.csv | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.hedar_fukushima.csv b/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.hedar_fukushima.csv
index 2e59424..6ce6942 100644
--- a/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.hedar_fukushima.csv
+++ b/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.hedar_fukushima.csv
@@ -52,7 +52,7 @@ TABLET, 11, 0 0 0 0 0 0 0 0 0 0 0, 3, 4, 2e-4, 3400, true
SUM_POW, 2, 0 0, 3, 4, 1e-2, 150, true
SUM_POW, 11, 0 0 0 0 0 0 0 0 0 0 0, 3, 4, 1e-2, 2500, true
ACKLEY, 2, 0 0, 2, 4, 1e-6, 250, true
-ACKLEY, 6, 0 0 0 0 0 0, 2, 4, 1e-6, 1600, true
+#ACKLEY, 6, 0 0 0 0 0 0, 2, 4, 1e-6, 1600, true
#RASTRIGIN, 2, 0 0, 6, 10, 5e-5, 170, true
GRIEWANK, 2, 0 0, 2, 3, 1e-1, 140, true
GRIEWANK, 11, 0 0 0 0 0 0 0 0 0 0 0, 2, 3, 1e-1, 2200, true
[commons-math] 02/03: MATH-1635: Unit test demonstrating the reported issue.
Posted by er...@apache.org.
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 c6094cf9e0f99f71e92e678fef08202fe3301069
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Wed Dec 1 02:27:51 2021 +0100
MATH-1635: Unit test demonstrating the reported issue.
Test is set to "@Ignore" since the behaviour may be a known limitation.
---
.../interpolation/AkimaSplineInterpolatorTest.java | 31 ++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/AkimaSplineInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/AkimaSplineInterpolatorTest.java
index c59a9bd..aea67a9 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/AkimaSplineInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/AkimaSplineInterpolatorTest.java
@@ -26,12 +26,14 @@ import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
import org.apache.commons.math4.legacy.exception.NonMonotonicSequenceException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
+import org.apache.commons.math4.legacy.analysis.polynomials.PolynomialSplineFunction;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
import org.apache.commons.math4.core.jdkmath.JdkMath;
import org.apache.commons.numbers.core.Precision;
import org.junit.Assert;
import org.junit.Test;
+import org.junit.Ignore;
public class AkimaSplineInterpolatorTest {
@Test
@@ -160,6 +162,35 @@ public class AkimaSplineInterpolatorTest {
maxTolerance );
}
+ // Test currently fails but it is not clear whether
+ // https://issues.apache.org/jira/browse/MATH-1635
+ // actually describes a bug, or a limitation of the algorithm.
+ @Ignore
+ @Test
+ public void testMath1635() {
+ final double[] x = {
+ 5994, 6005, 6555, 6588, 6663,
+ 6760, 6770, 6792, 6856, 6964,
+ 7028, 7233, 7426, 7469, 7619,
+ 7910, 8038, 8178, 8414, 8747,
+ 8983, 9316, 9864, 9875
+ };
+
+ final double[] y = {
+ 3.0, 2.0, 2.0, 2.0, 2.0,
+ 2.0, 2.0, 2.0, 2.0, 2.0,
+ 2.0, 2.0, 2.0, 2.0, 2.0,
+ 2.0, 2.0, 2.0, 2.0, 2.0,
+ 2.0, 2.0, 2.0, 3.0
+ };
+
+ final AkimaSplineInterpolator interpolator = new AkimaSplineInterpolator(true);
+ final PolynomialSplineFunction interpolate = interpolator.interpolate(x, y);
+ final double value = interpolate.value(9584);
+ final double expected = 2;
+ Assert.assertEquals(expected, value, 1e-4);
+ }
+
@Test
public void testOriginalVsModified() {
final UnivariateFunction f = new UnivariateFunction() {
[commons-math] 01/03: MATH-1636: Remove "isSupportedConnected" (as per STATISTICS-48).
Posted by er...@apache.org.
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 226c1fc6380ddcd59c38cbcafd892a58e8e356dd
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Wed Dec 1 02:06:16 2021 +0100
MATH-1636: Remove "isSupportedConnected" (as per STATISTICS-48).
---
.../distribution/AbstractRealDistribution.java | 29 +--
.../legacy/distribution/EmpiricalDistribution.java | 15 --
.../EnumeratedIntegerDistribution.java | 12 --
.../distribution/EnumeratedRealDistribution.java | 12 --
.../AbstractIntegerDistributionTest.java | 5 -
.../distribution/AbstractRealDistributionTest.java | 201 ---------------------
.../EnumeratedIntegerDistributionTest.java | 8 -
.../EnumeratedRealDistributionTest.java | 8 -
8 files changed, 4 insertions(+), 286 deletions(-)
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/AbstractRealDistribution.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/AbstractRealDistribution.java
index 3d79914..632d654 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/AbstractRealDistribution.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/AbstractRealDistribution.java
@@ -164,31 +164,10 @@ public abstract class AbstractRealDistribution
}
};
- double x = UnivariateSolverUtils.solve(toSolve,
- lowerBound,
- upperBound,
- getSolverAbsoluteAccuracy());
-
- if (!isSupportConnected()) {
- /* Test for plateau. */
- final double dx = getSolverAbsoluteAccuracy();
- if (x - dx >= getSupportLowerBound()) {
- double px = cumulativeProbability(x);
- if (cumulativeProbability(x - dx) == px) {
- upperBound = x;
- while (upperBound - lowerBound > dx) {
- final double midPoint = 0.5 * (lowerBound + upperBound);
- if (cumulativeProbability(midPoint) < px) {
- lowerBound = midPoint;
- } else {
- upperBound = midPoint;
- }
- }
- return upperBound;
- }
- }
- }
- return x;
+ return UnivariateSolverUtils.solve(toSolve,
+ lowerBound,
+ upperBound,
+ getSolverAbsoluteAccuracy());
}
/**
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EmpiricalDistribution.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EmpiricalDistribution.java
index f3bf604..f7e2fe6 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EmpiricalDistribution.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EmpiricalDistribution.java
@@ -466,15 +466,6 @@ public final class EmpiricalDistribution extends AbstractRealDistribution
}
/**
- * {@inheritDoc}
- * @since 3.1
- */
- @Override
- public boolean isSupportConnected() {
- return true;
- }
-
- /**
* The probability of bin i.
*
* @param i the index of the bin
@@ -620,12 +611,6 @@ public final class EmpiricalDistribution extends AbstractRealDistribution
return value;
}
- /** {@inheritDoc} */
- @Override
- public boolean isSupportConnected() {
- return true;
- }
-
/**
* {@inheritDoc}
*
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedIntegerDistribution.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedIntegerDistribution.java
index 38a8f64..dce14aa 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedIntegerDistribution.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedIntegerDistribution.java
@@ -218,18 +218,6 @@ public class EnumeratedIntegerDistribution extends AbstractIntegerDistribution {
/**
* {@inheritDoc}
*
- * The support of this distribution is connected.
- *
- * @return {@code true}
- */
- @Override
- public boolean isSupportConnected() {
- return true;
- }
-
- /**
- * {@inheritDoc}
- *
* Refer to {@link EnumeratedDistribution.Sampler} for implementation details.
*/
@Override
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedRealDistribution.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedRealDistribution.java
index bae7540..d85c5ec 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedRealDistribution.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedRealDistribution.java
@@ -251,18 +251,6 @@ public class EnumeratedRealDistribution
return max;
}
- /**
- * {@inheritDoc}
- *
- * The support of this distribution is connected.
- *
- * @return {@code true}
- */
- @Override
- public boolean isSupportConnected() {
- return true;
- }
-
/** {@inheritDoc} */
@Override
public ContinuousDistribution.Sampler createSampler(final UniformRandomProvider rng) {
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/AbstractIntegerDistributionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/AbstractIntegerDistributionTest.java
index 844bcea..9b8c259 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/AbstractIntegerDistributionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/AbstractIntegerDistributionTest.java
@@ -120,10 +120,5 @@ public class AbstractIntegerDistributionTest {
public int getSupportUpperBound() {
return 6;
}
-
- @Override
- public final boolean isSupportConnected() {
- return true;
- }
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/AbstractRealDistributionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/AbstractRealDistributionTest.java
deleted file mode 100644
index c750037..0000000
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/AbstractRealDistributionTest.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.math4.legacy.distribution;
-
-import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
-import org.apache.commons.math4.legacy.analysis.integration.RombergIntegrator;
-import org.apache.commons.math4.legacy.analysis.integration.UnivariateIntegrator;
-import org.apache.commons.math4.legacy.exception.OutOfRangeException;
-import org.junit.Assert;
-import org.junit.Test;
-
-/** Various tests related to MATH-699. */
-public class AbstractRealDistributionTest {
-
- @Test
- public void testContinuous() {
- final double x0 = 0.0;
- final double x1 = 1.0;
- final double x2 = 2.0;
- final double x3 = 3.0;
- final double p12 = 0.5;
- final AbstractRealDistribution distribution;
- distribution = new AbstractRealDistribution() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public double cumulativeProbability(final double x) {
- if ((x < x0) || (x > x3)) {
- throw new OutOfRangeException(x, x0, x3);
- }
- if (x <= x1) {
- return p12 * (x - x0) / (x1 - x0);
- } else if (x <= x2) {
- return p12;
- } else if (x <= x3) {
- return p12 + (1.0 - p12) * (x - x2) / (x3 - x2);
- }
- return 0.0;
- }
-
- @Override
- public double density(final double x) {
- if ((x < x0) || (x > x3)) {
- throw new OutOfRangeException(x, x0, x3);
- }
- if (x <= x1) {
- return p12 / (x1 - x0);
- } else if (x <= x2) {
- return 0.0;
- } else if (x <= x3) {
- return (1.0 - p12) / (x3 - x2);
- }
- return 0.0;
- }
-
- @Override
- public double getMean() {
- return ((x0 + x1) * p12 + (x2 + x3) * (1.0 - p12)) / 2.0;
- }
-
- @Override
- public double getVariance() {
- final double meanX = getMean();
- final double meanX2;
- meanX2 = ((x0 * x0 + x0 * x1 + x1 * x1) * p12 + (x2 * x2 + x2
- * x3 + x3 * x3)
- * (1.0 - p12)) / 3.0;
- return meanX2 - meanX * meanX;
- }
-
- @Override
- public double getSupportLowerBound() {
- return x0;
- }
-
- @Override
- public double getSupportUpperBound() {
- return x3;
- }
-
- @Override
- public boolean isSupportConnected() {
- return false;
- }
- };
- final double expected = x1;
- final double actual = distribution.inverseCumulativeProbability(p12);
- Assert.assertEquals("", expected, actual,
- distribution.getSolverAbsoluteAccuracy());
- }
-
- @Test
- public void testDiscontinuous() {
- final double x0 = 0.0;
- final double x1 = 0.25;
- final double x2 = 0.5;
- final double x3 = 0.75;
- final double x4 = 1.0;
- final double p12 = 1.0 / 3.0;
- final double p23 = 2.0 / 3.0;
- final AbstractRealDistribution distribution;
- distribution = new AbstractRealDistribution() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public double cumulativeProbability(final double x) {
- if ((x < x0) || (x > x4)) {
- throw new OutOfRangeException(x, x0, x4);
- }
- if (x <= x1) {
- return p12 * (x - x0) / (x1 - x0);
- } else if (x <= x2) {
- return p12;
- } else if (x <= x3) {
- return p23;
- } else {
- return (1.0 - p23) * (x - x3) / (x4 - x3) + p23;
- }
- }
-
- @Override
- public double density(final double x) {
- if ((x < x0) || (x > x4)) {
- throw new OutOfRangeException(x, x0, x4);
- }
- if (x <= x1) {
- return p12 / (x1 - x0);
- } else if (x <= x2) {
- return 0.0;
- } else if (x <= x3) {
- return 0.0;
- } else {
- return (1.0 - p23) / (x4 - x3);
- }
- }
-
- @Override
- public double getMean() {
- final UnivariateFunction f = new UnivariateFunction() {
-
- @Override
- public double value(final double x) {
- return x * density(x);
- }
- };
- final UnivariateIntegrator integrator = new RombergIntegrator();
- return integrator.integrate(Integer.MAX_VALUE, f, x0, x4);
- }
-
- @Override
- public double getVariance() {
- final double meanX = getMean();
- final UnivariateFunction f = new UnivariateFunction() {
-
- @Override
- public double value(final double x) {
- return x * x * density(x);
- }
- };
- final UnivariateIntegrator integrator = new RombergIntegrator();
- final double meanX2 = integrator.integrate(Integer.MAX_VALUE,
- f, x0, x4);
- return meanX2 - meanX * meanX;
- }
-
- @Override
- public double getSupportLowerBound() {
- return x0;
- }
-
- @Override
- public double getSupportUpperBound() {
- return x4;
- }
-
- @Override
- public boolean isSupportConnected() {
- return false;
- }
- };
- final double expected = x2;
- final double actual = distribution.inverseCumulativeProbability(p23);
- Assert.assertEquals("", expected, actual,
- distribution.getSolverAbsoluteAccuracy());
-
- }
-}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EnumeratedIntegerDistributionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EnumeratedIntegerDistributionTest.java
index 0810e8f..b3d948a 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EnumeratedIntegerDistributionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EnumeratedIntegerDistributionTest.java
@@ -143,14 +143,6 @@ public class EnumeratedIntegerDistributionTest {
}
/**
- * Tests if the distribution returns properly that the support is connected.
- */
- @Test
- public void testIsSupportConnected() {
- Assert.assertTrue(testDistribution.isSupportConnected());
- }
-
- /**
* Tests sampling.
*/
@Test
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EnumeratedRealDistributionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EnumeratedRealDistributionTest.java
index 4d38287..a386e4d 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EnumeratedRealDistributionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EnumeratedRealDistributionTest.java
@@ -163,14 +163,6 @@ public class EnumeratedRealDistributionTest {
}
/**
- * Tests if the distribution returns properly that the support is connected.
- */
- @Test
- public void testIsSupportConnected() {
- Assert.assertTrue(testDistribution.isSupportConnected());
- }
-
- /**
* Tests sampling.
*/
@Test