commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [commons-math] 02/02: Removed obsolete interface.
Date Tue, 17 Dec 2019 02:14:56 GMT
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 bf5d19e08bfc74c56bc3d3828e5c3d93abbdff8b
Author: Gilles Sadowski <gilles@harfang.homelinux.org>
AuthorDate: Tue Dec 17 03:14:12 2019 +0100

    Removed obsolete interface.
---
 .../distribution/AbstractRealDistribution.java     |  2 +-
 .../math4/distribution/EmpiricalDistribution.java  |  2 +-
 .../distribution/MultivariateRealDistribution.java |  6 ++---
 .../math4/distribution/RealDistribution.java       | 26 ----------------------
 .../java/org/apache/commons/math4/TestUtils.java   |  4 ++--
 .../distribution/EmpiricalDistributionTest.java    |  4 ++--
 .../IntegerDistributionAbstractTest.java           | 18 +++++++--------
 .../distribution/RealDistributionAbstractTest.java | 17 +++++++-------
 8 files changed, 25 insertions(+), 54 deletions(-)

diff --git a/src/main/java/org/apache/commons/math4/distribution/AbstractRealDistribution.java
b/src/main/java/org/apache/commons/math4/distribution/AbstractRealDistribution.java
index 72edd8b..46e098a 100644
--- a/src/main/java/org/apache/commons/math4/distribution/AbstractRealDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/AbstractRealDistribution.java
@@ -47,7 +47,7 @@ import org.apache.commons.math4.util.FastMath;
  * @since 3.0
  */
 public abstract class AbstractRealDistribution
