From 06bc5ac61a204128b1f69104acba83f266883b1c Mon Sep 17 00:00:00 2001 From: Gilles Date: Thu, 25 Jan 2018 18:31:10 +0100 Subject: [PATCH] MATH-1443: Depend on "Commons Statistics". --- .../AkimaSplineInterpolatorTest.java | 8 ++++---- .../BicubicInterpolatingFunctionTest.java | 8 ++++---- .../BicubicInterpolatorTest.java | 8 ++++---- ...icubicSplineInterpolatingFunctionTest.java | 8 ++++---- ...iecewiseBicubicSplineInterpolatorTest.java | 12 +++++------ .../TricubicInterpolatingFunctionTest.java | 10 +++++----- .../RealDistributionAbstractTest.java | 3 ++- .../math4/filter/KalmanFilterTest.java | 10 +++++----- .../fitting/PolynomialCurveFitterTest.java | 8 ++++---- .../math4/fitting/SimpleCurveFitterTest.java | 8 ++++---- .../LevenbergMarquardtOptimizerTest.java | 2 +- .../RandomCirclePointGenerator.java | 14 ++++++------- .../RandomStraightLinePointGenerator.java | 12 +++++------ .../math4/linear/EigenDecompositionTest.java | 6 +++--- .../linear/HessenbergTransformerTest.java | 6 +++--- .../math4/linear/SchurTransformerTest.java | 6 +++--- .../correlation/PearsonsCorrelationTest.java | 2 +- .../AggregateSummaryStatisticsTest.java | 20 +++++++++---------- .../UnivariateStatisticAbstractTest.java | 16 +++++++-------- .../stat/descriptive/rank/PercentileTest.java | 6 +++--- .../GLSMultipleLinearRegressionTest.java | 6 +++--- .../commons/math4/util/MathUtilsTest.java | 8 ++++---- .../math4/util/ResizableDoubleArrayTest.java | 14 ++++++------- 23 files changed, 101 insertions(+), 100 deletions(-) diff --git a/src/test/java/org/apache/commons/math4/analysis/interpolation/AkimaSplineInterpolatorTest.java b/src/test/java/org/apache/commons/math4/analysis/interpolation/AkimaSplineInterpolatorTest.java index 0d6ccf39b..d559c4e14 100644 --- a/src/test/java/org/apache/commons/math4/analysis/interpolation/AkimaSplineInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/interpolation/AkimaSplineInterpolatorTest.java @@ -20,8 +20,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import org.apache.commons.math4.analysis.UnivariateFunction; -import org.apache.commons.math4.distribution.RealDistribution; -import org.apache.commons.math4.distribution.UniformRealDistribution; +import org.apache.commons.statistics.distribution.ContinuousDistribution; +import org.apache.commons.statistics.distribution.UniformContinuousDistribution; import org.apache.commons.math4.exception.DimensionMismatchException; import org.apache.commons.math4.exception.NonMonotonicSequenceException; import org.apache.commons.math4.exception.NullArgumentException; @@ -214,8 +214,8 @@ public class AkimaSplineInterpolatorTest } final UniformRandomProvider rng = RandomSource.create(RandomSource.WELL_19937_C, 1234567L); // "tol" depends on the seed. - final RealDistribution.Sampler distX = - new UniformRealDistribution(xValues[0], xValues[xValues.length - 1]).createSampler(rng); + final ContinuousDistribution.Sampler distX = + new UniformContinuousDistribution(xValues[0], xValues[xValues.length - 1]).createSampler(rng); double sumError = 0; for ( int i = 0; i < numberOfSamples; i++ ) diff --git a/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java b/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java index 57d5b2411..f63ea08c2 100644 --- a/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java @@ -17,8 +17,8 @@ package org.apache.commons.math4.analysis.interpolation; import org.apache.commons.math4.analysis.BivariateFunction; -import org.apache.commons.math4.distribution.RealDistribution; -import org.apache.commons.math4.distribution.UniformRealDistribution; +import org.apache.commons.statistics.distribution.ContinuousDistribution; +import org.apache.commons.statistics.distribution.UniformContinuousDistribution; import org.apache.commons.math4.exception.DimensionMismatchException; import org.apache.commons.math4.exception.MathIllegalArgumentException; import org.apache.commons.math4.exception.OutOfRangeException; @@ -362,8 +362,8 @@ public final class BicubicInterpolatingFunctionTest { } final UniformRandomProvider rng = RandomSource.create(RandomSource.WELL_19937_C, 1234567L); - final RealDistribution.Sampler distX = new UniformRealDistribution(xValues[0], xValues[xValues.length - 1]).createSampler(rng); - final RealDistribution.Sampler distY = new UniformRealDistribution(yValues[0], yValues[yValues.length - 1]).createSampler(rng); + final ContinuousDistribution.Sampler distX = new UniformContinuousDistribution(xValues[0], xValues[xValues.length - 1]).createSampler(rng); + final ContinuousDistribution.Sampler distY = new UniformContinuousDistribution(yValues[0], yValues[yValues.length - 1]).createSampler(rng); double sumError = 0; for (int i = 0; i < numberOfSamples; i++) { diff --git a/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatorTest.java b/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatorTest.java index 8c29778b4..bf3195c2a 100644 --- a/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatorTest.java @@ -17,8 +17,8 @@ package org.apache.commons.math4.analysis.interpolation; import org.apache.commons.math4.analysis.BivariateFunction; -import org.apache.commons.math4.distribution.RealDistribution; -import org.apache.commons.math4.distribution.UniformRealDistribution; +import org.apache.commons.statistics.distribution.ContinuousDistribution; +import org.apache.commons.statistics.distribution.UniformContinuousDistribution; import org.apache.commons.math4.exception.DimensionMismatchException; import org.apache.commons.math4.exception.MathIllegalArgumentException; import org.apache.commons.rng.UniformRandomProvider; @@ -148,8 +148,8 @@ public final class BicubicInterpolatorTest { double x, y; final UniformRandomProvider rng = RandomSource.create(RandomSource.WELL_19937_C); - final RealDistribution.Sampler distX = new UniformRealDistribution(xval[0], xval[xval.length - 1]).createSampler(rng); - final RealDistribution.Sampler distY = new UniformRealDistribution(yval[0], yval[yval.length - 1]).createSampler(rng); + final ContinuousDistribution.Sampler distX = new UniformContinuousDistribution(xval[0], xval[xval.length - 1]).createSampler(rng); + final ContinuousDistribution.Sampler distY = new UniformContinuousDistribution(yval[0], yval[yval.length - 1]).createSampler(rng); int count = 0; while (true) { diff --git a/src/test/java/org/apache/commons/math4/analysis/interpolation/PiecewiseBicubicSplineInterpolatingFunctionTest.java b/src/test/java/org/apache/commons/math4/analysis/interpolation/PiecewiseBicubicSplineInterpolatingFunctionTest.java index 6ee205cb5..a1825ccf2 100644 --- a/src/test/java/org/apache/commons/math4/analysis/interpolation/PiecewiseBicubicSplineInterpolatingFunctionTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/interpolation/PiecewiseBicubicSplineInterpolatingFunctionTest.java @@ -17,8 +17,8 @@ package org.apache.commons.math4.analysis.interpolation; import org.apache.commons.math4.analysis.BivariateFunction; -import org.apache.commons.math4.distribution.RealDistribution; -import org.apache.commons.math4.distribution.UniformRealDistribution; +import org.apache.commons.statistics.distribution.ContinuousDistribution; +import org.apache.commons.statistics.distribution.UniformContinuousDistribution; import org.apache.commons.math4.exception.DimensionMismatchException; import org.apache.commons.math4.exception.InsufficientDataException; import org.apache.commons.math4.exception.NonMonotonicSequenceException; @@ -252,8 +252,8 @@ public final class PiecewiseBicubicSplineInterpolatingFunctionTest { } final UniformRandomProvider rng = RandomSource.create(RandomSource.WELL_19937_C, 1234567L); - final RealDistribution.Sampler distX = new UniformRealDistribution(xValues[0], xValues[xValues.length - 1]).createSampler(rng); - final RealDistribution.Sampler distY = new UniformRealDistribution(yValues[0], yValues[yValues.length - 1]).createSampler(rng); + final ContinuousDistribution.Sampler distX = new UniformContinuousDistribution(xValues[0], xValues[xValues.length - 1]).createSampler(rng); + final ContinuousDistribution.Sampler distY = new UniformContinuousDistribution(yValues[0], yValues[yValues.length - 1]).createSampler(rng); double sumError = 0; for (int i = 0; i < numberOfSamples; i++) { diff --git a/src/test/java/org/apache/commons/math4/analysis/interpolation/PiecewiseBicubicSplineInterpolatorTest.java b/src/test/java/org/apache/commons/math4/analysis/interpolation/PiecewiseBicubicSplineInterpolatorTest.java index 1c0a0707e..c47562134 100644 --- a/src/test/java/org/apache/commons/math4/analysis/interpolation/PiecewiseBicubicSplineInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/interpolation/PiecewiseBicubicSplineInterpolatorTest.java @@ -17,8 +17,8 @@ package org.apache.commons.math4.analysis.interpolation; import org.apache.commons.math4.analysis.BivariateFunction; -import org.apache.commons.math4.distribution.RealDistribution; -import org.apache.commons.math4.distribution.UniformRealDistribution; +import org.apache.commons.statistics.distribution.ContinuousDistribution; +import org.apache.commons.statistics.distribution.UniformContinuousDistribution; import org.apache.commons.math4.exception.DimensionMismatchException; import org.apache.commons.math4.exception.InsufficientDataException; import org.apache.commons.math4.exception.NonMonotonicSequenceException; @@ -159,8 +159,8 @@ public final class PiecewiseBicubicSplineInterpolatorTest { double x, y; final UniformRandomProvider rng = RandomSource.create(RandomSource.WELL_19937_C, 1234567L); - final RealDistribution.Sampler distX = new UniformRealDistribution(xval[0], xval[xval.length - 1]).createSampler(rng); - final RealDistribution.Sampler distY = new UniformRealDistribution(yval[0], yval[yval.length - 1]).createSampler(rng); + final ContinuousDistribution.Sampler distX = new UniformContinuousDistribution(xval[0], xval[xval.length - 1]).createSampler(rng); + final ContinuousDistribution.Sampler distY = new UniformContinuousDistribution(yval[0], yval[yval.length - 1]).createSampler(rng); final int numSamples = 50; final double tol = 2e-14; @@ -211,8 +211,8 @@ public final class PiecewiseBicubicSplineInterpolatorTest { double x, y; final UniformRandomProvider rng = RandomSource.create(RandomSource.WELL_19937_C, 1234567L); - final RealDistribution.Sampler distX = new UniformRealDistribution(xval[0], xval[xval.length - 1]).createSampler(rng); - final RealDistribution.Sampler distY = new UniformRealDistribution(yval[0], yval[yval.length - 1]).createSampler(rng); + final ContinuousDistribution.Sampler distX = new UniformContinuousDistribution(xval[0], xval[xval.length - 1]).createSampler(rng); + final ContinuousDistribution.Sampler distY = new UniformContinuousDistribution(yval[0], yval[yval.length - 1]).createSampler(rng); final int numSamples = 50; final double tol = 5e-13; diff --git a/src/test/java/org/apache/commons/math4/analysis/interpolation/TricubicInterpolatingFunctionTest.java b/src/test/java/org/apache/commons/math4/analysis/interpolation/TricubicInterpolatingFunctionTest.java index a28a6fc9e..f2ccc0be2 100644 --- a/src/test/java/org/apache/commons/math4/analysis/interpolation/TricubicInterpolatingFunctionTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/interpolation/TricubicInterpolatingFunctionTest.java @@ -17,8 +17,8 @@ package org.apache.commons.math4.analysis.interpolation; import org.apache.commons.math4.analysis.TrivariateFunction; -import org.apache.commons.math4.distribution.RealDistribution; -import org.apache.commons.math4.distribution.UniformRealDistribution; +import org.apache.commons.statistics.distribution.ContinuousDistribution; +import org.apache.commons.statistics.distribution.UniformContinuousDistribution; import org.apache.commons.math4.exception.DimensionMismatchException; import org.apache.commons.math4.exception.MathIllegalArgumentException; import org.apache.commons.rng.UniformRandomProvider; @@ -381,9 +381,9 @@ public final class TricubicInterpolatingFunctionTest { } final UniformRandomProvider rng = RandomSource.create(RandomSource.WELL_19937_C, 1234568L); - final RealDistribution.Sampler distX = new UniformRealDistribution(xValues[0], xValues[xValues.length - 1]).createSampler(rng); - final RealDistribution.Sampler distY = new UniformRealDistribution(yValues[0], yValues[yValues.length - 1]).createSampler(rng); - final RealDistribution.Sampler distZ = new UniformRealDistribution(zValues[0], zValues[zValues.length - 1]).createSampler(rng); + final ContinuousDistribution.Sampler distX = new UniformContinuousDistribution(xValues[0], xValues[xValues.length - 1]).createSampler(rng); + final ContinuousDistribution.Sampler distY = new UniformContinuousDistribution(yValues[0], yValues[yValues.length - 1]).createSampler(rng); + final ContinuousDistribution.Sampler distZ = new UniformContinuousDistribution(zValues[0], zValues[zValues.length - 1]).createSampler(rng); double sumError = 0; for (int i = 0; i < numberOfSamples; i++) { 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 8933dbb10..8d7ac9f73 100644 --- a/src/test/java/org/apache/commons/math4/distribution/RealDistributionAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/distribution/RealDistributionAbstractTest.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import org.apache.commons.statistics.distribution.ContinuousDistribution; import org.apache.commons.math4.TestUtils; import org.apache.commons.math4.analysis.UnivariateFunction; import org.apache.commons.math4.analysis.integration.BaseAbstractUnivariateIntegrator; @@ -329,7 +330,7 @@ public abstract class RealDistributionAbstractTest { @Test public void testSampler() { final int sampleSize = 1000; - final RealDistribution.Sampler sampler = + final ContinuousDistribution.Sampler sampler = distribution.createSampler(RandomSource.create(RandomSource.WELL_19937_C, 123456789L)); final double[] sample = AbstractRealDistribution.sample(sampleSize, sampler); final double[] quartiles = TestUtils.getDistributionQuartiles(distribution); diff --git a/src/test/java/org/apache/commons/math4/filter/KalmanFilterTest.java b/src/test/java/org/apache/commons/math4/filter/KalmanFilterTest.java index 744fe4141..fbe786b49 100644 --- a/src/test/java/org/apache/commons/math4/filter/KalmanFilterTest.java +++ b/src/test/java/org/apache/commons/math4/filter/KalmanFilterTest.java @@ -14,8 +14,8 @@ package org.apache.commons.math4.filter; -import org.apache.commons.math4.distribution.RealDistribution; -import org.apache.commons.math4.distribution.NormalDistribution; +import org.apache.commons.statistics.distribution.ContinuousDistribution; +import org.apache.commons.statistics.distribution.NormalDistribution; import org.apache.commons.math4.filter.DefaultMeasurementModel; import org.apache.commons.math4.filter.DefaultProcessModel; import org.apache.commons.math4.filter.KalmanFilter; @@ -126,7 +126,7 @@ public class KalmanFilterTest { RealVector pNoise = new ArrayRealVector(1); RealVector mNoise = new ArrayRealVector(1); - final RealDistribution.Sampler rand = new NormalDistribution().createSampler(RandomSource.create(RandomSource.WELL_19937_C)); + final ContinuousDistribution.Sampler rand = new NormalDistribution(0, 1).createSampler(RandomSource.create(RandomSource.WELL_19937_C)); // iterate 60 steps for (int i = 0; i < 60; i++) { @@ -215,7 +215,7 @@ public class KalmanFilterTest { double[] expectedInitialState = new double[] { 0.0, 0.0 }; assertVectorEquals(expectedInitialState, filter.getStateEstimation()); - final RealDistribution.Sampler rand = new NormalDistribution().createSampler(RandomSource.create(RandomSource.WELL_19937_C)); + final ContinuousDistribution.Sampler rand = new NormalDistribution(0, 1).createSampler(RandomSource.create(RandomSource.WELL_19937_C)); RealVector tmpPNoise = new ArrayRealVector( new double[] { FastMath.pow(dt, 2d) / 2d, dt }); @@ -392,7 +392,7 @@ public class KalmanFilterTest { final MeasurementModel mm = new DefaultMeasurementModel(H, R); final KalmanFilter filter = new KalmanFilter(pm, mm); - final RealDistribution.Sampler dist = new NormalDistribution(0, measurementNoise).createSampler(RandomSource.create(RandomSource.WELL_19937_C, 1001)); + final ContinuousDistribution.Sampler dist = new NormalDistribution(0, measurementNoise).createSampler(RandomSource.create(RandomSource.WELL_19937_C, 1001)); for (int i = 0; i < iterations; i++) { // get the "real" cannonball position diff --git a/src/test/java/org/apache/commons/math4/fitting/PolynomialCurveFitterTest.java b/src/test/java/org/apache/commons/math4/fitting/PolynomialCurveFitterTest.java index 95349b00a..581761112 100644 --- a/src/test/java/org/apache/commons/math4/fitting/PolynomialCurveFitterTest.java +++ b/src/test/java/org/apache/commons/math4/fitting/PolynomialCurveFitterTest.java @@ -20,8 +20,8 @@ import java.util.Random; import org.apache.commons.math4.TestUtils; import org.apache.commons.math4.analysis.polynomials.PolynomialFunction; -import org.apache.commons.math4.distribution.RealDistribution; -import org.apache.commons.math4.distribution.UniformRealDistribution; +import org.apache.commons.statistics.distribution.ContinuousDistribution; +import org.apache.commons.statistics.distribution.UniformContinuousDistribution; import org.apache.commons.math4.exception.ConvergenceException; import org.apache.commons.math4.fitting.PolynomialCurveFitter; import org.apache.commons.math4.fitting.WeightedObservedPoints; @@ -36,8 +36,8 @@ import org.junit.Test; public class PolynomialCurveFitterTest { @Test public void testFit() { - final RealDistribution.Sampler rng - = new UniformRealDistribution(-100, 100).createSampler(RandomSource.create(RandomSource.WELL_512_A, + final ContinuousDistribution.Sampler rng + = new UniformContinuousDistribution(-100, 100).createSampler(RandomSource.create(RandomSource.WELL_512_A, 64925784252L)); final double[] coeff = { 12.9, -3.4, 2.1 }; // 12.9 - 3.4 x + 2.1 x^2 final PolynomialFunction f = new PolynomialFunction(coeff); diff --git a/src/test/java/org/apache/commons/math4/fitting/SimpleCurveFitterTest.java b/src/test/java/org/apache/commons/math4/fitting/SimpleCurveFitterTest.java index e53c1ca49..36d3e92fa 100644 --- a/src/test/java/org/apache/commons/math4/fitting/SimpleCurveFitterTest.java +++ b/src/test/java/org/apache/commons/math4/fitting/SimpleCurveFitterTest.java @@ -21,8 +21,8 @@ import java.util.Random; import org.apache.commons.math4.TestUtils; import org.apache.commons.math4.analysis.ParametricUnivariateFunction; import org.apache.commons.math4.analysis.polynomials.PolynomialFunction; -import org.apache.commons.math4.distribution.RealDistribution; -import org.apache.commons.math4.distribution.UniformRealDistribution; +import org.apache.commons.statistics.distribution.ContinuousDistribution; +import org.apache.commons.statistics.distribution.UniformContinuousDistribution; import org.apache.commons.math4.fitting.SimpleCurveFitter; import org.apache.commons.math4.fitting.WeightedObservedPoints; import org.apache.commons.rng.simple.RandomSource; @@ -35,8 +35,8 @@ public class SimpleCurveFitterTest { @Test public void testPolynomialFit() { final Random randomizer = new Random(53882150042L); - final RealDistribution.Sampler rng - = new UniformRealDistribution(-100, 100).createSampler(RandomSource.create(RandomSource.WELL_512_A, + final ContinuousDistribution.Sampler rng + = new UniformContinuousDistribution(-100, 100).createSampler(RandomSource.create(RandomSource.WELL_512_A, 64925784253L)); final double[] coeff = { 12.9, -3.4, 2.1 }; // 12.9 - 3.4 x + 2.1 x^2 diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java index 464e18154..bddf86bb6 100644 --- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java +++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java @@ -262,7 +262,7 @@ public class LevenbergMarquardtOptimizerTest final double ySigma = 15; final double radius = 111.111; // The test is extremely sensitive to the seed. - final long seed = 59321761414L; + final long seed = 59321761419L; final RandomCirclePointGenerator factory = new RandomCirclePointGenerator(xCenter, yCenter, radius, xSigma, ySigma, diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/RandomCirclePointGenerator.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/RandomCirclePointGenerator.java index 312b67f34..c991629ee 100644 --- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/RandomCirclePointGenerator.java +++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/RandomCirclePointGenerator.java @@ -16,9 +16,9 @@ */ package org.apache.commons.math4.fitting.leastsquares; -import org.apache.commons.math4.distribution.NormalDistribution; -import org.apache.commons.math4.distribution.RealDistribution; -import org.apache.commons.math4.distribution.UniformRealDistribution; +import org.apache.commons.statistics.distribution.NormalDistribution; +import org.apache.commons.statistics.distribution.ContinuousDistribution; +import org.apache.commons.statistics.distribution.UniformContinuousDistribution; import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D; import org.apache.commons.rng.UniformRandomProvider; import org.apache.commons.rng.simple.RandomSource; @@ -30,11 +30,11 @@ import org.apache.commons.math4.util.MathUtils; */ public class RandomCirclePointGenerator { /** RNG for the x-coordinate of the center. */ - private final RealDistribution.Sampler cX; + private final ContinuousDistribution.Sampler cX; /** RNG for the y-coordinate of the center. */ - private final RealDistribution.Sampler cY; + private final ContinuousDistribution.Sampler cY; /** RNG for the parametric position of the point. */ - private final RealDistribution.Sampler tP; + private final ContinuousDistribution.Sampler tP; /** Radius of the circle. */ private final double radius; @@ -56,7 +56,7 @@ public class RandomCirclePointGenerator { this.radius = radius; cX = new NormalDistribution(x, xSigma).createSampler(rng); cY = new NormalDistribution(y, ySigma).createSampler(rng); - tP = new UniformRealDistribution(0, MathUtils.TWO_PI).createSampler(rng); + tP = new UniformContinuousDistribution(0, MathUtils.TWO_PI).createSampler(rng); } /** diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/RandomStraightLinePointGenerator.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/RandomStraightLinePointGenerator.java index 867f2ed4c..c440e650a 100644 --- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/RandomStraightLinePointGenerator.java +++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/RandomStraightLinePointGenerator.java @@ -19,9 +19,9 @@ package org.apache.commons.math4.fitting.leastsquares; import java.awt.geom.Point2D; -import org.apache.commons.math4.distribution.NormalDistribution; -import org.apache.commons.math4.distribution.RealDistribution; -import org.apache.commons.math4.distribution.UniformRealDistribution; +import org.apache.commons.statistics.distribution.NormalDistribution; +import org.apache.commons.statistics.distribution.ContinuousDistribution; +import org.apache.commons.statistics.distribution.UniformContinuousDistribution; import org.apache.commons.rng.UniformRandomProvider; import org.apache.commons.rng.simple.RandomSource; @@ -34,9 +34,9 @@ public class RandomStraightLinePointGenerator { /** Intercept. */ private final double intercept; /** RNG for the x-coordinate. */ - private final RealDistribution.Sampler x; + private final ContinuousDistribution.Sampler x; /** RNG for the error on the y-coordinate. */ - private final RealDistribution.Sampler error; + private final ContinuousDistribution.Sampler error; /** * The generator will create a cloud of points whose x-coordinates @@ -65,7 +65,7 @@ public class RandomStraightLinePointGenerator { slope = a; intercept = b; error = new NormalDistribution(0, sigma).createSampler(rng); - x = new UniformRealDistribution(lo, hi).createSampler(rng); + x = new UniformContinuousDistribution(lo, hi).createSampler(rng); } /** diff --git a/src/test/java/org/apache/commons/math4/linear/EigenDecompositionTest.java b/src/test/java/org/apache/commons/math4/linear/EigenDecompositionTest.java index df472a2dc..dc7853774 100644 --- a/src/test/java/org/apache/commons/math4/linear/EigenDecompositionTest.java +++ b/src/test/java/org/apache/commons/math4/linear/EigenDecompositionTest.java @@ -20,8 +20,8 @@ package org.apache.commons.math4.linear; import java.util.Arrays; import java.util.Random; -import org.apache.commons.math4.distribution.RealDistribution; -import org.apache.commons.math4.distribution.NormalDistribution; +import org.apache.commons.statistics.distribution.ContinuousDistribution; +import org.apache.commons.statistics.distribution.NormalDistribution; import org.apache.commons.math4.exception.MathUnsupportedOperationException; import org.apache.commons.math4.linear.ArrayRealVector; import org.apache.commons.math4.linear.EigenDecomposition; @@ -470,7 +470,7 @@ public class EigenDecompositionTest { public void testNormalDistributionUnsymmetricMatrix() { for (int run = 0; run < 100; run++) { Random r = new Random(System.currentTimeMillis()); - RealDistribution.Sampler dist + ContinuousDistribution.Sampler dist = new NormalDistribution(0.0, r.nextDouble() * 5).createSampler(RandomSource.create(RandomSource.WELL_512_A, 64925784252L)); diff --git a/src/test/java/org/apache/commons/math4/linear/HessenbergTransformerTest.java b/src/test/java/org/apache/commons/math4/linear/HessenbergTransformerTest.java index 758cea40a..08f983e7e 100644 --- a/src/test/java/org/apache/commons/math4/linear/HessenbergTransformerTest.java +++ b/src/test/java/org/apache/commons/math4/linear/HessenbergTransformerTest.java @@ -19,8 +19,8 @@ package org.apache.commons.math4.linear; import java.util.Random; -import org.apache.commons.math4.distribution.RealDistribution; -import org.apache.commons.math4.distribution.NormalDistribution; +import org.apache.commons.statistics.distribution.ContinuousDistribution; +import org.apache.commons.statistics.distribution.NormalDistribution; import org.apache.commons.math4.linear.HessenbergTransformer; import org.apache.commons.math4.linear.MatrixUtils; import org.apache.commons.math4.linear.NonSquareMatrixException; @@ -114,7 +114,7 @@ public class HessenbergTransformerTest { public void testRandomDataNormalDistribution() { for (int run = 0; run < 100; run++) { Random r = new Random(System.currentTimeMillis()); - RealDistribution.Sampler dist + ContinuousDistribution.Sampler dist = new NormalDistribution(0.0, r.nextDouble() * 5).createSampler(RandomSource.create(RandomSource.WELL_512_A, 64925784252L)); diff --git a/src/test/java/org/apache/commons/math4/linear/SchurTransformerTest.java b/src/test/java/org/apache/commons/math4/linear/SchurTransformerTest.java index e5b7ebb3a..e086dd301 100644 --- a/src/test/java/org/apache/commons/math4/linear/SchurTransformerTest.java +++ b/src/test/java/org/apache/commons/math4/linear/SchurTransformerTest.java @@ -19,8 +19,8 @@ package org.apache.commons.math4.linear; import java.util.Random; -import org.apache.commons.math4.distribution.RealDistribution; -import org.apache.commons.math4.distribution.NormalDistribution; +import org.apache.commons.statistics.distribution.ContinuousDistribution; +import org.apache.commons.statistics.distribution.NormalDistribution; import org.apache.commons.math4.linear.MatrixUtils; import org.apache.commons.math4.linear.NonSquareMatrixException; import org.apache.commons.math4.linear.RealMatrix; @@ -118,7 +118,7 @@ public class SchurTransformerTest { public void testRandomDataNormalDistribution() { for (int run = 0; run < 100; run++) { Random r = new Random(System.currentTimeMillis()); - RealDistribution.Sampler dist + ContinuousDistribution.Sampler dist = new NormalDistribution(0.0, r.nextDouble() * 5).createSampler(RandomSource.create(RandomSource.WELL_512_A, 64925784252L)); diff --git a/src/test/java/org/apache/commons/math4/stat/correlation/PearsonsCorrelationTest.java b/src/test/java/org/apache/commons/math4/stat/correlation/PearsonsCorrelationTest.java index c4c02113e..08dbabcab 100644 --- a/src/test/java/org/apache/commons/math4/stat/correlation/PearsonsCorrelationTest.java +++ b/src/test/java/org/apache/commons/math4/stat/correlation/PearsonsCorrelationTest.java @@ -17,7 +17,7 @@ package org.apache.commons.math4.stat.correlation; import org.apache.commons.math4.TestUtils; -import org.apache.commons.math4.distribution.TDistribution; +import org.apache.commons.statistics.distribution.TDistribution; import org.apache.commons.math4.exception.MathIllegalArgumentException; import org.apache.commons.math4.linear.BlockRealMatrix; import org.apache.commons.math4.linear.RealMatrix; diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/AggregateSummaryStatisticsTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/AggregateSummaryStatisticsTest.java index 2f31b4ca1..662ece67c 100644 --- a/src/test/java/org/apache/commons/math4/stat/descriptive/AggregateSummaryStatisticsTest.java +++ b/src/test/java/org/apache/commons/math4/stat/descriptive/AggregateSummaryStatisticsTest.java @@ -21,11 +21,11 @@ import java.util.ArrayList; import java.util.Collection; import org.apache.commons.math4.TestUtils; -import org.apache.commons.math4.distribution.IntegerDistribution; -import org.apache.commons.math4.distribution.RealDistribution; +import org.apache.commons.statistics.distribution.DiscreteDistribution; +import org.apache.commons.statistics.distribution.ContinuousDistribution; import org.apache.commons.math4.distribution.AbstractRealDistribution; -import org.apache.commons.math4.distribution.UniformIntegerDistribution; -import org.apache.commons.math4.distribution.UniformRealDistribution; +import org.apache.commons.statistics.distribution.UniformDiscreteDistribution; +import org.apache.commons.statistics.distribution.UniformContinuousDistribution; import org.apache.commons.numbers.core.Precision; import org.apache.commons.rng.simple.RandomSource; import org.junit.Assert; @@ -282,11 +282,11 @@ public class AggregateSummaryStatisticsTest { * @return array of random double values */ private double[] generateSample() { - final IntegerDistribution.Sampler size = - new UniformIntegerDistribution(10, 100).createSampler(RandomSource.create(RandomSource.WELL_512_A, + final DiscreteDistribution.Sampler size = + new UniformDiscreteDistribution(10, 100).createSampler(RandomSource.create(RandomSource.WELL_512_A, 327652)); - final RealDistribution.Sampler randomData - = new UniformRealDistribution(-100, 100).createSampler(RandomSource.create(RandomSource.WELL_512_A, + final ContinuousDistribution.Sampler randomData + = new UniformContinuousDistribution(-100, 100).createSampler(RandomSource.create(RandomSource.WELL_512_A, 64925784252L));; final int sampleSize = size.sample(); final double[] out = AbstractRealDistribution.sample(sampleSize, randomData); @@ -314,8 +314,8 @@ public class AggregateSummaryStatisticsTest { if (i == 4 || cur == length - 1) { next = length - 1; } else { - final IntegerDistribution.Sampler sampler = - new UniformIntegerDistribution(cur, length - 1).createSampler(RandomSource.create(RandomSource.WELL_512_A)); + final DiscreteDistribution.Sampler sampler = + new UniformDiscreteDistribution(cur, length - 1).createSampler(RandomSource.create(RandomSource.WELL_512_A)); next = sampler.sample(); } final int subLength = next - cur + 1; diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/UnivariateStatisticAbstractTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/UnivariateStatisticAbstractTest.java index 5ef2370f7..f837bf919 100644 --- a/src/test/java/org/apache/commons/math4/stat/descriptive/UnivariateStatisticAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/stat/descriptive/UnivariateStatisticAbstractTest.java @@ -20,10 +20,10 @@ import java.util.ArrayList; import java.util.List; import org.apache.commons.math4.TestUtils; -import org.apache.commons.math4.distribution.IntegerDistribution; -import org.apache.commons.math4.distribution.NormalDistribution; -import org.apache.commons.math4.distribution.RealDistribution; -import org.apache.commons.math4.distribution.UniformIntegerDistribution; +import org.apache.commons.statistics.distribution.DiscreteDistribution; +import org.apache.commons.statistics.distribution.NormalDistribution; +import org.apache.commons.statistics.distribution.ContinuousDistribution; +import org.apache.commons.statistics.distribution.UniformDiscreteDistribution; import org.apache.commons.math4.stat.descriptive.UnivariateStatistic; import org.apache.commons.math4.stat.descriptive.WeightedEvaluation; import org.apache.commons.math4.util.FastMath; @@ -179,9 +179,9 @@ public abstract class UnivariateStatisticAbstractTest { // Fill weights array with random int values between 1 and 5 int[] intWeights = new int[len]; - final IntegerDistribution.Sampler weightDist = - new UniformIntegerDistribution(1, 5).createSampler(RandomSource.create(RandomSource.WELL_512_A, - 234878544L)); + final DiscreteDistribution.Sampler weightDist = + new UniformDiscreteDistribution(1, 5).createSampler(RandomSource.create(RandomSource.WELL_512_A, + 234878544L)); for (int i = 0; i < len; i++) { intWeights[i] = weightDist.sample(); weights[i] = intWeights[i]; @@ -190,7 +190,7 @@ public abstract class UnivariateStatisticAbstractTest { // Fill values array with random data from N(mu, sigma) // and fill valuesList with values from values array with // values[i] repeated weights[i] times, each i - final RealDistribution.Sampler valueDist = + final ContinuousDistribution.Sampler valueDist = new NormalDistribution(mu, sigma).createSampler(RandomSource.create(RandomSource.WELL_512_A, 64925784252L)); List valuesList = new ArrayList<>(); diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PercentileTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PercentileTest.java index bbb4468d2..aa2c4c127 100644 --- a/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PercentileTest.java +++ b/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PercentileTest.java @@ -18,9 +18,9 @@ package org.apache.commons.math4.stat.descriptive.rank; import java.util.Arrays; -import org.apache.commons.math4.distribution.RealDistribution; +import org.apache.commons.statistics.distribution.ContinuousDistribution; import org.apache.commons.math4.distribution.AbstractRealDistribution; -import org.apache.commons.math4.distribution.NormalDistribution; +import org.apache.commons.statistics.distribution.NormalDistribution; import org.apache.commons.math4.exception.MathIllegalArgumentException; import org.apache.commons.math4.exception.NotANumberException; import org.apache.commons.math4.exception.NullArgumentException; @@ -587,7 +587,7 @@ public class PercentileTest extends UnivariateStatisticAbstractTest{ @Test public void testStoredVsDirect() { - final RealDistribution.Sampler sampler = + final ContinuousDistribution.Sampler sampler = new NormalDistribution(4000, 50).createSampler(RandomSource.create(RandomSource.JDK, Long.MAX_VALUE)); diff --git a/src/test/java/org/apache/commons/math4/stat/regression/GLSMultipleLinearRegressionTest.java b/src/test/java/org/apache/commons/math4/stat/regression/GLSMultipleLinearRegressionTest.java index 772d9c3e2..bb46c465c 100644 --- a/src/test/java/org/apache/commons/math4/stat/regression/GLSMultipleLinearRegressionTest.java +++ b/src/test/java/org/apache/commons/math4/stat/regression/GLSMultipleLinearRegressionTest.java @@ -29,8 +29,8 @@ import org.apache.commons.math4.random.CorrelatedRandomVectorGenerator; import org.apache.commons.math4.random.GaussianRandomGenerator; import org.apache.commons.rng.UniformRandomProvider; import org.apache.commons.rng.simple.RandomSource; -import org.apache.commons.math4.distribution.RealDistribution; -import org.apache.commons.math4.distribution.NormalDistribution; +import org.apache.commons.statistics.distribution.ContinuousDistribution; +import org.apache.commons.statistics.distribution.NormalDistribution; import org.apache.commons.math4.stat.correlation.Covariance; import org.apache.commons.math4.stat.descriptive.DescriptiveStatistics; import org.apache.commons.math4.stat.regression.GLSMultipleLinearRegression; @@ -223,7 +223,7 @@ public class GLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs @Test public void testGLSEfficiency() { final UniformRandomProvider rg = RandomSource.create(RandomSource.MT, 123456789L); - final RealDistribution.Sampler gauss = new NormalDistribution().createSampler(rg); + final ContinuousDistribution.Sampler gauss = new NormalDistribution(0, 1).createSampler(rg); // Assume model has 16 observations (will use Longley data). Start by generating // non-constant variances for the 16 error terms. diff --git a/src/test/java/org/apache/commons/math4/util/MathUtilsTest.java b/src/test/java/org/apache/commons/math4/util/MathUtilsTest.java index 2536f8480..466864e95 100644 --- a/src/test/java/org/apache/commons/math4/util/MathUtilsTest.java +++ b/src/test/java/org/apache/commons/math4/util/MathUtilsTest.java @@ -14,8 +14,8 @@ package org.apache.commons.math4.util; import org.apache.commons.numbers.angle.PlaneAngleRadians; -import org.apache.commons.math4.distribution.RealDistribution; -import org.apache.commons.math4.distribution.UniformRealDistribution; +import org.apache.commons.statistics.distribution.ContinuousDistribution; +import org.apache.commons.statistics.distribution.UniformContinuousDistribution; import org.apache.commons.math4.exception.MathArithmeticException; import org.apache.commons.math4.exception.NotFiniteNumberException; import org.apache.commons.math4.exception.NullArgumentException; @@ -103,8 +103,8 @@ public final class MathUtilsTest { // Generate 10 distinct random values for (int i = 0; i < 10; i++) { - final RealDistribution.Sampler u - = new UniformRealDistribution(i + 0.5, i + 0.75).createSampler(random); + final ContinuousDistribution.Sampler u + = new UniformContinuousDistribution(i + 0.5, i + 0.75).createSampler(random); original[i] = u.sample(); } diff --git a/src/test/java/org/apache/commons/math4/util/ResizableDoubleArrayTest.java b/src/test/java/org/apache/commons/math4/util/ResizableDoubleArrayTest.java index b63556ade..f88a28309 100644 --- a/src/test/java/org/apache/commons/math4/util/ResizableDoubleArrayTest.java +++ b/src/test/java/org/apache/commons/math4/util/ResizableDoubleArrayTest.java @@ -16,8 +16,8 @@ */ package org.apache.commons.math4.util; -import org.apache.commons.math4.distribution.IntegerDistribution; -import org.apache.commons.math4.distribution.UniformIntegerDistribution; +import org.apache.commons.statistics.distribution.DiscreteDistribution; +import org.apache.commons.statistics.distribution.UniformDiscreteDistribution; import org.apache.commons.math4.exception.MathIllegalArgumentException; import org.apache.commons.math4.exception.NullArgumentException; import org.apache.commons.rng.simple.RandomSource; @@ -322,8 +322,8 @@ public class ResizableDoubleArrayTest extends DoubleArrayAbstractTest { ResizableDoubleArray eDA2 = new ResizableDoubleArray(2); Assert.assertEquals("Initial number of elements should be 0", 0, eDA2.getNumElements()); - final IntegerDistribution.Sampler randomData = - new UniformIntegerDistribution(100, 1000).createSampler(RandomSource.create(RandomSource.WELL_19937_C)); + final DiscreteDistribution.Sampler randomData = + new UniformDiscreteDistribution(100, 1000).createSampler(RandomSource.create(RandomSource.WELL_19937_C)); final int iterations = randomData.sample(); for( int i = 0; i < iterations; i++) { @@ -344,9 +344,9 @@ public class ResizableDoubleArrayTest extends DoubleArrayAbstractTest { ResizableDoubleArray eDA3 = new ResizableDoubleArray(3, 3.0, 3.5); Assert.assertEquals("Initial number of elements should be 0", 0, eDA3.getNumElements() ); - final IntegerDistribution.Sampler randomData = - new UniformIntegerDistribution(100, 3000).createSampler(RandomSource.create(RandomSource.WELL_19937_C)); -; + final DiscreteDistribution.Sampler randomData = + new UniformDiscreteDistribution(100, 3000).createSampler(RandomSource.create(RandomSource.WELL_19937_C)); + final int iterations = randomData.sample(); for( int i = 0; i < iterations; i++) {