From 3c0c9d83e27e436f9d3646f177bcb0ac2fecbeab Mon Sep 17 00:00:00 2001 From: Gilles Date: Wed, 24 Jan 2018 16:16:00 +0100 Subject: [PATCH] MATH-1443: Depend on "Commons Statistics". --- pom.xml | 6 ++++++ .../math4/ml/neuralnet/FeatureInitializerFactory.java | 8 ++++---- .../math4/ml/neuralnet/sofm/TravellingSalesmanSolver.java | 6 +++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 2aaaa12c8..22a81ec29 100644 --- a/pom.xml +++ b/pom.xml @@ -365,6 +365,12 @@ + + org.apache.commons + commons-statistics-distribution + 0.1-SNAPSHOT + + org.apache.commons commons-numbers-core diff --git a/src/main/java/org/apache/commons/math4/ml/neuralnet/FeatureInitializerFactory.java b/src/main/java/org/apache/commons/math4/ml/neuralnet/FeatureInitializerFactory.java index 8aa6bb8dc..d1eb32ef8 100644 --- a/src/main/java/org/apache/commons/math4/ml/neuralnet/FeatureInitializerFactory.java +++ b/src/main/java/org/apache/commons/math4/ml/neuralnet/FeatureInitializerFactory.java @@ -19,8 +19,8 @@ package org.apache.commons.math4.ml.neuralnet; import org.apache.commons.math4.analysis.UnivariateFunction; import org.apache.commons.math4.analysis.function.Constant; -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.rng.simple.RandomSource; import org.apache.commons.rng.UniformRandomProvider; @@ -49,7 +49,7 @@ public class FeatureInitializerFactory { public static FeatureInitializer uniform(final UniformRandomProvider rng, final double min, final double max) { - return randomize(new UniformRealDistribution(min, max).createSampler(rng), + return randomize(new UniformContinuousDistribution(min, max).createSampler(rng), function(new Constant(0), 0, 0)); } @@ -103,7 +103,7 @@ public class FeatureInitializerFactory { * @return an initializer whose {@link FeatureInitializer#value() value} * method will return {@code orig.value() + random.sample()}. */ - public static FeatureInitializer randomize(final RealDistribution.Sampler random, + public static FeatureInitializer randomize(final ContinuousDistribution.Sampler random, final FeatureInitializer orig) { return new FeatureInitializer() { /** {@inheritDoc} */ diff --git a/src/test/java/org/apache/commons/math4/ml/neuralnet/sofm/TravellingSalesmanSolver.java b/src/test/java/org/apache/commons/math4/ml/neuralnet/sofm/TravellingSalesmanSolver.java index 2f16bb859..bd24f4ac6 100644 --- a/src/test/java/org/apache/commons/math4/ml/neuralnet/sofm/TravellingSalesmanSolver.java +++ b/src/test/java/org/apache/commons/math4/ml/neuralnet/sofm/TravellingSalesmanSolver.java @@ -28,8 +28,8 @@ import org.apache.commons.math4.analysis.FunctionUtils; import org.apache.commons.math4.analysis.UnivariateFunction; import org.apache.commons.math4.analysis.function.Constant; import org.apache.commons.math4.analysis.function.HarmonicOscillator; -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.MathUnsupportedOperationException; import org.apache.commons.math4.ml.distance.DistanceMeasure; import org.apache.commons.math4.ml.distance.EuclideanDistance; @@ -341,7 +341,7 @@ public class TravellingSalesmanSolver { final UnivariateFunction f1 = FunctionUtils.add(h1, new Constant(centre[0])); final UnivariateFunction f2 = FunctionUtils.add(h2, new Constant(centre[1])); - final RealDistribution u = new UniformRealDistribution(-0.05 * radius, 0.05 * radius); + final ContinuousDistribution u = new UniformContinuousDistribution(-0.05 * radius, 0.05 * radius); return new FeatureInitializer[] { FeatureInitializerFactory.randomize(u.createSampler(random),