-    implements RealDistribution,
+    implements ContinuousDistribution,
                Serializable {
     /** Default absolute accuracy for inverse cumulative computation. */
     public static final double SOLVER_DEFAULT_ABSOLUTE_ACCURACY = 1e-6;
diff --git a/src/main/java/org/apache/commons/math4/distribution/EmpiricalDistribution.java
b/src/main/java/org/apache/commons/math4/distribution/EmpiricalDistribution.java
index 82357e9..b9434d1 100644
--- a/src/main/java/org/apache/commons/math4/distribution/EmpiricalDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/EmpiricalDistribution.java
@@ -81,7 +81,7 @@ import org.apache.commons.math4.util.MathUtils;
  * <li>Generate a random Gaussian value with mean = mean of the associated
  *     bin and std dev = std dev of associated bin.</li></ol>
  *
- * <p>EmpiricalDistribution implements the {@link RealDistribution} interface
+ * <p>EmpiricalDistribution implements the {@link ContinuousDistribution} interface
  * as follows.  Given x within the range of values in the dataset, let B
  * be the bin containing x and let K be the within-bin kernel for B.  Let P(B-)
  * be the sum of the probabilities of the bins below B and let K(B) be the
diff --git a/src/main/java/org/apache/commons/math4/distribution/MultivariateRealDistribution.java
b/src/main/java/org/apache/commons/math4/distribution/MultivariateRealDistribution.java
index ef5fca9..7c85965 100644
--- a/src/main/java/org/apache/commons/math4/distribution/MultivariateRealDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/MultivariateRealDistribution.java
@@ -21,9 +21,9 @@ import org.apache.commons.rng.UniformRandomProvider;
 /**
  * Base interface for multivariate distributions on the reals.
  *
- * This is based largely on the RealDistribution interface, but cumulative
- * distribution functions are not required because they are often quite
- * difficult to compute for multivariate distributions.
+ * This is based largely on the {@code ContinuousDistribution} interface,
+ * but cumulative distribution functions are not required because they
+ * are often quite difficult to compute for multivariate distributions.
  *
  * @since 3.1
  */
diff --git a/src/main/java/org/apache/commons/math4/distribution/RealDistribution.java b/src/main/java/org/apache/commons/math4/distribution/RealDistribution.java
deleted file mode 100644
index 7d6eff2..0000000
--- a/src/main/java/org/apache/commons/math4/distribution/RealDistribution.java
+++ /dev/null
@@ -1,26 +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.distribution;
-
-import org.apache.commons.statistics.distribution.ContinuousDistribution;
-
-/**
- * Base interface for distributions on the reals.
- *
- * @since 3.0
- */
-public interface RealDistribution extends ContinuousDistribution {}
diff --git a/src/test/java/org/apache/commons/math4/TestUtils.java b/src/test/java/org/apache/commons/math4/TestUtils.java
index 75fa790..0c73779 100644
--- a/src/test/java/org/apache/commons/math4/TestUtils.java
+++ b/src/test/java/org/apache/commons/math4/TestUtils.java
@@ -25,9 +25,9 @@ import java.text.DecimalFormat;
 
 import org.apache.commons.numbers.complex.Complex;
 import org.apache.commons.numbers.core.Precision;
+import org.apache.commons.statistics.distribution.ContinuousDistribution;
 import org.apache.commons.math4.FieldElement;
 import org.apache.commons.math4.complex.ComplexFormat;
-import org.apache.commons.math4.distribution.RealDistribution;
 import org.apache.commons.math4.linear.FieldMatrix;
 import org.apache.commons.math4.linear.RealMatrix;
 import org.apache.commons.math4.linear.RealVector;
@@ -531,7 +531,7 @@ public class TestUtils {
      * Computes the 25th, 50th and 75th percentiles of the given distribution and returns
      * these values in an array.
      */
-    public static double[] getDistributionQuartiles(RealDistribution distribution) {
+    public static double[] getDistributionQuartiles(ContinuousDistribution distribution)
{
         double[] quantiles = new double[3];
         quantiles[0] = distribution.inverseCumulativeProbability(0.25d);
         quantiles[1] = distribution.inverseCumulativeProbability(0.5d);
diff --git a/src/test/java/org/apache/commons/math4/distribution/EmpiricalDistributionTest.java
b/src/test/java/org/apache/commons/math4/distribution/EmpiricalDistributionTest.java
index 299af66..5b0f492 100644
--- a/src/test/java/org/apache/commons/math4/distribution/EmpiricalDistributionTest.java
+++ b/src/test/java/org/apache/commons/math4/distribution/EmpiricalDistributionTest.java
@@ -295,7 +295,7 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
     //  Setup for distribution tests
 
     @Override
-    public RealDistribution makeDistribution() {
+    public ContinuousDistribution makeDistribution() {
         // Create a uniform distribution on [0, 10,000]
         final double[] sourceData = new double[n + 1];
         for (int i = 0; i < n + 1; i++) {
@@ -374,7 +374,7 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
     @Override
     @Test
     public void testDensityIntegrals() {
-        final RealDistribution distribution = makeDistribution();
+        final ContinuousDistribution distribution = makeDistribution();
         final double tol = 1.0e-9;
         final BaseAbstractUnivariateIntegrator integrator =
             new IterativeLegendreGaussIntegrator(5, 1.0e-12, 1.0e-10);
diff --git a/src/test/java/org/apache/commons/math4/distribution/IntegerDistributionAbstractTest.java
b/src/test/java/org/apache/commons/math4/distribution/IntegerDistributionAbstractTest.java
index bb99df8..8a6e229 100644
--- a/src/test/java/org/apache/commons/math4/distribution/IntegerDistributionAbstractTest.java
+++ b/src/test/java/org/apache/commons/math4/distribution/IntegerDistributionAbstractTest.java
@@ -16,9 +16,9 @@
  */
 package org.apache.commons.math4.distribution;
 
+import org.apache.commons.statistics.distribution.DiscreteDistribution;
 import org.apache.commons.math4.TestUtils;
 import org.apache.commons.math4.distribution.AbstractIntegerDistribution;
-import org.apache.commons.math4.distribution.IntegerDistribution;
 import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.rng.simple.RandomSource;
 import org.apache.commons.math4.util.FastMath;
@@ -28,7 +28,7 @@ import org.junit.Before;
 import org.junit.Test;
 
 /**
- * Abstract base class for {@link IntegerDistribution} tests.
+ * Abstract base class for {@link DiscreteDistribution} tests.
  * <p>
  * To create a concrete test class for an integer distribution implementation,
  *  implement makeDistribution() to return a distribution instance to use in
@@ -52,7 +52,7 @@ public abstract class IntegerDistributionAbstractTest {
 
 //-------------------- Private test instance data -------------------------
     /** Discrete distribution instance used to perform tests */
-    private IntegerDistribution distribution;
+    private DiscreteDistribution distribution;
 
     /** Tolerance used in comparing expected and returned values */
     private double tolerance = 1E-12;
@@ -81,7 +81,7 @@ public abstract class IntegerDistributionAbstractTest {
     //-------------------- Abstract methods -----------------------------------
 
     /** Creates the default discrete distribution instance to use in tests. */
-    public abstract IntegerDistribution makeDistribution();
+    public abstract DiscreteDistribution makeDistribution();
 
     /** Creates the default probability density test input values */
     public abstract int[] makeDensityTestPoints();
@@ -169,10 +169,9 @@ public abstract class IntegerDistributionAbstractTest {
      */
     protected void verifyLogDensities() {
         for (int i = 0; i < densityTestPoints.length; i++) {
-            // FIXME: when logProbability methods are added to IntegerDistribution in 4.0,
remove cast below
             Assert.assertEquals("Incorrect log density value returned for " + densityTestPoints[i],
                     logDensityTestValues[i],
-                    ((AbstractIntegerDistribution) distribution).logProbability(densityTestPoints[i]),
tolerance);
+                    distribution.logProbability(densityTestPoints[i]), tolerance);
         }
     }
 
@@ -299,7 +298,7 @@ public abstract class IntegerDistributionAbstractTest {
             expectedCounts[i] = sampleSize * densityValues[i];
         }
         // Use fixed seed.
-        final IntegerDistribution.Sampler sampler =
+        final DiscreteDistribution.Sampler sampler =
             distribution.createSampler(RandomSource.create(RandomSource.WELL_512_A,
                                                            1000));
         int[] sample = AbstractIntegerDistribution.sample(sampleSize, sampler);
@@ -373,14 +372,14 @@ public abstract class IntegerDistributionAbstractTest {
     /**
      * @return Returns the distribution.
      */
-    protected IntegerDistribution getDistribution() {
+    protected DiscreteDistribution getDistribution() {
         return distribution;
     }
 
     /**
      * @param distribution The distribution to set.
      */
-    protected void setDistribution(IntegerDistribution distribution) {
+    protected void setDistribution(DiscreteDistribution distribution) {
         this.distribution = distribution;
     }
 
@@ -425,5 +424,4 @@ public abstract class IntegerDistributionAbstractTest {
     protected void setTolerance(double tolerance) {
         this.tolerance = tolerance;
     }
-
 }
diff --git a/src/test/java/org/apache/commons/math4/distribution/RealDistributionAbstractTest.java
b/src/test/java/org/apache/commons/math4/distribution/RealDistributionAbstractTest.java
index ea6d392..7039efa 100644
--- a/src/test/java/org/apache/commons/math4/distribution/RealDistributionAbstractTest.java
+++ b/src/test/java/org/apache/commons/math4/distribution/RealDistributionAbstractTest.java
@@ -30,7 +30,6 @@ import org.apache.commons.math4.TestUtils;
 import org.apache.commons.math4.analysis.UnivariateFunction;
 import org.apache.commons.math4.analysis.integration.BaseAbstractUnivariateIntegrator;
 import org.apache.commons.math4.analysis.integration.IterativeLegendreGaussIntegrator;
-import org.apache.commons.math4.distribution.RealDistribution;
 import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.exception.NumberIsTooLargeException;
 import org.apache.commons.rng.simple.RandomSource;
@@ -41,7 +40,7 @@ import org.junit.Before;
 import org.junit.Test;
 
 /**
- * Abstract base class for {@link RealDistribution} tests.
+ * Abstract base class for {@link ContinuousDistribution} tests.
  * <p>
  * To create a concrete test class for a continuous distribution
  * implementation, first implement makeDistribution() to return a distribution
@@ -77,7 +76,7 @@ public abstract class RealDistributionAbstractTest {
 
 //-------------------- Private test instance data -------------------------
     /**  Distribution instance used to perform tests */
-    private RealDistribution distribution;
+    private ContinuousDistribution distribution;
 
     /** Tolerance used in comparing expected and returned values */
     private double tolerance = 1E-4;
@@ -103,7 +102,7 @@ public abstract class RealDistributionAbstractTest {
     //-------------------- Abstract methods -----------------------------------
 
     /** Creates the default continuous distribution instance to use in tests. */
-    public abstract RealDistribution makeDistribution();
+    public abstract ContinuousDistribution makeDistribution();
 
     /** Creates the default cumulative probability test input values */
     public abstract double[] makeCumulativeTestPoints();
@@ -394,7 +393,7 @@ public abstract class RealDistributionAbstractTest {
         ContinuousDistribution.Sampler origSampler = distribution.createSampler(RandomSource.create(source,
seed));
 
         // Clone the distribution.
-        final RealDistribution cloned = deepClone();
+        final ContinuousDistribution cloned = deepClone();
         ContinuousDistribution.Sampler clonedSampler = cloned.createSampler(RandomSource.create(source,
seed));
 
         // Make sure they still produce the same samples.
@@ -443,14 +442,14 @@ public abstract class RealDistributionAbstractTest {
     /**
      * @return Returns the distribution.
      */
-    protected RealDistribution getDistribution() {
+    protected ContinuousDistribution getDistribution() {
         return distribution;
     }
 
     /**
      * @param distribution The distribution to set.
      */
-    protected void setDistribution(RealDistribution distribution) {
+    protected void setDistribution(ContinuousDistribution distribution) {
         this.distribution = distribution;
     }
 
@@ -499,7 +498,7 @@ public abstract class RealDistributionAbstractTest {
     /**
      * Serialization and deserialization loop of the {@link #distribution}.
      */
-    private RealDistribution deepClone()
+    private ContinuousDistribution deepClone()
         throws IOException,
                ClassNotFoundException {
         // Serialize to byte array.
@@ -514,6 +513,6 @@ public abstract class RealDistributionAbstractTest {
         final Object clone = oIn.readObject();
         oIn.close();
 
-        return (RealDistribution) clone;
+        return (ContinuousDistribution) clone;
     }
 }


Mime
View raw message