MATH-1443: Depend on "Commons Statistics".

This commit is contained in:
Gilles 2018-01-25 18:31:10 +01:00
parent b2d4b2ac3a
commit 06bc5ac61a
23 changed files with 101 additions and 100 deletions

View File

@ -20,8 +20,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.apache.commons.math4.analysis.UnivariateFunction; import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.distribution.RealDistribution; import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.math4.distribution.UniformRealDistribution; import org.apache.commons.statistics.distribution.UniformContinuousDistribution;
import org.apache.commons.math4.exception.DimensionMismatchException; import org.apache.commons.math4.exception.DimensionMismatchException;
import org.apache.commons.math4.exception.NonMonotonicSequenceException; import org.apache.commons.math4.exception.NonMonotonicSequenceException;
import org.apache.commons.math4.exception.NullArgumentException; 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 UniformRandomProvider rng = RandomSource.create(RandomSource.WELL_19937_C, 1234567L); // "tol" depends on the seed.
final RealDistribution.Sampler distX = final ContinuousDistribution.Sampler distX =
new UniformRealDistribution(xValues[0], xValues[xValues.length - 1]).createSampler(rng); new UniformContinuousDistribution(xValues[0], xValues[xValues.length - 1]).createSampler(rng);
double sumError = 0; double sumError = 0;
for ( int i = 0; i < numberOfSamples; i++ ) for ( int i = 0; i < numberOfSamples; i++ )

View File

