MATH-1636: Remove "isSupportedConnected" (as per STATISTICS-48).
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 @@
}
};
- 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 @@
}
/**
- * {@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 @@
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 @@
/**
* {@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 @@
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 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 @@
}
/**
- * 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 @@
}
/**
- * Tests if the distribution returns properly that the support is connected.
- */
- @Test
- public void testIsSupportConnected() {
- Assert.assertTrue(testDistribution.isSupportConnected());
- }
-
- /**
* Tests sampling.
*/
@Test