Depend on Commons RNG v1.0 official release.
This commit is contained in:
parent
af1b5872ab
commit
b1d38d9bf2
16
pom.xml
16
pom.xml
|
@ -362,8 +362,20 @@
|
|||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-rng</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<artifactId>commons-rng-client-api</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-rng-simple</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-rng-sampling</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
|
@ -23,6 +23,9 @@ import org.apache.commons.math4.exception.NumberIsTooLargeException;
|
|||
import org.apache.commons.math4.exception.OutOfRangeException;
|
||||
import org.apache.commons.math4.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.sampling.distribution.InverseTransformDiscreteSampler;
|
||||
import org.apache.commons.rng.sampling.distribution.DiscreteInverseCumulativeProbabilityFunction;
|
||||
import org.apache.commons.rng.sampling.distribution.DiscreteSampler;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
|
||||
/**
|
||||
|
@ -195,10 +198,26 @@ public abstract class AbstractIntegerDistribution implements IntegerDistribution
|
|||
@Override
|
||||
public IntegerDistribution.Sampler createSampler(final UniformRandomProvider rng) {
|
||||
return new IntegerDistribution.Sampler() {
|
||||
private final DiscreteSampler sampler =
|
||||
new InverseTransformDiscreteSampler(rng, createICPF());
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int sample() {
|
||||
return inverseCumulativeProbability(rng.nextDouble());
|
||||
return sampler.sample();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an instance for use by {@link #createSampler(UniformRandomProvider)}
|
||||
*/
|
||||
private DiscreteInverseCumulativeProbabilityFunction createICPF() {
|
||||
return new DiscreteInverseCumulativeProbabilityFunction() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int inverseCumulativeProbability(double p) {
|
||||
return AbstractIntegerDistribution.this.inverseCumulativeProbability(p);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -24,6 +24,9 @@ import org.apache.commons.math4.exception.NumberIsTooLargeException;
|
|||
import org.apache.commons.math4.exception.OutOfRangeException;
|
||||
import org.apache.commons.math4.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.sampling.distribution.InverseTransformContinuousSampler;
|
||||
import org.apache.commons.rng.sampling.distribution.ContinuousInverseCumulativeProbabilityFunction;
|
||||
import org.apache.commons.rng.sampling.distribution.ContinuousSampler;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
|
||||
/**
|
||||
|
@ -243,10 +246,26 @@ public abstract class AbstractRealDistribution
|
|||
@Override
|
||||
public RealDistribution.Sampler createSampler(final UniformRandomProvider rng) {
|
||||
return new RealDistribution.Sampler() {
|
||||
private final ContinuousSampler sampler =
|
||||
new InverseTransformContinuousSampler(rng, createICPF());
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double sample() {
|
||||
return inverseCumulativeProbability(rng.nextDouble());
|
||||
return sampler.sample();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an instance for use by {@link #createSampler(UniformRandomProvider)}
|
||||
*/
|
||||
private ContinuousInverseCumulativeProbabilityFunction createICPF() {
|
||||
return new ContinuousInverseCumulativeProbabilityFunction() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double inverseCumulativeProbability(double p) {
|
||||
return AbstractRealDistribution.this.inverseCumulativeProbability(p);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -18,11 +18,12 @@ package org.apache.commons.math4.distribution;
|
|||
|
||||
import org.apache.commons.math4.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math4.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.math4.special.Beta;
|
||||
import org.apache.commons.math4.special.Gamma;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.Precision;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.sampling.distribution.ContinuousSampler;
|
||||
import org.apache.commons.rng.sampling.distribution.ChengBetaSampler;
|
||||
|
||||
/**
|
||||
* Implements the Beta distribution.
|
||||
|
@ -227,150 +228,15 @@ public class BetaDistribution extends AbstractRealDistribution {
|
|||
*/
|
||||
@Override
|
||||
public RealDistribution.Sampler createSampler(final UniformRandomProvider rng) {
|
||||
return new ChengBetaSampler(rng, alpha, beta);
|
||||
}
|
||||
return new RealDistribution.Sampler() {
|
||||
private final ContinuousSampler sampler =
|
||||
new ChengBetaSampler(rng, alpha, beta);
|
||||
|
||||
/**
|
||||
* Utility class implementing Cheng's algorithms for beta distribution sampling.
|
||||
*
|
||||
* <blockquote>
|
||||
* <pre>
|
||||
* R. C. H. Cheng,
|
||||
* "Generating beta variates with nonintegral shape parameters",
|
||||
* Communications of the ACM, 21, 317-322, 1978.
|
||||
* </pre>
|
||||
* </blockquote>
|
||||
*
|
||||
* @since 3.6
|
||||
*/
|
||||
private static class ChengBetaSampler implements RealDistribution.Sampler {
|
||||
/** RNG (uniform distribution). */
|
||||
private final UniformRandomProvider rng;
|
||||
/** First shape parameter. */
|
||||
private final double alphaShape;
|
||||
/** Second shape parameter. */
|
||||
private final double betaShape;
|
||||
|
||||
/**
|
||||
* Creates a sampler instance.
|
||||
*
|
||||
* @param generator RNG.
|
||||
* @param alpha Distribution first shape parameter.
|
||||
* @param beta Distribution second shape parameter.
|
||||
*/
|
||||
ChengBetaSampler(UniformRandomProvider generator,
|
||||
double alpha,
|
||||
double beta) {
|
||||
rng = generator;
|
||||
alphaShape = alpha;
|
||||
betaShape = beta;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double sample() {
|
||||
final double a = FastMath.min(alphaShape, betaShape);
|
||||
final double b = FastMath.max(alphaShape, betaShape);
|
||||
|
||||
if (a > 1) {
|
||||
return algorithmBB(alphaShape, a, b);
|
||||
} else {
|
||||
return algorithmBC(alphaShape, b, a);
|
||||
/**{@inheritDoc} */
|
||||
@Override
|
||||
public double sample() {
|
||||
return sampler.sample();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes one sample using Cheng's BB algorithm, when α and
|
||||
* β are both larger than 1.
|
||||
*
|
||||
* @param a0 First shape parameter (α).
|
||||
* @param a Min(α, β) where α, β are the shape parameters.
|
||||
* @param b Max(α, β) where α, β are the shape parameters.
|
||||
* @return a random sample.
|
||||
*/
|
||||
private double algorithmBB(double a0,
|
||||
double a,
|
||||
double b) {
|
||||
final double alpha = a + b;
|
||||
final double beta = FastMath.sqrt((alpha - 2) / (2 * a * b - alpha));
|
||||
final double gamma = a + 1 / beta;
|
||||
|
||||
double r;
|
||||
double w;
|
||||
double t;
|
||||
do {
|
||||
final double u1 = rng.nextDouble();
|
||||
final double u2 = rng.nextDouble();
|
||||
final double v = beta * (FastMath.log(u1) - FastMath.log1p(-u1));
|
||||
w = a * FastMath.exp(v);
|
||||
final double z = u1 * u1 * u2;
|
||||
r = gamma * v - 1.3862944;
|
||||
final double s = a + r - w;
|
||||
if (s + 2.609438 >= 5 * z) {
|
||||
break;
|
||||
}
|
||||
|
||||
t = FastMath.log(z);
|
||||
if (s >= t) {
|
||||
break;
|
||||
}
|
||||
} while (r + alpha * (FastMath.log(alpha) - FastMath.log(b + w)) < t);
|
||||
|
||||
w = FastMath.min(w, Double.MAX_VALUE);
|
||||
|
||||
return Precision.equals(a, a0) ? w / (b + w) : b / (b + w);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes one sample using Cheng's BC algorithm, when at least one
|
||||
* of α and β is smaller than 1.
|
||||
*
|
||||
* @param a0 First shape parameter (α).
|
||||
* @param a Max(α, β) where α, β are the shape parameters.
|
||||
* @param b min(α, β) where α, β are the shape parameters.
|
||||
* @return a random sample.
|
||||
*/
|
||||
private double algorithmBC(double a0,
|
||||
double a,
|
||||
double b) {
|
||||
final double alpha = a + b;
|
||||
final double beta = 1 / b;
|
||||
final double delta = 1 + a - b;
|
||||
final double k1 = delta * (0.0138889 + 0.0416667 * b) / (a * beta - 0.777778);
|
||||
final double k2 = 0.25 + (0.5 + 0.25 / delta) * b;
|
||||
|
||||
double w;
|
||||
while (true) {
|
||||
final double u1 = rng.nextDouble();
|
||||
final double u2 = rng.nextDouble();
|
||||
final double y = u1 * u2;
|
||||
final double z = u1 * y;
|
||||
if (u1 < 0.5) {
|
||||
if (0.25 * u2 + z - y >= k1) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (z <= 0.25) {
|
||||
final double v = beta * (FastMath.log(u1) - FastMath.log1p(-u1));
|
||||
w = a * FastMath.exp(v);
|
||||
break;
|
||||
}
|
||||
|
||||
if (z >= k2) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
final double v = beta * (FastMath.log(u1) - FastMath.log1p(-u1));
|
||||
w = a * FastMath.exp(v);
|
||||
if (alpha * (FastMath.log(alpha) - FastMath.log(b + w) + v) - 1.3862944 >= FastMath.log(z)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
w = FastMath.min(w, Double.MAX_VALUE);
|
||||
|
||||
return Precision.equals(a, a0) ? w / (b + w) : b / (b + w);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,10 +19,10 @@ package org.apache.commons.math4.distribution;
|
|||
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math4.exception.OutOfRangeException;
|
||||
import org.apache.commons.math4.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.math4.util.CombinatoricsUtils;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.ResizableDoubleArray;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.sampling.distribution.ContinuousSampler;
|
||||
import org.apache.commons.rng.sampling.distribution.AhrensDieterExponentialSampler;
|
||||
|
||||
/**
|
||||
* Implementation of the exponential distribution.
|
||||
|
@ -38,20 +38,6 @@ public class ExponentialDistribution extends AbstractRealDistribution {
|
|||
public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9;
|
||||
/** Serializable version identifier */
|
||||
private static final long serialVersionUID = 20160311L;
|
||||
/**
|
||||
* Used when generating Exponential samples.
|
||||
* Table containing the constants
|
||||
* q_i = sum_{j=1}^i (ln 2)^j/j! = ln 2 + (ln 2)^2/2 + ... + (ln 2)^i/i!
|
||||
* until the largest representable fraction below 1 is exceeded.
|
||||
*
|
||||
* Note that
|
||||
* 1 = 2 - 1 = exp(ln 2) - 1 = sum_{n=1}^infty (ln 2)^n / n!
|
||||
* thus q_i -> 1 as i -> +inf,
|
||||
* so the higher i, the closer to one we get (the series is not alternating).
|
||||
*
|
||||
* By trying, n = 16 in Java is enough to reach 1.0.
|
||||
*/
|
||||
private static final double[] EXPONENTIAL_SA_QI;
|
||||
/** The mean of this distribution. */
|
||||
private final double mean;
|
||||
/** The logarithm of the mean, stored to reduce computing time. **/
|
||||
|
@ -59,35 +45,6 @@ public class ExponentialDistribution extends AbstractRealDistribution {
|
|||
/** Inverse cumulative probability accuracy. */
|
||||
private final double solverAbsoluteAccuracy;
|
||||
|
||||
/**
|
||||
* Initialize tables.
|
||||
*/
|
||||
static {
|
||||
/**
|
||||
* Filling EXPONENTIAL_SA_QI table.
|
||||
* Note that we don't want qi = 0 in the table.
|
||||
*/
|
||||
final double LN2 = FastMath.log(2);
|
||||
double qi = 0;
|
||||
int i = 1;
|
||||
|
||||
/**
|
||||
* ArithmeticUtils provides factorials up to 20, so let's use that
|
||||
* limit together with Precision.EPSILON to generate the following
|
||||
* code (a priori, we know that there will be 16 elements, but it is
|
||||
* better to not hardcode it).
|
||||
*/
|
||||
final ResizableDoubleArray ra = new ResizableDoubleArray(20);
|
||||
|
||||
while (qi < 1) {
|
||||
qi += FastMath.pow(LN2, i) / CombinatoricsUtils.factorial(i);
|
||||
ra.addElement(qi);
|
||||
++i;
|
||||
}
|
||||
|
||||
EXPONENTIAL_SA_QI = ra.getElements();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a distribution.
|
||||
*
|
||||
|
@ -262,45 +219,13 @@ public class ExponentialDistribution extends AbstractRealDistribution {
|
|||
@Override
|
||||
public RealDistribution.Sampler createSampler(final UniformRandomProvider rng) {
|
||||
return new RealDistribution.Sampler() {
|
||||
/** {@inheritDoc} */
|
||||
private final ContinuousSampler sampler =
|
||||
new AhrensDieterExponentialSampler(rng, mean);
|
||||
|
||||
/**{@inheritDoc} */
|
||||
@Override
|
||||
public double sample() {
|
||||
// Step 1:
|
||||
double a = 0;
|
||||
double u = rng.nextDouble();
|
||||
|
||||
// Step 2 and 3:
|
||||
while (u < 0.5) {
|
||||
a += EXPONENTIAL_SA_QI[0];
|
||||
u *= 2;
|
||||
}
|
||||
|
||||
// Step 4 (now u >= 0.5):
|
||||
u += u - 1;
|
||||
|
||||
// Step 5:
|
||||
if (u <= EXPONENTIAL_SA_QI[0]) {
|
||||
return mean * (a + u);
|
||||
}
|
||||
|
||||
// Step 6:
|
||||
int i = 0; // Should be 1, be we iterate before it in while using 0
|
||||
double u2 = rng.nextDouble();
|
||||
double umin = u2;
|
||||
|
||||
// Step 7 and 8:
|
||||
do {
|
||||
++i;
|
||||
u2 = rng.nextDouble();
|
||||
|
||||
if (u2 < umin) {
|
||||
umin = u2;
|
||||
}
|
||||
|
||||
// Step 8:
|
||||
} while (u > EXPONENTIAL_SA_QI[i]); // Ensured to exit since EXPONENTIAL_SA_QI[MAX] = 1
|
||||
|
||||
return mean * (a + umin * EXPONENTIAL_SA_QI[0]);
|
||||
return sampler.sample();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -18,9 +18,11 @@ package org.apache.commons.math4.distribution;
|
|||
|
||||
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math4.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.math4.special.Gamma;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.sampling.distribution.ContinuousSampler;
|
||||
import org.apache.commons.rng.sampling.distribution.AhrensDieterMarsagliaTsangGammaSampler;
|
||||
|
||||
/**
|
||||
* Implementation of the Gamma distribution.
|
||||
|
@ -378,75 +380,15 @@ public class GammaDistribution extends AbstractRealDistribution {
|
|||
@Override
|
||||
public RealDistribution.Sampler createSampler(final UniformRandomProvider rng) {
|
||||
return new RealDistribution.Sampler() {
|
||||
/** Gaussian sampling. */
|
||||
private final RealDistribution.Sampler gaussian = new NormalDistribution().createSampler(rng);
|
||||
private final ContinuousSampler sampler =
|
||||
new AhrensDieterMarsagliaTsangGammaSampler(rng, scale, shape);
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**{@inheritDoc} */
|
||||
@Override
|
||||
public double sample() {
|
||||
if (shape < 1) {
|
||||
// [1]: p. 228, Algorithm GS
|
||||
|
||||
while (true) {
|
||||
// Step 1:
|
||||
final double u = rng.nextDouble();
|
||||
final double bGS = 1 + shape / FastMath.E;
|
||||
final double p = bGS * u;
|
||||
|
||||
if (p <= 1) {
|
||||
// Step 2:
|
||||
|
||||
final double x = FastMath.pow(p, 1 / shape);
|
||||
final double u2 = rng.nextDouble();
|
||||
|
||||
if (u2 > FastMath.exp(-x)) {
|
||||
// Reject
|
||||
continue;
|
||||
} else {
|
||||
return scale * x;
|
||||
}
|
||||
} else {
|
||||
// Step 3:
|
||||
|
||||
final double x = -1 * FastMath.log((bGS - p) / shape);
|
||||
final double u2 = rng.nextDouble();
|
||||
|
||||
if (u2 > FastMath.pow(x, shape - 1)) {
|
||||
// Reject
|
||||
continue;
|
||||
} else {
|
||||
return scale * x;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now shape >= 1
|
||||
|
||||
final double d = shape - 0.333333333333333333;
|
||||
final double c = 1 / (3 * FastMath.sqrt(d));
|
||||
|
||||
while (true) {
|
||||
final double x = gaussian.sample();
|
||||
final double v = (1 + c * x) * (1 + c * x) * (1 + c * x);
|
||||
|
||||
if (v <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final double x2 = x * x;
|
||||
final double u = rng.nextDouble();
|
||||
|
||||
// Squeeze
|
||||
if (u < 1 - 0.0331 * x2 * x2) {
|
||||
return scale * d * v;
|
||||
}
|
||||
|
||||
if (FastMath.log(u) < 0.5 * x2 + d * (1 - v + FastMath.log(v))) {
|
||||
return scale * d * v;
|
||||
}
|
||||
}
|
||||
return sampler.sample();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,9 +20,11 @@ package org.apache.commons.math4.distribution;
|
|||
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math4.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math4.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.math4.special.Erf;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.sampling.distribution.ContinuousSampler;
|
||||
import org.apache.commons.rng.sampling.distribution.BoxMullerLogNormalSampler;
|
||||
|
||||
/**
|
||||
* Implementation of the log-normal (gaussian) distribution.
|
||||
|
@ -292,14 +294,13 @@ public class LogNormalDistribution extends AbstractRealDistribution {
|
|||
@Override
|
||||
public RealDistribution.Sampler createSampler(final UniformRandomProvider rng) {
|
||||
return new RealDistribution.Sampler() {
|
||||
/** Gaussian sampling. */
|
||||
private final RealDistribution.Sampler gaussian = new NormalDistribution().createSampler(rng);
|
||||
private final ContinuousSampler sampler =
|
||||
new BoxMullerLogNormalSampler(rng, scale, shape);
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**{@inheritDoc} */
|
||||
@Override
|
||||
public double sample() {
|
||||
final double n = gaussian.sample();
|
||||
return FastMath.exp(scale + shape * n);
|
||||
return sampler.sample();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -21,9 +21,11 @@ import org.apache.commons.math4.exception.NotStrictlyPositiveException;
|
|||
import org.apache.commons.math4.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math4.exception.OutOfRangeException;
|
||||
import org.apache.commons.math4.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.math4.special.Erf;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.sampling.distribution.ContinuousSampler;
|
||||
import org.apache.commons.rng.sampling.distribution.BoxMullerGaussianSampler;
|
||||
|
||||
/**
|
||||
* Implementation of the normal (gaussian) distribution.
|
||||
|
@ -239,36 +241,13 @@ public class NormalDistribution extends AbstractRealDistribution {
|
|||
@Override
|
||||
public RealDistribution.Sampler createSampler(final UniformRandomProvider rng) {
|
||||
return new RealDistribution.Sampler() {
|
||||
/** Next gaussian. */
|
||||
private double nextGaussian = Double.NaN;
|
||||
private final ContinuousSampler sampler =
|
||||
new BoxMullerGaussianSampler(rng, mean, standardDeviation);
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**{@inheritDoc} */
|
||||
@Override
|
||||
public double sample() {
|
||||
final double random;
|
||||
if (Double.isNaN(nextGaussian)) {
|
||||
// Generate a pair of Gaussian numbers.
|
||||
|
||||
final double x = rng.nextDouble();
|
||||
final double y = rng.nextDouble();
|
||||
final double alpha = 2 * FastMath.PI * x;
|
||||
final double r = FastMath.sqrt(-2 * FastMath.log(y));
|
||||
|
||||
// Return the first element of the generated pair.
|
||||
random = r * FastMath.cos(alpha);
|
||||
|
||||
// Keep second element of the pair for next invocation.
|
||||
nextGaussian = r * FastMath.sin(alpha);
|
||||
} else {
|
||||
// Use the second element of the pair (generated at the
|
||||
// previous invocation).
|
||||
random = nextGaussian;
|
||||
|
||||
// Both elements of the pair have been used.
|
||||
nextGaussian = Double.NaN;
|
||||
}
|
||||
|
||||
return standardDeviation * random + mean;
|
||||
return sampler.sample();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -19,8 +19,10 @@ package org.apache.commons.math4.distribution;
|
|||
|
||||
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math4.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.sampling.distribution.ContinuousSampler;
|
||||
import org.apache.commons.rng.sampling.distribution.InverseTransformParetoSampler;
|
||||
|
||||
/**
|
||||
* Implementation of the Pareto distribution.
|
||||
|
@ -252,11 +254,13 @@ public class ParetoDistribution extends AbstractRealDistribution {
|
|||
@Override
|
||||
public RealDistribution.Sampler createSampler(final UniformRandomProvider rng) {
|
||||
return new RealDistribution.Sampler() {
|
||||
/** {@inheritDoc} */
|
||||
private final ContinuousSampler sampler =
|
||||
new InverseTransformParetoSampler(rng, scale, shape);
|
||||
|
||||
/**{@inheritDoc} */
|
||||
@Override
|
||||
public double sample() {
|
||||
final double n = rng.nextDouble();
|
||||
return scale / FastMath.pow(n, 1 / shape);
|
||||
return sampler.sample();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -19,10 +19,11 @@ package org.apache.commons.math4.distribution;
|
|||
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math4.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math4.special.Gamma;
|
||||
import org.apache.commons.math4.util.CombinatoricsUtils;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.MathUtils;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.sampling.distribution.DiscreteSampler;
|
||||
import org.apache.commons.rng.sampling.distribution.PoissonSampler;
|
||||
|
||||
/**
|
||||
* Implementation of the Poisson distribution.
|
||||
|
@ -248,108 +249,13 @@ public class PoissonDistribution extends AbstractIntegerDistribution {
|
|||
@Override
|
||||
public IntegerDistribution.Sampler createSampler(final UniformRandomProvider rng) {
|
||||
return new IntegerDistribution.Sampler() {
|
||||
/** Exponential distribution. */
|
||||
private final RealDistribution.Sampler exponentialSampler
|
||||
= new ExponentialDistribution(1).createSampler(rng);
|
||||
/** Gaussian distribution. */
|
||||
private final RealDistribution.Sampler gaussianSampler
|
||||
= new NormalDistribution().createSampler(rng);
|
||||
private final DiscreteSampler sampler =
|
||||
new PoissonSampler(rng, mean);
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**{@inheritDoc} */
|
||||
@Override
|
||||
public int sample() {
|
||||
return (int) FastMath.min(nextPoisson(mean),
|
||||
Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param meanPoisson Mean of the Poisson distribution.
|
||||
* @return the next sample.
|
||||
*/
|
||||
private long nextPoisson(double meanPoisson) {
|
||||
final double pivot = 40.0d;
|
||||
if (meanPoisson < pivot) {
|
||||
double p = FastMath.exp(-meanPoisson);
|
||||
long n = 0;
|
||||
double r = 1.0d;
|
||||
double rnd = 1.0d;
|
||||
|
||||
while (n < 1000 * meanPoisson) {
|
||||
rnd = rng.nextDouble();
|
||||
r *= rnd;
|
||||
if (r >= p) {
|
||||
n++;
|
||||
} else {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
} else {
|
||||
final double lambda = FastMath.floor(meanPoisson);
|
||||
final double lambdaFractional = meanPoisson - lambda;
|
||||
final double logLambda = FastMath.log(lambda);
|
||||
final double logLambdaFactorial = CombinatoricsUtils.factorialLog((int) lambda);
|
||||
final long y2 = lambdaFractional < Double.MIN_VALUE ? 0 : nextPoisson(lambdaFractional);
|
||||
final double delta = FastMath.sqrt(lambda * FastMath.log(32 * lambda / FastMath.PI + 1));
|
||||
final double halfDelta = delta / 2;
|
||||
final double twolpd = 2 * lambda + delta;
|
||||
final double a1 = FastMath.sqrt(FastMath.PI * twolpd) * FastMath.exp(1 / (8 * lambda));
|
||||
final double a2 = (twolpd / delta) * FastMath.exp(-delta * (1 + delta) / twolpd);
|
||||
final double aSum = a1 + a2 + 1;
|
||||
final double p1 = a1 / aSum;
|
||||
final double p2 = a2 / aSum;
|
||||
final double c1 = 1 / (8 * lambda);
|
||||
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
double v = 0;
|
||||
int a = 0;
|
||||
double t = 0;
|
||||
double qr = 0;
|
||||
double qa = 0;
|
||||
while (true) {
|
||||
final double u = rng.nextDouble();
|
||||
if (u <= p1) {
|
||||
final double n = gaussianSampler.sample();
|
||||
x = n * FastMath.sqrt(lambda + halfDelta) - 0.5d;
|
||||
if (x > delta || x < -lambda) {
|
||||
continue;
|
||||
}
|
||||
y = x < 0 ? FastMath.floor(x) : FastMath.ceil(x);
|
||||
final double e = exponentialSampler.sample();
|
||||
v = -e - (n * n / 2) + c1;
|
||||
} else {
|
||||
if (u > p1 + p2) {
|
||||
y = lambda;
|
||||
break;
|
||||
} else {
|
||||
x = delta + (twolpd / delta) * exponentialSampler.sample();
|
||||
y = FastMath.ceil(x);
|
||||
v = -exponentialSampler.sample() - delta * (x + 1) / twolpd;
|
||||
}
|
||||
}
|
||||
a = x < 0 ? 1 : 0;
|
||||
t = y * (y + 1) / (2 * lambda);
|
||||
if (v < -t && a == 0) {
|
||||
y = lambda + y;
|
||||
break;
|
||||
}
|
||||
qr = t * ((2 * y + 1) / (6 * lambda) - 1);
|
||||
qa = qr - (t * t) / (3 * (lambda + a * (y + 1)));
|
||||
if (v < qa) {
|
||||
y = lambda + y;
|
||||
break;
|
||||
}
|
||||
if (v > qr) {
|
||||
continue;
|
||||
}
|
||||
if (v < y * logLambda - CombinatoricsUtils.factorialLog((int) (y + lambda)) + logLambdaFactorial) {
|
||||
y = lambda + y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return y2 + (long) y;
|
||||
}
|
||||
return sampler.sample();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ package org.apache.commons.math4.distribution;
|
|||
import org.apache.commons.math4.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math4.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.sampling.distribution.DiscreteSampler;
|
||||
import org.apache.commons.rng.sampling.distribution.DiscreteUniformSampler;
|
||||
|
||||
/**
|
||||
* Implementation of the <a href="http://en.wikipedia.org/wiki/Uniform_distribution_(discrete)">
|
||||
|
@ -147,25 +149,13 @@ public class UniformIntegerDistribution extends AbstractIntegerDistribution {
|
|||
@Override
|
||||
public IntegerDistribution.Sampler createSampler(final UniformRandomProvider rng) {
|
||||
return new IntegerDistribution.Sampler() {
|
||||
/** {@inheritDoc} */
|
||||
private final DiscreteSampler sampler =
|
||||
new DiscreteUniformSampler(rng, lower, upper);
|
||||
|
||||
/**{@inheritDoc} */
|
||||
@Override
|
||||
public int sample() {
|
||||
final int max = (upper - lower) + 1;
|
||||
if (max <= 0) {
|
||||
// The range is too wide to fit in a positive int (larger
|
||||
// than 2^31); as it covers more than half the integer range,
|
||||
// we use a simple rejection method.
|
||||
while (true) {
|
||||
final int r = rng.nextInt();
|
||||
if (r >= lower &&
|
||||
r <= upper) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// We can shift the range and directly generate a positive int.
|
||||
return lower + rng.nextInt(max);
|
||||
}
|
||||
return sampler.sample();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ import org.apache.commons.math4.exception.NumberIsTooLargeException;
|
|||
import org.apache.commons.math4.exception.OutOfRangeException;
|
||||
import org.apache.commons.math4.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.sampling.distribution.ContinuousSampler;
|
||||
import org.apache.commons.rng.sampling.distribution.ContinuousUniformSampler;
|
||||
|
||||
/**
|
||||
* Implementation of the uniform real distribution.
|
||||
|
@ -162,11 +164,13 @@ public class UniformRealDistribution extends AbstractRealDistribution {
|
|||
@Override
|
||||
public RealDistribution.Sampler createSampler(final UniformRandomProvider rng) {
|
||||
return new RealDistribution.Sampler() {
|
||||
/** {@inheritDoc} */
|
||||
private final ContinuousSampler sampler =
|
||||
new ContinuousUniformSampler(rng, lower, upper);
|
||||
|
||||
/**{@inheritDoc} */
|
||||
@Override
|
||||
public double sample() {
|
||||
final double u = rng.nextDouble();
|
||||
return u * upper + (1 - u) * lower;
|
||||
return sampler.sample();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -19,8 +19,10 @@ package org.apache.commons.math4.distribution;
|
|||
|
||||
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math4.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.sampling.distribution.DiscreteSampler;
|
||||
import org.apache.commons.rng.sampling.distribution.RejectionInversionZipfSampler;
|
||||
|
||||
/**
|
||||
* Implementation of the Zipf distribution.
|
||||
|
@ -261,214 +263,14 @@ public class ZipfDistribution extends AbstractIntegerDistribution {
|
|||
@Override
|
||||
public IntegerDistribution.Sampler createSampler(final UniformRandomProvider rng) {
|
||||
return new IntegerDistribution.Sampler() {
|
||||
/** Helper. */
|
||||
private final ZipfRejectionInversionSampler sampler =
|
||||
new ZipfRejectionInversionSampler(numberOfElements, exponent);
|
||||
private final DiscreteSampler sampler =
|
||||
new RejectionInversionZipfSampler(rng, numberOfElements, exponent);
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**{@inheritDoc} */
|
||||
@Override
|
||||
public int sample() {
|
||||
return sampler.sample(rng);
|
||||
return sampler.sample();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility class implementing a rejection inversion sampling method for a discrete,
|
||||
* bounded Zipf distribution that is based on the method described in
|
||||
* <p>
|
||||
* Wolfgang Hörmann and Gerhard Derflinger
|
||||
* "Rejection-inversion to generate variates from monotone discrete distributions."
|
||||
* ACM Transactions on Modeling and Computer Simulation (TOMACS) 6.3 (1996): 169-184.
|
||||
* <p>
|
||||
* The paper describes an algorithm for exponents larger than 1 (Algorithm ZRI).
|
||||
* The original method uses {@code H(x) := (v + x)^(1 - q) / (1 - q)}
|
||||
* as the integral of the hat function. This function is undefined for
|
||||
* q = 1, which is the reason for the limitation of the exponent.
|
||||
* If instead the integral function
|
||||
* {@code H(x) := ((v + x)^(1 - q) - 1) / (1 - q)} is used,
|
||||
* for which a meaningful limit exists for q = 1,
|
||||
* the method works for all positive exponents.
|
||||
* <p>
|
||||
* The following implementation uses v := 0 and generates integral numbers
|
||||
* in the range [1, numberOfElements]. This is different to the original method
|
||||
* where v is defined to be positive and numbers are taken from [0, i_max].
|
||||
* This explains why the implementation looks slightly different.
|
||||
*
|
||||
* @since 3.6
|
||||
*/
|
||||
static class ZipfRejectionInversionSampler {
|
||||
/** Exponent parameter of the distribution. */
|
||||
private final double exponent;
|
||||
/** Number of elements. */
|
||||
private final int numberOfElements;
|
||||
/** Constant equal to {@code hIntegral(1.5) - 1}. */
|
||||
private final double hIntegralX1;
|
||||
/** Constant equal to {@code hIntegral(numberOfElements + 0.5)}. */
|
||||
private final double hIntegralNumberOfElements;
|
||||
/** Constant equal to {@code 2 - hIntegralInverse(hIntegral(2.5) - h(2)}. */
|
||||
private final double s;
|
||||
|
||||
/**
|
||||
* @param numberOfElements number of elements
|
||||
* @param exponent exponent parameter of the distribution
|
||||
*/
|
||||
ZipfRejectionInversionSampler(final int numberOfElements, final double exponent) {
|
||||
this.exponent = exponent;
|
||||
this.numberOfElements = numberOfElements;
|
||||
this.hIntegralX1 = hIntegral(1.5) - 1d;
|
||||
this.hIntegralNumberOfElements = hIntegral(numberOfElements + 0.5);
|
||||
this.s = 2d - hIntegralInverse(hIntegral(2.5) - h(2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates one integer in the range [1, numberOfElements].
|
||||
*
|
||||
* @param random random generator to use
|
||||
* @return generated integral number in the range [1, numberOfElements]
|
||||
*/
|
||||
int sample(final UniformRandomProvider random) {
|
||||
while(true) {
|
||||
final double u = hIntegralNumberOfElements + random.nextDouble() * (hIntegralX1 - hIntegralNumberOfElements);
|
||||
// u is uniformly distributed in (hIntegralX1, hIntegralNumberOfElements]
|
||||
|
||||
double x = hIntegralInverse(u);
|
||||
int k = (int)(x + 0.5);
|
||||
|
||||
// Limit k to the range [1, numberOfElements]
|
||||
// (k could be outside due to numerical inaccuracies)
|
||||
if (k < 1) {
|
||||
k = 1;
|
||||
}
|
||||
else if (k > numberOfElements) {
|
||||
k = numberOfElements;
|
||||
}
|
||||
|
||||
// Here, the distribution of k is given by:
|
||||
//
|
||||
// P(k = 1) = C * (hIntegral(1.5) - hIntegralX1) = C
|
||||
// P(k = m) = C * (hIntegral(m + 1/2) - hIntegral(m - 1/2)) for m >= 2
|
||||
//
|
||||
// where C := 1 / (hIntegralNumberOfElements - hIntegralX1)
|
||||
|
||||
if (k - x <= s || u >= hIntegral(k + 0.5) - h(k)) {
|
||||
|
||||
// Case k = 1:
|
||||
//
|
||||
// The right inequality is always true, because replacing k by 1 gives
|
||||
// u >= hIntegral(1.5) - h(1) = hIntegralX1 and u is taken from
|
||||
// (hIntegralX1, hIntegralNumberOfElements].
|
||||
//
|
||||
// Therefore, the acceptance rate for k = 1 is P(accepted | k = 1) = 1
|
||||
// and the probability that 1 is returned as random value is
|
||||
// P(k = 1 and accepted) = P(accepted | k = 1) * P(k = 1) = C = C / 1^exponent
|
||||
//
|
||||
// Case k >= 2:
|
||||
//
|
||||
// The left inequality (k - x <= s) is just a short cut
|
||||
// to avoid the more expensive evaluation of the right inequality
|
||||
// (u >= hIntegral(k + 0.5) - h(k)) in many cases.
|
||||
//
|
||||
// If the left inequality is true, the right inequality is also true:
|
||||
// Theorem 2 in the paper is valid for all positive exponents, because
|
||||
// the requirements h'(x) = -exponent/x^(exponent + 1) < 0 and
|
||||
// (-1/hInverse'(x))'' = (1+1/exponent) * x^(1/exponent-1) >= 0
|
||||
// are both fulfilled.
|
||||
// Therefore, f(x) := x - hIntegralInverse(hIntegral(x + 0.5) - h(x))
|
||||
// is a non-decreasing function. If k - x <= s holds,
|
||||
// k - x <= s + f(k) - f(2) is obviously also true which is equivalent to
|
||||
// -x <= -hIntegralInverse(hIntegral(k + 0.5) - h(k)),
|
||||
// -hIntegralInverse(u) <= -hIntegralInverse(hIntegral(k + 0.5) - h(k)),
|
||||
// and finally u >= hIntegral(k + 0.5) - h(k).
|
||||
//
|
||||
// Hence, the right inequality determines the acceptance rate:
|
||||
// P(accepted | k = m) = h(m) / (hIntegrated(m+1/2) - hIntegrated(m-1/2))
|
||||
// The probability that m is returned is given by
|
||||
// P(k = m and accepted) = P(accepted | k = m) * P(k = m) = C * h(m) = C / m^exponent.
|
||||
//
|
||||
// In both cases the probabilities are proportional to the probability mass function
|
||||
// of the Zipf distribution.
|
||||
|
||||
return k;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code H(x) :=}
|
||||
* <ul>
|
||||
* <li>{@code (x^(1-exponent) - 1)/(1 - exponent)}, if {@code exponent != 1}</li>
|
||||
* <li>{@code log(x)}, if {@code exponent == 1}</li>
|
||||
* </ul>
|
||||
* H(x) is an integral function of h(x),
|
||||
* the derivative of H(x) is h(x).
|
||||
*
|
||||
* @param x free parameter
|
||||
* @return {@code H(x)}
|
||||
*/
|
||||
private double hIntegral(final double x) {
|
||||
final double logX = FastMath.log(x);
|
||||
return helper2((1d-exponent)*logX)*logX;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code h(x) := 1/x^exponent}
|
||||
*
|
||||
* @param x free parameter
|
||||
* @return h(x)
|
||||
*/
|
||||
private double h(final double x) {
|
||||
return FastMath.exp(-exponent * FastMath.log(x));
|
||||
}
|
||||
|
||||
/**
|
||||
* The inverse function of H(x).
|
||||
*
|
||||
* @param x free parameter
|
||||
* @return y for which {@code H(y) = x}
|
||||
*/
|
||||
private double hIntegralInverse(final double x) {
|
||||
double t = x*(1d-exponent);
|
||||
if (t < -1d) {
|
||||
// Limit value to the range [-1, +inf).
|
||||
// t could be smaller than -1 in some rare cases due to numerical errors.
|
||||
t = -1;
|
||||
}
|
||||
return FastMath.exp(helper1(t)*x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function that calculates {@code log(1+x)/x}.
|
||||
* <p>
|
||||
* A Taylor series expansion is used, if x is close to 0.
|
||||
*
|
||||
* @param x a value larger than or equal to -1
|
||||
* @return {@code log(1+x)/x}
|
||||
*/
|
||||
static double helper1(final double x) {
|
||||
if (FastMath.abs(x)>1e-8) {
|
||||
return FastMath.log1p(x)/x;
|
||||
}
|
||||
else {
|
||||
return 1.-x*((1./2.)-x*((1./3.)-x*(1./4.)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to calculate {@code (exp(x)-1)/x}.
|
||||
* <p>
|
||||
* A Taylor series expansion is used, if x is close to 0.
|
||||
*
|
||||
* @param x free parameter
|
||||
* @return {@code (exp(x)-1)/x} if x is non-zero, or 1 if x=0
|
||||
*/
|
||||
static double helper2(final double x) {
|
||||
if (FastMath.abs(x)>1e-8) {
|
||||
return FastMath.expm1(x)/x;
|
||||
}
|
||||
else {
|
||||
return 1.+x*(1./2.)*(1.+x*(1./3.)*(1.+x*(1./4.)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.apache.commons.math4.genetics;
|
|||
|
||||
import org.apache.commons.math4.exception.OutOfRangeException;
|
||||
import org.apache.commons.math4.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.math4.linear.MatrixUtils;
|
|||
import org.apache.commons.math4.linear.RealMatrix;
|
||||
import org.apache.commons.math4.ml.distance.DistanceMeasure;
|
||||
import org.apache.commons.math4.ml.distance.EuclideanDistance;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.MathArrays;
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.math4.exception.NumberIsTooSmallException;
|
|||
import org.apache.commons.math4.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math4.ml.distance.DistanceMeasure;
|
||||
import org.apache.commons.math4.ml.distance.EuclideanDistance;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.math4.stat.descriptive.moment.Variance;
|
||||
import org.apache.commons.math4.util.MathUtils;
|
||||
|
|
|
@ -21,7 +21,7 @@ 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.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,8 @@ import java.io.ObjectOutputStream;
|
|||
import java.io.ObjectInputStream;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.rng.RestorableUniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.rng.core.RandomProviderDefaultState;
|
||||
|
||||
/**
|
||||
* Adaptor that delegates to a {@link UniformRandomProvider} instance.
|
||||
|
@ -206,7 +207,7 @@ public final class RngAdaptor
|
|||
out.defaultWriteObject();
|
||||
|
||||
// Save current state.
|
||||
out.writeObject(((RandomSource.State) delegate.saveState()).getState());
|
||||
out.writeObject(((RandomProviderDefaultState) delegate.saveState()).getState());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -223,7 +224,7 @@ public final class RngAdaptor
|
|||
// Recreate the "delegate" from serialized info.
|
||||
delegate = RandomSource.create(source);
|
||||
// And restore its state.
|
||||
final RandomSource.State state = new RandomSource.State((byte[]) in.readObject());
|
||||
final RandomProviderDefaultState state = new RandomProviderDefaultState((byte[]) in.readObject());
|
||||
delegate.restoreState(state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.commons.math4.random;
|
||||
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.math4.distribution.RealDistribution;
|
||||
import org.apache.commons.math4.distribution.NormalDistribution;
|
||||
|
|
|
@ -40,7 +40,7 @@ import org.apache.commons.math4.linear.Array2DRowFieldMatrix;
|
|||
import org.apache.commons.math4.linear.FieldMatrix;
|
||||
import org.apache.commons.math4.linear.MatrixUtils;
|
||||
import org.apache.commons.math4.linear.RealMatrix;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.math4.util.CombinatoricsUtils;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.List;
|
|||
import org.apache.commons.math4.exception.MathInternalError;
|
||||
import org.apache.commons.math4.exception.NotANumberException;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.random.RandomUtils;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ import org.apache.commons.math4.exception.NotStrictlyPositiveException;
|
|||
import org.apache.commons.math4.exception.NullArgumentException;
|
||||
import org.apache.commons.math4.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math4.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,8 @@ import java.io.ObjectOutputStream;
|
|||
import java.io.ObjectInputStream;
|
||||
import org.apache.commons.math4.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.rng.RestorableUniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.rng.core.RandomProviderDefaultState;
|
||||
|
||||
/**
|
||||
* A strategy of selecting random index between begin and end indices.
|
||||
|
@ -77,7 +78,7 @@ public class RandomPivotingStrategy implements PivotingStrategyInterface, Serial
|
|||
out.defaultWriteObject();
|
||||
|
||||
// Save current state.
|
||||
out.writeObject(((RandomSource.State) random.saveState()).getState());
|
||||
out.writeObject(((RandomProviderDefaultState) random.saveState()).getState());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,7 +95,7 @@ public class RandomPivotingStrategy implements PivotingStrategyInterface, Serial
|
|||
// Recreate the "delegate" from serialized info.
|
||||
random = RandomSource.create(randomSource);
|
||||
// And restore its state.
|
||||
final RandomSource.State state = new RandomSource.State((byte[]) in.readObject());
|
||||
final RandomProviderDefaultState state = new RandomProviderDefaultState((byte[]) in.readObject());
|
||||
random.restoreState(state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.apache.commons.math4;
|
|||
|
||||
import org.apache.commons.math4.RealFieldElement;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.MathArrays;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.concurrent.Callable;
|
|||
|
||||
import org.apache.commons.math4.util.MathArrays;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math4.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math4.exception.util.LocalizedFormats;
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.commons.math4.analysis.polynomials.PolynomialFunction;
|
|||
import org.apache.commons.math4.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math4.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.ArithmeticUtils;
|
||||
import org.apache.commons.math4.util.CombinatoricsUtils;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.apache.commons.math4.ExtendedFieldElementAbstractTest;
|
|||
import org.apache.commons.math4.TestUtils;
|
||||
import org.apache.commons.math4.analysis.polynomials.PolynomialFunction;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.commons.math4.analysis.function.Sigmoid;
|
|||
import org.apache.commons.math4.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math4.exception.NullArgumentException;
|
||||
import org.apache.commons.math4.exception.OutOfRangeException;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.commons.math4.exception.NonMonotonicSequenceException;
|
|||
import org.apache.commons.math4.exception.NullArgumentException;
|
||||
import org.apache.commons.math4.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.Precision;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.apache.commons.math4.exception.DimensionMismatchException;
|
|||
import org.apache.commons.math4.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math4.exception.OutOfRangeException;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.Precision;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.commons.math4.distribution.UniformRealDistribution;
|
|||
import org.apache.commons.math4.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math4.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.commons.math4.exception.InsufficientDataException;
|
|||
import org.apache.commons.math4.exception.NonMonotonicSequenceException;
|
||||
import org.apache.commons.math4.exception.NullArgumentException;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.Precision;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.commons.math4.exception.InsufficientDataException;
|
|||
import org.apache.commons.math4.exception.NonMonotonicSequenceException;
|
||||
import org.apache.commons.math4.exception.NullArgumentException;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.commons.math4.distribution.UniformRealDistribution;
|
|||
import org.apache.commons.math4.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math4.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.Precision;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.apache.commons.math4.distribution;
|
|||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.math4.stat.StatUtils;
|
||||
import org.apache.commons.math4.stat.inference.KolmogorovSmirnovTest;
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.apache.commons.math4.analysis.integration.IterativeLegendreGaussInteg
|
|||
import org.apache.commons.math4.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math4.exception.NullArgumentException;
|
||||
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.stat.descriptive.SummaryStatistics;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.commons.math4.exception.NotANumberException;
|
|||
import org.apache.commons.math4.exception.NotFiniteNumberException;
|
||||
import org.apache.commons.math4.exception.NotPositiveException;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.apache.commons.math4.exception.NotPositiveException;
|
|||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.Pair;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.commons.math4.exception.NotPositiveException;
|
|||
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math4.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math4.util.Precision;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ 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.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.apache.commons.math4.distribution.MixtureMultivariateRealDistribution
|
|||
import org.apache.commons.math4.distribution.MultivariateNormalDistribution;
|
||||
import org.apache.commons.math4.exception.MathArithmeticException;
|
||||
import org.apache.commons.math4.exception.NotPositiveException;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.Pair;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.commons.math4.distribution;
|
|||
import org.apache.commons.math4.distribution.MultivariateNormalDistribution;
|
||||
import org.apache.commons.math4.distribution.NormalDistribution;
|
||||
import org.apache.commons.math4.linear.RealMatrix;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.stat.correlation.Covariance;
|
||||
|
||||
import java.util.Random;
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.apache.commons.math4.analysis.integration.IterativeLegendreGaussInteg
|
|||
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.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -18,9 +18,8 @@
|
|||
package org.apache.commons.math4.distribution;
|
||||
|
||||
import org.apache.commons.math4.TestUtils;
|
||||
import org.apache.commons.math4.distribution.ZipfDistribution.ZipfRejectionInversionSampler;
|
||||
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
|
@ -168,41 +167,6 @@ public class ZipfDistributionTest extends IntegerDistributionAbstractTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSamplerHelper1() {
|
||||
final double tol = 1e-12;
|
||||
final double[] testValues = {
|
||||
Math.nextUp(-1.), -1e-1, -1e-2, -1e-3, -1e-4, -1e-5, -1e-6, -1e-7, -1e-8,
|
||||
-1e-9, -1e-10, -1e-11, 0., 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6,
|
||||
1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1e0
|
||||
};
|
||||
for (final double testValue : testValues) {
|
||||
final double expected = FastMath.log1p(testValue);
|
||||
final double actual = ZipfRejectionInversionSampler.helper1(testValue) * testValue;
|
||||
TestUtils.assertRelativelyEquals(expected, actual, tol);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSamplerHelper1Minus1() {
|
||||
Assert.assertEquals(Double.POSITIVE_INFINITY, ZipfRejectionInversionSampler.helper1(-1d), 0d);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSamplerHelper2() {
|
||||
final double tol = 1e-12;
|
||||
final double[] testValues = {
|
||||
-1e0, -1e-1, -1e-2, -1e-3, -1e-4, -1e-5, -1e-6, -1e-7, -1e-8,
|
||||
-1e-9, -1e-10, -1e-11, 0., 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6,
|
||||
1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1e0
|
||||
};
|
||||
for (double testValue : testValues) {
|
||||
final double expected = FastMath.expm1(testValue);
|
||||
final double actual = ZipfRejectionInversionSampler.helper2(testValue) * testValue;
|
||||
TestUtils.assertRelativelyEquals(expected, actual, tol);
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testSamplerPerformance() {
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.commons.math4.linear.MatrixDimensionMismatchException;
|
|||
import org.apache.commons.math4.linear.MatrixUtils;
|
||||
import org.apache.commons.math4.linear.RealMatrix;
|
||||
import org.apache.commons.math4.linear.RealVector;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.Precision;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.commons.math4.exception.ConvergenceException;
|
|||
import org.apache.commons.math4.fitting.PolynomialCurveFitter;
|
||||
import org.apache.commons.math4.fitting.WeightedObservedPoints;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.commons.math4.distribution.RealDistribution;
|
|||
import org.apache.commons.math4.distribution.UniformRealDistribution;
|
||||
import org.apache.commons.math4.fitting.SimpleCurveFitter;
|
||||
import org.apache.commons.math4.fitting.WeightedObservedPoints;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.apache.commons.math4.distribution.RealDistribution;
|
|||
import org.apache.commons.math4.distribution.UniformRealDistribution;
|
||||
import org.apache.commons.math4.geometry.euclidean.twod.Vector2D;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.MathUtils;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ 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.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
|
||||
/**
|
||||
* Factory for generating a cloud of points that approximate a straight line.
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.commons.math4.geometry.euclidean.twod.DiskGenerator;
|
|||
import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D;
|
||||
import org.apache.commons.math4.geometry.euclidean.twod.Vector2D;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.math4.geometry.euclidean.threed.SphereGenerator;
|
|||
import org.apache.commons.math4.geometry.euclidean.threed.Vector3D;
|
||||
import org.apache.commons.math4.random.UnitSphereRandomVectorGenerator;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.apache.commons.math4.linear.MatrixUtils;
|
|||
import org.apache.commons.math4.linear.RealMatrix;
|
||||
import org.apache.commons.math4.random.UnitSphereRandomVectorGenerator;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.MathUtils;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.apache.commons.math4.geometry.euclidean.threed.RotationOrder;
|
|||
import org.apache.commons.math4.geometry.euclidean.threed.Vector3D;
|
||||
import org.apache.commons.math4.random.UnitSphereRandomVectorGenerator;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.MathUtils;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.math4.exception.MathArithmeticException;
|
|||
import org.apache.commons.math4.geometry.euclidean.threed.FieldVector3D;
|
||||
import org.apache.commons.math4.geometry.euclidean.threed.Vector3D;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.Precision;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -51,7 +51,7 @@ import org.apache.commons.math4.geometry.partitioning.RegionFactory;
|
|||
import org.apache.commons.math4.geometry.partitioning.RegionParser;
|
||||
import org.apache.commons.math4.geometry.partitioning.SubHyperplane;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.commons.math4.geometry.euclidean.threed.SphereGenerator;
|
|||
import org.apache.commons.math4.geometry.euclidean.threed.Vector3D;
|
||||
import org.apache.commons.math4.random.UnitSphereRandomVectorGenerator;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.apache.commons.math4.geometry.Space;
|
|||
import org.apache.commons.math4.geometry.euclidean.threed.Rotation;
|
||||
import org.apache.commons.math4.geometry.euclidean.threed.Vector3D;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.Precision;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D;
|
|||
import org.apache.commons.math4.geometry.euclidean.twod.Vector2D;
|
||||
import org.apache.commons.math4.random.UnitSphereRandomVectorGenerator;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.apache.commons.math4.geometry.euclidean.twod.hull.ConvexHullGenerator
|
|||
import org.apache.commons.math4.geometry.partitioning.Region;
|
||||
import org.apache.commons.math4.geometry.partitioning.Region.Location;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.MathArrays;
|
||||
import org.apache.commons.math4.util.Precision;
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.apache.commons.math4.geometry.spherical.twod.S2Point;
|
|||
import org.apache.commons.math4.geometry.spherical.twod.Sphere2D;
|
||||
import org.apache.commons.math4.random.UnitSphereRandomVectorGenerator;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.MathUtils;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.apache.commons.math4.geometry.spherical.twod.SphericalPolygonsSet;
|
|||
import org.apache.commons.math4.geometry.spherical.twod.SubCircle;
|
||||
import org.apache.commons.math4.geometry.spherical.twod.Vertex;
|
||||
import org.apache.commons.math4.random.UnitSphereRandomVectorGenerator;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.MathUtils;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.apache.commons.math4.linear.TriDiagonalTransformer;
|
|||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.MathArrays;
|
||||
import org.apache.commons.math4.util.Precision;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.commons.math4.linear.HessenbergTransformer;
|
|||
import org.apache.commons.math4.linear.MatrixUtils;
|
||||
import org.apache.commons.math4.linear.NonSquareMatrixException;
|
||||
import org.apache.commons.math4.linear.RealMatrix;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.junit.Test;
|
||||
import org.junit.Assert;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.commons.math4.linear.MatrixUtils;
|
|||
import org.apache.commons.math4.linear.NonSquareMatrixException;
|
||||
import org.apache.commons.math4.linear.RealMatrix;
|
||||
import org.apache.commons.math4.linear.SchurTransformer;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.junit.Test;
|
||||
import org.junit.Assert;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.math4.ml.clustering.DoublePoint;
|
|||
import org.apache.commons.math4.ml.clustering.FuzzyKMeansClusterer;
|
||||
import org.apache.commons.math4.ml.distance.CanberraDistance;
|
||||
import org.apache.commons.math4.ml.distance.DistanceMeasure;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.math4.ml.clustering.Cluster;
|
|||
import org.apache.commons.math4.ml.clustering.DoublePoint;
|
||||
import org.apache.commons.math4.ml.clustering.KMeansPlusPlusClusterer;
|
||||
import org.apache.commons.math4.ml.distance.EuclideanDistance;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
|
|
@ -44,7 +44,7 @@ import org.apache.commons.math4.ml.neuralnet.sofm.LearningFactorFunction;
|
|||
import org.apache.commons.math4.ml.neuralnet.sofm.LearningFactorFunctionFactory;
|
||||
import org.apache.commons.math4.ml.neuralnet.sofm.NeighbourhoodSizeFunction;
|
||||
import org.apache.commons.math4.ml.neuralnet.sofm.NeighbourhoodSizeFunctionFactory;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.math4.ode.events.EventHandler;
|
|||
import org.apache.commons.math4.ode.events.FilterType;
|
||||
import org.apache.commons.math4.ode.nonstiff.DormandPrince853Integrator;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.apache.commons.math4.optim.nonlinear.scalar.gradient.NonLinearConjuga
|
|||
import org.apache.commons.math4.optim.nonlinear.scalar.noderiv.NelderMeadSimplex;
|
||||
import org.apache.commons.math4.optim.nonlinear.scalar.noderiv.SimplexOptimizer;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.random.GaussianRandomGenerator;
|
||||
import org.apache.commons.math4.random.RandomVectorGenerator;
|
||||
import org.apache.commons.math4.random.UncorrelatedRandomVectorGenerator;
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.apache.commons.math4.optim.SimpleBounds;
|
|||
import org.apache.commons.math4.optim.nonlinear.scalar.GoalType;
|
||||
import org.apache.commons.math4.optim.nonlinear.scalar.ObjectiveFunction;
|
||||
import org.apache.commons.math4.optim.nonlinear.scalar.noderiv.CMAESOptimizer;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.apache.commons.math4.optim.univariate.UnivariateObjectiveFunction;
|
|||
import org.apache.commons.math4.optim.univariate.UnivariateOptimizer;
|
||||
import org.apache.commons.math4.optim.univariate.UnivariatePointValuePair;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -87,7 +87,7 @@ public class MultiStartUnivariateOptimizerTest {
|
|||
new UnivariateObjectiveFunction(f),
|
||||
GoalType.MINIMIZE,
|
||||
new SearchInterval(-0.3, -0.2));
|
||||
Assert.assertEquals(-0.271956128, optimum.getPoint(), 1e-9);
|
||||
Assert.assertEquals(-0.2719561295, optimum.getPoint(), 1e-9);
|
||||
Assert.assertEquals(-0.0443342695, optimum.getValue(), 1e-9);
|
||||
|
||||
UnivariatePointValuePair[] optima = optimizer.getOptima();
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.commons.math4.random.CorrelatedRandomVectorGenerator;
|
|||
import org.apache.commons.math4.random.GaussianRandomGenerator;
|
||||
import org.apache.commons.math4.random.NormalizedRandomGenerator;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.stat.correlation.StorelessCovariance;
|
||||
import org.apache.commons.math4.stat.descriptive.moment.VectorialCovariance;
|
||||
import org.apache.commons.math4.stat.descriptive.moment.VectorialMean;
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.random;
|
|||
|
||||
import org.apache.commons.math4.random.GaussianRandomGenerator;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.stat.StatUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.random;
|
|||
import java.util.Random;
|
||||
import org.apache.commons.math4.exception.MathUnsupportedOperationException;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
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.math4.TestUtils;
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.apache.commons.math4.random;
|
|||
|
||||
import org.apache.commons.math4.exception.OutOfRangeException;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.stat.StatUtils;
|
||||
import org.apache.commons.math4.stat.descriptive.DescriptiveStatistics;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.concurrent.ExecutorService;
|
|||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.commons.math4.random;
|
||||
|
||||
import org.apache.commons.math4.linear.RealMatrix;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.random.GaussianRandomGenerator;
|
||||
import org.apache.commons.math4.random.UncorrelatedRandomVectorGenerator;
|
||||
import org.apache.commons.math4.stat.descriptive.moment.VectorialCovariance;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.commons.math4.random;
|
||||
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.stat.StatUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.apache.commons.math4.random;
|
||||
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.math4.random.UnitSphereRandomVectorGenerator;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.commons.math4.TestUtils;
|
|||
import org.apache.commons.math4.linear.BlockRealMatrix;
|
||||
import org.apache.commons.math4.linear.RealMatrix;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.stat.correlation.KendallsCorrelation;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.apache.commons.math4.TestUtils;
|
|||
import org.apache.commons.math4.linear.Array2DRowRealMatrix;
|
||||
import org.apache.commons.math4.linear.RealMatrix;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.stat.correlation.StorelessBivariateCovariance;
|
||||
import org.apache.commons.math4.stat.correlation.StorelessCovariance;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -27,7 +27,7 @@ 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.math4.util.Precision;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.commons.math4.distribution.UniformIntegerDistribution;
|
|||
import org.apache.commons.math4.stat.descriptive.UnivariateStatistic;
|
||||
import org.apache.commons.math4.stat.descriptive.WeightedEvaluation;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.apache.commons.math4.exception.MathIllegalArgumentException;
|
|||
import org.apache.commons.math4.exception.NullArgumentException;
|
||||
import org.apache.commons.math4.exception.OutOfRangeException;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.stat.descriptive.StorelessUnivariateStatistic;
|
||||
import org.apache.commons.math4.stat.descriptive.StorelessUnivariateStatisticAbstractTest;
|
||||
import org.apache.commons.math4.stat.descriptive.UnivariateStatistic;
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.commons.math4.exception.MathIllegalArgumentException;
|
|||
import org.apache.commons.math4.exception.NotANumberException;
|
||||
import org.apache.commons.math4.exception.NullArgumentException;
|
||||
import org.apache.commons.math4.exception.OutOfRangeException;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.math4.stat.descriptive.UnivariateStatistic;
|
||||
import org.apache.commons.math4.stat.descriptive.UnivariateStatisticAbstractTest;
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Arrays;
|
|||
import org.apache.commons.math4.TestUtils;
|
||||
import org.apache.commons.math4.distribution.NormalDistribution;
|
||||
import org.apache.commons.math4.distribution.UniformRealDistribution;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.math4.util.CombinatoricsUtils;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
|
|
|
@ -19,13 +19,12 @@ package org.apache.commons.math4.stat.ranking;
|
|||
import org.junit.Assert;
|
||||
import org.apache.commons.math4.TestUtils;
|
||||
import org.apache.commons.math4.exception.NotANumberException;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.math4.stat.ranking.NaNStrategy;
|
||||
import org.apache.commons.math4.stat.ranking.NaturalRanking;
|
||||
import org.apache.commons.math4.stat.ranking.TiesStrategy;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
|
||||
/**
|
||||
* Test cases for NaturalRanking class
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.math4.linear.RealVector;
|
|||
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.RandomSource;
|
||||
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.math4.stat.correlation.Covariance;
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.util.Random;
|
|||
import org.apache.commons.math4.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math4.exception.OutOfRangeException;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.stat.regression.ModelSpecificationException;
|
||||
import org.apache.commons.math4.stat.regression.RegressionResults;
|
||||
import org.apache.commons.math4.stat.regression.SimpleRegression;
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.apache.commons.math4.dfp.DfpField;
|
|||
import org.apache.commons.math4.dfp.DfpMath;
|
||||
import org.apache.commons.math4.exception.MathArithmeticException;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.commons.math4.exception.NotPositiveException;
|
|||
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math4.exception.NullArgumentException;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.MathArrays;
|
||||
import org.apache.commons.math4.util.Precision;
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.apache.commons.math4.exception.NotFiniteNumberException;
|
|||
import org.apache.commons.math4.exception.NullArgumentException;
|
||||
import org.apache.commons.math4.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.apache.commons.math4.distribution.IntegerDistribution;
|
|||
import org.apache.commons.math4.distribution.UniformIntegerDistribution;
|
||||
import org.apache.commons.math4.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math4.exception.NullArgumentException;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.util.ResizableDoubleArray.ExpansionMode;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
|
|
Loading…
Reference in New Issue