@ -17,8 +17,8 @@
package org.apache.commons.math4.analysis.interpolation; package org.apache.commons.math4.analysis.interpolation;
import org.apache.commons.math4.analysis.BivariateFunction; import org.apache.commons.math4.analysis.BivariateFunction;
import org.apache.commons.math4.distribution.RealDistribution; import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.math4.distribution.UniformRealDistribution; import org.apache.commons.statistics.distribution.UniformContinuousDistribution;
import org.apache.commons.math4.exception.DimensionMismatchException; import org.apache.commons.math4.exception.DimensionMismatchException;
import org.apache.commons.math4.exception.MathIllegalArgumentException; import org.apache.commons.math4.exception.MathIllegalArgumentException;
import org.apache.commons.math4.exception.OutOfRangeException; 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 UniformRandomProvider rng = RandomSource.create(RandomSource.WELL_19937_C, 1234567L);
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);
final RealDistribution.Sampler distY = new UniformRealDistribution(yValues[0], yValues[yValues.length - 1]).createSampler(rng); final ContinuousDistribution.Sampler distY = new UniformContinuousDistribution(yValues[0], yValues[yValues.length - 1]).createSampler(rng);
double sumError = 0; double sumError = 0;
for (int i = 0; i < numberOfSamples; i++) { for (int i = 0; i < numberOfSamples; i++) {

View File

@ -17,8 +17,8 @@
package org.apache.commons.math4.analysis.interpolation; package org.apache.commons.math4.analysis.interpolation;
import org.apache.commons.math4.analysis.BivariateFunction; import org.apache.commons.math4.analysis.BivariateFunction;
import org.apache.commons.math4.distribution.RealDistribution; import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.math4.distribution.UniformRealDistribution; import org.apache.commons.statistics.distribution.UniformContinuousDistribution;
import org.apache.commons.math4.exception.DimensionMismatchException; import org.apache.commons.math4.exception.DimensionMismatchException;
import org.apache.commons.math4.exception.MathIllegalArgumentException; import org.apache.commons.math4.exception.MathIllegalArgumentException;
import org.apache.commons.rng.UniformRandomProvider; import org.apache.commons.rng.UniformRandomProvider;
@ -148,8 +148,8 @@ public final class BicubicInterpolatorTest {
double x, y; double x, y;
final UniformRandomProvider rng = RandomSource.create(RandomSource.WELL_19937_C); final UniformRandomProvider rng = RandomSource.create(RandomSource.WELL_19937_C);
final RealDistribution.Sampler distX = new UniformRealDistribution(xval[0], xval[xval.length - 1]).createSampler(rng); final ContinuousDistribution.Sampler distX = new UniformContinuousDistribution(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 distY = new UniformContinuousDistribution(yval[0], yval[yval.length - 1]).createSampler(rng);
int count = 0; int count = 0;
while (true) { while (true) {

View File

@ -17,8 +17,8 @@
package org.apache.commons.math4.analysis.interpolation; package org.apache.commons.math4.analysis.interpolation;
import org.apache.commons.math4.analysis.BivariateFunction; import org.apache.commons.math4.analysis.BivariateFunction;
import org.apache.commons.math4.distribution.RealDistribution; import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.math4.distribution.UniformRealDistribution; import org.apache.commons.statistics.distribution.UniformContinuousDistribution;
import org.apache.commons.math4.exception.DimensionMismatchException; import org.apache.commons.math4.exception.DimensionMismatchException;
import org.apache.commons.math4.exception.InsufficientDataException; import org.apache.commons.math4.exception.InsufficientDataException;
import org.apache.commons.math4.exception.NonMonotonicSequenceException; 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 UniformRandomProvider rng = RandomSource.create(RandomSource.WELL_19937_C, 1234567L);
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);
final RealDistribution.Sampler distY = new UniformRealDistribution(yValues[0], yValues[yValues.length - 1]).createSampler(rng); final ContinuousDistribution.Sampler distY = new UniformContinuousDistribution(yValues[0], yValues[yValues.length - 1]).createSampler(rng);
double sumError = 0; double sumError = 0;
for (int i = 0; i < numberOfSamples; i++) { for (int i = 0; i < numberOfSamples; i++) {

View File

@ -17,8 +17,8 @@
package org.apache.commons.math4.analysis.interpolation; package org.apache.commons.math4.analysis.interpolation;
import org.apache.commons.math4.analysis.BivariateFunction; import org.apache.commons.math4.analysis.BivariateFunction;
import org.apache.commons.math4.distribution.RealDistribution; import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.math4.distribution.UniformRealDistribution; import org.apache.commons.statistics.distribution.UniformContinuousDistribution;
import org.apache.commons.math4.exception.DimensionMismatchException; import org.apache.commons.math4.exception.DimensionMismatchException;
import org.apache.commons.math4.exception.InsufficientDataException; import org.apache.commons.math4.exception.InsufficientDataException;
import org.apache.commons.math4.exception.NonMonotonicSequenceException; import org.apache.commons.math4.exception.NonMonotonicSequenceException;
@ -159,8 +159,8 @@ public final class PiecewiseBicubicSplineInterpolatorTest {
double x, y; double x, y;
final UniformRandomProvider rng = RandomSource.create(RandomSource.WELL_19937_C, 1234567L); 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 ContinuousDistribution.Sampler distX = new UniformContinuousDistribution(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 distY = new UniformContinuousDistribution(yval[0], yval[yval.length - 1]).createSampler(rng);
final int numSamples = 50; final int numSamples = 50;
final double tol = 2e-14; final double tol = 2e-14;
@ -211,8 +211,8 @@ public final class PiecewiseBicubicSplineInterpolatorTest {
double x, y; double x, y;
final UniformRandomProvider rng = RandomSource.create(RandomSource.WELL_19937_C, 1234567L); 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 ContinuousDistribution.Sampler distX = new UniformContinuousDistribution(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 distY = new UniformContinuousDistribution(yval[0], yval[yval.length - 1]).createSampler(rng);
final int numSamples = 50; final int numSamples = 50;
final double tol = 5e-13; final double tol = 5e-13;

View File

@ -17,8 +17,8 @@
package org.apache.commons.math4.analysis.interpolation; package org.apache.commons.math4.analysis.interpolation;
import org.apache.commons.math4.analysis.TrivariateFunction; import org.apache.commons.math4.analysis.TrivariateFunction;
import org.apache.commons.math4.distribution.RealDistribution; import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.math4.distribution.UniformRealDistribution; import org.apache.commons.statistics.distribution.UniformContinuousDistribution;
import org.apache.commons.math4.exception.DimensionMismatchException; import org.apache.commons.math4.exception.DimensionMismatchException;
import org.apache.commons.math4.exception.MathIllegalArgumentException; import org.apache.commons.math4.exception.MathIllegalArgumentException;
import org.apache.commons.rng.UniformRandomProvider; 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 UniformRandomProvider rng = RandomSource.create(RandomSource.WELL_19937_C, 1234568L);
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);
final RealDistribution.Sampler distY = new UniformRealDistribution(yValues[0], yValues[yValues.length - 1]).createSampler(rng); final ContinuousDistribution.Sampler distY = new UniformContinuousDistribution(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 distZ = new UniformContinuousDistribution(zValues[0], zValues[zValues.length - 1]).createSampler(rng);
double sumError = 0; double sumError = 0;
for (int i = 0; i < numberOfSamples; i++) { for (int i = 0; i < numberOfSamples; i++) {

View File

@ -25,6 +25,7 @@ import java.io.IOException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.math4.TestUtils; import org.apache.commons.math4.TestUtils;
import org.apache.commons.math4.analysis.UnivariateFunction; import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.integration.BaseAbstractUnivariateIntegrator; import org.apache.commons.math4.analysis.integration.BaseAbstractUnivariateIntegrator;
@ -329,7 +330,7 @@ public abstract class RealDistributionAbstractTest {
@Test @Test
public void testSampler() { public void testSampler() {
final int sampleSize = 1000; final int sampleSize = 1000;
final RealDistribution.Sampler sampler = final ContinuousDistribution.Sampler sampler =
distribution.createSampler(RandomSource.create(RandomSource.WELL_19937_C, 123456789L)); distribution.createSampler(RandomSource.create(RandomSource.WELL_19937_C, 123456789L));
final double[] sample = AbstractRealDistribution.sample(sampleSize, sampler); final double[] sample = AbstractRealDistribution.sample(sampleSize, sampler);
final double[] quartiles = TestUtils.getDistributionQuartiles(distribution); final double[] quartiles = TestUtils.getDistributionQuartiles(distribution);

View File

@ -14,8 +14,8 @@
package org.apache.commons.math4.filter; package org.apache.commons.math4.filter;
import org.apache.commons.math4.distribution.RealDistribution; import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.math4.distribution.NormalDistribution; import org.apache.commons.statistics.distribution.NormalDistribution;
import org.apache.commons.math4.filter.DefaultMeasurementModel; import org.apache.commons.math4.filter.DefaultMeasurementModel;
import org.apache.commons.math4.filter.DefaultProcessModel; import org.apache.commons.math4.filter.DefaultProcessModel;
import org.apache.commons.math4.filter.KalmanFilter; import org.apache.commons.math4.filter.KalmanFilter;
@ -126,7 +126,7 @@ public class KalmanFilterTest {
RealVector pNoise = new ArrayRealVector(1); RealVector pNoise = new ArrayRealVector(1);
RealVector mNoise = 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 // iterate 60 steps
for (int i = 0; i < 60; i++) { for (int i = 0; i < 60; i++) {
@ -215,7 +215,7 @@ public class KalmanFilterTest {
double[] expectedInitialState = new double[] { 0.0, 0.0 }; double[] expectedInitialState = new double[] { 0.0, 0.0 };
assertVectorEquals(expectedInitialState, filter.getStateEstimation()); 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( RealVector tmpPNoise = new ArrayRealVector(
new double[] { FastMath.pow(dt, 2d) / 2d, dt }); new double[] { FastMath.pow(dt, 2d) / 2d, dt });
@ -392,7 +392,7 @@ public class KalmanFilterTest {
final MeasurementModel mm = new DefaultMeasurementModel(H, R); final MeasurementModel mm = new DefaultMeasurementModel(H, R);
final KalmanFilter filter = new KalmanFilter(pm, mm); 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++) { for (int i = 0; i < iterations; i++) {
// get the "real" cannonball position // get the "real" cannonball position

View File

@ -20,8 +20,8 @@ import java.util.Random;
import org.apache.commons.math4.TestUtils; import org.apache.commons.math4.TestUtils;
import org.apache.commons.math4.analysis.polynomials.PolynomialFunction; import org.apache.commons.math4.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math4.distribution.RealDistribution; import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.math4.distribution.UniformRealDistribution; import org.apache.commons.statistics.distribution.UniformContinuousDistribution;
import org.apache.commons.math4.exception.ConvergenceException; import org.apache.commons.math4.exception.ConvergenceException;
import org.apache.commons.math4.fitting.PolynomialCurveFitter; import org.apache.commons.math4.fitting.PolynomialCurveFitter;
import org.apache.commons.math4.fitting.WeightedObservedPoints; import org.apache.commons.math4.fitting.WeightedObservedPoints;
@ -36,8 +36,8 @@ import org.junit.Test;
public class PolynomialCurveFitterTest { public class PolynomialCurveFitterTest {
@Test @Test
public void testFit() { public void testFit() {
final RealDistribution.Sampler rng final ContinuousDistribution.Sampler rng
= new UniformRealDistribution(-100, 100).createSampler(RandomSource.create(RandomSource.WELL_512_A, = new UniformContinuousDistribution(-100, 100).createSampler(RandomSource.create(RandomSource.WELL_512_A,
64925784252L)); 64925784252L));
final double[] coeff = { 12.9, -3.4, 2.1 }; // 12.9 - 3.4 x + 2.1 x^2 final double[] coeff = { 12.9, -3.4, 2.1 }; // 12.9 - 3.4 x + 2.1 x^2
final PolynomialFunction f = new PolynomialFunction(coeff); final PolynomialFunction f = new PolynomialFunction(coeff);

View File

@ -21,8 +21,8 @@ import java.util.Random;
import org.apache.commons.math4.TestUtils; import org.apache.commons.math4.TestUtils;
import org.apache.commons.math4.analysis.ParametricUnivariateFunction; import org.apache.commons.math4.analysis.ParametricUnivariateFunction;
import org.apache.commons.math4.analysis.polynomials.PolynomialFunction; import org.apache.commons.math4.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math4.distribution.RealDistribution; import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.math4.distribution.UniformRealDistribution; import org.apache.commons.statistics.distribution.UniformContinuousDistribution;
import org.apache.commons.math4.fitting.SimpleCurveFitter; import org.apache.commons.math4.fitting.SimpleCurveFitter;
import org.apache.commons.math4.fitting.WeightedObservedPoints; import org.apache.commons.math4.fitting.WeightedObservedPoints;
import org.apache.commons.rng.simple.RandomSource; import org.apache.commons.rng.simple.RandomSource;
@ -35,8 +35,8 @@ public class SimpleCurveFitterTest {
@Test @Test
public void testPolynomialFit() { public void testPolynomialFit() {
final Random randomizer = new Random(53882150042L); final Random randomizer = new Random(53882150042L);
final RealDistribution.Sampler rng final ContinuousDistribution.Sampler rng
= new UniformRealDistribution(-100, 100).createSampler(RandomSource.create(RandomSource.WELL_512_A, = new UniformContinuousDistribution(-100, 100).createSampler(RandomSource.create(RandomSource.WELL_512_A,
64925784253L)); 64925784253L));
final double[] coeff = { 12.9, -3.4, 2.1 }; // 12.9 - 3.4 x + 2.1 x^2 final double[] coeff = { 12.9, -3.4, 2.1 }; // 12.9 - 3.4 x + 2.1 x^2

View File

@ -262,7 +262,7 @@ public class LevenbergMarquardtOptimizerTest
final double ySigma = 15; final double ySigma = 15;
final double radius = 111.111; final double radius = 111.111;
// The test is extremely sensitive to the seed. // The test is extremely sensitive to the seed.
final long seed = 59321761414L; final long seed = 59321761419L;
final RandomCirclePointGenerator factory final RandomCirclePointGenerator factory
= new RandomCirclePointGenerator(xCenter, yCenter, radius, = new RandomCirclePointGenerator(xCenter, yCenter, radius,
xSigma, ySigma, xSigma, ySigma,

View File

@ -16,9 +16,9 @@
*/ */
package org.apache.commons.math4.fitting.leastsquares; package org.apache.commons.math4.fitting.leastsquares;
import org.apache.commons.math4.distribution.NormalDistribution; import org.apache.commons.statistics.distribution.NormalDistribution;
import org.apache.commons.math4.distribution.RealDistribution; import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.math4.distribution.UniformRealDistribution; import org.apache.commons.statistics.distribution.UniformContinuousDistribution;
import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D; import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.rng.UniformRandomProvider; import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource; import org.apache.commons.rng.simple.RandomSource;
@ -30,11 +30,11 @@ import org.apache.commons.math4.util.MathUtils;
*/ */
public class RandomCirclePointGenerator { public class RandomCirclePointGenerator {
/** RNG for the x-coordinate of the center. */ /** 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. */ /** 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. */ /** RNG for the parametric position of the point. */
private final RealDistribution.Sampler tP; private final ContinuousDistribution.Sampler tP;
/** Radius of the circle. */ /** Radius of the circle. */
private final double radius; private final double radius;
@ -56,7 +56,7 @@ public class RandomCirclePointGenerator {
this.radius = radius; this.radius = radius;
cX = new NormalDistribution(x, xSigma).createSampler(rng); cX = new NormalDistribution(x, xSigma).createSampler(rng);
cY = new NormalDistribution(y, ySigma).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);
} }
/** /**

View File

@ -19,9 +19,9 @@ package org.apache.commons.math4.fitting.leastsquares;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import org.apache.commons.math4.distribution.NormalDistribution; import org.apache.commons.statistics.distribution.NormalDistribution;
import org.apache.commons.math4.distribution.RealDistribution; import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.math4.distribution.UniformRealDistribution; import org.apache.commons.statistics.distribution.UniformContinuousDistribution;
import org.apache.commons.rng.UniformRandomProvider; import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource; import org.apache.commons.rng.simple.RandomSource;
@ -34,9 +34,9 @@ public class RandomStraightLinePointGenerator {
/** Intercept. */ /** Intercept. */
private final double intercept; private final double intercept;
/** RNG for the x-coordinate. */ /** RNG for the x-coordinate. */
private final RealDistribution.Sampler x; private final ContinuousDistribution.Sampler x;
/** RNG for the error on the y-coordinate. */ /** 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 * The generator will create a cloud of points whose x-coordinates
@ -65,7 +65,7 @@ public class RandomStraightLinePointGenerator {
slope = a; slope = a;
intercept = b; intercept = b;
error = new NormalDistribution(0, sigma).createSampler(rng); error = new NormalDistribution(0, sigma).createSampler(rng);
x = new UniformRealDistribution(lo, hi).createSampler(rng); x = new UniformContinuousDistribution(lo, hi).createSampler(rng);
} }
/** /**

View File

@ -20,8 +20,8 @@ package org.apache.commons.math4.linear;
import java.util.Arrays; import java.util.Arrays;
import java.util.Random; import java.util.Random;
import org.apache.commons.math4.distribution.RealDistribution; import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.math4.distribution.NormalDistribution; import org.apache.commons.statistics.distribution.NormalDistribution;
import org.apache.commons.math4.exception.MathUnsupportedOperationException; import org.apache.commons.math4.exception.MathUnsupportedOperationException;
import org.apache.commons.math4.linear.ArrayRealVector; import org.apache.commons.math4.linear.ArrayRealVector;
import org.apache.commons.math4.linear.EigenDecomposition; import org.apache.commons.math4.linear.EigenDecomposition;
@ -470,7 +470,7 @@ public class EigenDecompositionTest {
public void testNormalDistributionUnsymmetricMatrix() { public void testNormalDistributionUnsymmetricMatrix() {
for (int run = 0; run < 100; run++) { for (int run = 0; run < 100; run++) {
Random r = new Random(System.currentTimeMillis()); 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, = new NormalDistribution(0.0, r.nextDouble() * 5).createSampler(RandomSource.create(RandomSource.WELL_512_A,
64925784252L)); 64925784252L));

View File

@ -19,8 +19,8 @@ package org.apache.commons.math4.linear;
import java.util.Random; import java.util.Random;
import org.apache.commons.math4.distribution.RealDistribution; import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.math4.distribution.NormalDistribution; import org.apache.commons.statistics.distribution.NormalDistribution;
import org.apache.commons.math4.linear.HessenbergTransformer; import org.apache.commons.math4.linear.HessenbergTransformer;
import org.apache.commons.math4.linear.MatrixUtils; import org.apache.commons.math4.linear.MatrixUtils;
import org.apache.commons.math4.linear.NonSquareMatrixException; import org.apache.commons.math4.linear.NonSquareMatrixException;
@ -114,7 +114,7 @@ public class HessenbergTransformerTest {
public void testRandomDataNormalDistribution() { public void testRandomDataNormalDistribution() {
for (int run = 0; run < 100; run++) { for (int run = 0; run < 100; run++) {
Random r = new Random(System.currentTimeMillis()); 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, = new NormalDistribution(0.0, r.nextDouble() * 5).createSampler(RandomSource.create(RandomSource.WELL_512_A,
64925784252L)); 64925784252L));

View File

@ -19,8 +19,8 @@ package org.apache.commons.math4.linear;
import java.util.Random; import java.util.Random;
import org.apache.commons.math4.distribution.RealDistribution; import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.math4.distribution.NormalDistribution; import org.apache.commons.statistics.distribution.NormalDistribution;
import org.apache.commons.math4.linear.MatrixUtils; import org.apache.commons.math4.linear.MatrixUtils;
import org.apache.commons.math4.linear.NonSquareMatrixException; import org.apache.commons.math4.linear.NonSquareMatrixException;
import org.apache.commons.math4.linear.RealMatrix; import org.apache.commons.math4.linear.RealMatrix;
@ -118,7 +118,7 @@ public class SchurTransformerTest {
public void testRandomDataNormalDistribution() { public void testRandomDataNormalDistribution() {
for (int run = 0; run < 100; run++) { for (int run = 0; run < 100; run++) {
Random r = new Random(System.currentTimeMillis()); 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, = new NormalDistribution(0.0, r.nextDouble() * 5).createSampler(RandomSource.create(RandomSource.WELL_512_A,
64925784252L)); 64925784252L));

View File

@ -17,7 +17,7 @@
package org.apache.commons.math4.stat.correlation; package org.apache.commons.math4.stat.correlation;
import org.apache.commons.math4.TestUtils; 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.exception.MathIllegalArgumentException;
import org.apache.commons.math4.linear.BlockRealMatrix; import org.apache.commons.math4.linear.BlockRealMatrix;
import org.apache.commons.math4.linear.RealMatrix; import org.apache.commons.math4.linear.RealMatrix;

View File

@ -21,11 +21,11 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import org.apache.commons.math4.TestUtils; import org.apache.commons.math4.TestUtils;
import org.apache.commons.math4.distribution.IntegerDistribution; import org.apache.commons.statistics.distribution.DiscreteDistribution;
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.AbstractRealDistribution;
import org.apache.commons.math4.distribution.UniformIntegerDistribution; import org.apache.commons.statistics.distribution.UniformDiscreteDistribution;
import org.apache.commons.math4.distribution.UniformRealDistribution; import org.apache.commons.statistics.distribution.UniformContinuousDistribution;
import org.apache.commons.numbers.core.Precision; import org.apache.commons.numbers.core.Precision;
import org.apache.commons.rng.simple.RandomSource; import org.apache.commons.rng.simple.RandomSource;
import org.junit.Assert; import org.junit.Assert;
@ -282,11 +282,11 @@ public class AggregateSummaryStatisticsTest {
* @return array of random double values * @return array of random double values
*/ */
private double[] generateSample() { private double[] generateSample() {
final IntegerDistribution.Sampler size = final DiscreteDistribution.Sampler size =
new UniformIntegerDistribution(10, 100).createSampler(RandomSource.create(RandomSource.WELL_512_A, new UniformDiscreteDistribution(10, 100).createSampler(RandomSource.create(RandomSource.WELL_512_A,
327652)); 327652));
final RealDistribution.Sampler randomData final ContinuousDistribution.Sampler randomData
= new UniformRealDistribution(-100, 100).createSampler(RandomSource.create(RandomSource.WELL_512_A, = new UniformContinuousDistribution(-100, 100).createSampler(RandomSource.create(RandomSource.WELL_512_A,
64925784252L));; 64925784252L));;
final int sampleSize = size.sample(); final int sampleSize = size.sample();
final double[] out = AbstractRealDistribution.sample(sampleSize, randomData); final double[] out = AbstractRealDistribution.sample(sampleSize, randomData);
@ -314,8 +314,8 @@ public class AggregateSummaryStatisticsTest {
if (i == 4 || cur == length - 1) { if (i == 4 || cur == length - 1) {
next = length - 1; next = length - 1;
} else { } else {
final IntegerDistribution.Sampler sampler = final DiscreteDistribution.Sampler sampler =
new UniformIntegerDistribution(cur, length - 1).createSampler(RandomSource.create(RandomSource.WELL_512_A)); new UniformDiscreteDistribution(cur, length - 1).createSampler(RandomSource.create(RandomSource.WELL_512_A));
next = sampler.sample(); next = sampler.sample();
} }
final int subLength = next - cur + 1; final int subLength = next - cur + 1;

View File

@ -20,10 +20,10 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.math4.TestUtils; import org.apache.commons.math4.TestUtils;
import org.apache.commons.math4.distribution.IntegerDistribution; import org.apache.commons.statistics.distribution.DiscreteDistribution;
import org.apache.commons.math4.distribution.NormalDistribution; import org.apache.commons.statistics.distribution.NormalDistribution;
import org.apache.commons.math4.distribution.RealDistribution; import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.math4.distribution.UniformIntegerDistribution; import org.apache.commons.statistics.distribution.UniformDiscreteDistribution;
import org.apache.commons.math4.stat.descriptive.UnivariateStatistic; import org.apache.commons.math4.stat.descriptive.UnivariateStatistic;
import org.apache.commons.math4.stat.descriptive.WeightedEvaluation; import org.apache.commons.math4.stat.descriptive.WeightedEvaluation;
import org.apache.commons.math4.util.FastMath; 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 // Fill weights array with random int values between 1 and 5
int[] intWeights = new int[len]; int[] intWeights = new int[len];
final IntegerDistribution.Sampler weightDist = final DiscreteDistribution.Sampler weightDist =
new UniformIntegerDistribution(1, 5).createSampler(RandomSource.create(RandomSource.WELL_512_A, new UniformDiscreteDistribution(1, 5).createSampler(RandomSource.create(RandomSource.WELL_512_A,
234878544L)); 234878544L));
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
intWeights[i] = weightDist.sample(); intWeights[i] = weightDist.sample();
weights[i] = intWeights[i]; weights[i] = intWeights[i];
@ -190,7 +190,7 @@ public abstract class UnivariateStatisticAbstractTest {
// Fill values array with random data from N(mu, sigma) // Fill values array with random data from N(mu, sigma)
// and fill valuesList with values from values array with // and fill valuesList with values from values array with
// values[i] repeated weights[i] times, each i // 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, new NormalDistribution(mu, sigma).createSampler(RandomSource.create(RandomSource.WELL_512_A,
64925784252L)); 64925784252L));
List<Double> valuesList = new ArrayList<>(); List<Double> valuesList = new ArrayList<>();

View File

@ -18,9 +18,9 @@ package org.apache.commons.math4.stat.descriptive.rank;
import java.util.Arrays; 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.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.MathIllegalArgumentException;
import org.apache.commons.math4.exception.NotANumberException; import org.apache.commons.math4.exception.NotANumberException;
import org.apache.commons.math4.exception.NullArgumentException; import org.apache.commons.math4.exception.NullArgumentException;
@ -587,7 +587,7 @@ public class PercentileTest extends UnivariateStatisticAbstractTest{
@Test @Test
public void testStoredVsDirect() { public void testStoredVsDirect() {
final RealDistribution.Sampler sampler = final ContinuousDistribution.Sampler sampler =
new NormalDistribution(4000, 50).createSampler(RandomSource.create(RandomSource.JDK, new NormalDistribution(4000, 50).createSampler(RandomSource.create(RandomSource.JDK,
Long.MAX_VALUE)); Long.MAX_VALUE));

View File

@ -29,8 +29,8 @@ import org.apache.commons.math4.random.CorrelatedRandomVectorGenerator;
import org.apache.commons.math4.random.GaussianRandomGenerator; import org.apache.commons.math4.random.GaussianRandomGenerator;
import org.apache.commons.rng.UniformRandomProvider; import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource; import org.apache.commons.rng.simple.RandomSource;
import org.apache.commons.math4.distribution.RealDistribution; import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.math4.distribution.NormalDistribution; import org.apache.commons.statistics.distribution.NormalDistribution;
import org.apache.commons.math4.stat.correlation.Covariance; import org.apache.commons.math4.stat.correlation.Covariance;
import org.apache.commons.math4.stat.descriptive.DescriptiveStatistics; import org.apache.commons.math4.stat.descriptive.DescriptiveStatistics;
import org.apache.commons.math4.stat.regression.GLSMultipleLinearRegression; import org.apache.commons.math4.stat.regression.GLSMultipleLinearRegression;
@ -223,7 +223,7 @@ public class GLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
@Test @Test
public void testGLSEfficiency() { public void testGLSEfficiency() {
final UniformRandomProvider rg = RandomSource.create(RandomSource.MT, 123456789L); 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 // Assume model has 16 observations (will use Longley data). Start by generating
// non-constant variances for the 16 error terms. // non-constant variances for the 16 error terms.

View File

@ -14,8 +14,8 @@
package org.apache.commons.math4.util; package org.apache.commons.math4.util;
import org.apache.commons.numbers.angle.PlaneAngleRadians; import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.math4.distribution.RealDistribution; import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.math4.distribution.UniformRealDistribution; import org.apache.commons.statistics.distribution.UniformContinuousDistribution;
import org.apache.commons.math4.exception.MathArithmeticException; import org.apache.commons.math4.exception.MathArithmeticException;
import org.apache.commons.math4.exception.NotFiniteNumberException; import org.apache.commons.math4.exception.NotFiniteNumberException;
import org.apache.commons.math4.exception.NullArgumentException; import org.apache.commons.math4.exception.NullArgumentException;
@ -103,8 +103,8 @@ public final class MathUtilsTest {
// Generate 10 distinct random values // Generate 10 distinct random values
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
final RealDistribution.Sampler u final ContinuousDistribution.Sampler u
= new UniformRealDistribution(i + 0.5, i + 0.75).createSampler(random); = new UniformContinuousDistribution(i + 0.5, i + 0.75).createSampler(random);
original[i] = u.sample(); original[i] = u.sample();
} }

View File

@ -16,8 +16,8 @@
*/ */
package org.apache.commons.math4.util; package org.apache.commons.math4.util;
import org.apache.commons.math4.distribution.IntegerDistribution; import org.apache.commons.statistics.distribution.DiscreteDistribution;
import org.apache.commons.math4.distribution.UniformIntegerDistribution; import org.apache.commons.statistics.distribution.UniformDiscreteDistribution;
import org.apache.commons.math4.exception.MathIllegalArgumentException; import org.apache.commons.math4.exception.MathIllegalArgumentException;
import org.apache.commons.math4.exception.NullArgumentException; import org.apache.commons.math4.exception.NullArgumentException;
import org.apache.commons.rng.simple.RandomSource; import org.apache.commons.rng.simple.RandomSource;
@ -322,8 +322,8 @@ public class ResizableDoubleArrayTest extends DoubleArrayAbstractTest {
ResizableDoubleArray eDA2 = new ResizableDoubleArray(2); ResizableDoubleArray eDA2 = new ResizableDoubleArray(2);
Assert.assertEquals("Initial number of elements should be 0", 0, eDA2.getNumElements()); Assert.assertEquals("Initial number of elements should be 0", 0, eDA2.getNumElements());
final IntegerDistribution.Sampler randomData = final DiscreteDistribution.Sampler randomData =
new UniformIntegerDistribution(100, 1000).createSampler(RandomSource.create(RandomSource.WELL_19937_C)); new UniformDiscreteDistribution(100, 1000).createSampler(RandomSource.create(RandomSource.WELL_19937_C));
final int iterations = randomData.sample(); final int iterations = randomData.sample();
for( int i = 0; i < iterations; i++) { 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); ResizableDoubleArray eDA3 = new ResizableDoubleArray(3, 3.0, 3.5);
Assert.assertEquals("Initial number of elements should be 0", 0, eDA3.getNumElements() ); Assert.assertEquals("Initial number of elements should be 0", 0, eDA3.getNumElements() );
final IntegerDistribution.Sampler randomData = final DiscreteDistribution.Sampler randomData =
new UniformIntegerDistribution(100, 3000).createSampler(RandomSource.create(RandomSource.WELL_19937_C)); new UniformDiscreteDistribution(100, 3000).createSampler(RandomSource.create(RandomSource.WELL_19937_C));
;
final int iterations = randomData.sample(); final int iterations = randomData.sample();
for( int i = 0; i < iterations; i++) { for( int i = 0; i < iterations; i++) {