diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/random/CorrelatedRandomVectorGenerator.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/random/CorrelatedRandomVectorGenerator.java
index 0338f5f38..789c05aad 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/random/CorrelatedRandomVectorGenerator.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/random/CorrelatedRandomVectorGenerator.java
@@ -17,13 +17,15 @@
package org.apache.commons.math4.legacy.random;
+import java.util.function.Supplier;
+
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
import org.apache.commons.math4.legacy.linear.RealMatrix;
import org.apache.commons.math4.legacy.linear.RectangularCholeskyDecomposition;
/**
- * A {@link RandomVectorGenerator} that generates vectors with with
- * correlated components.
+ * Generates vectors with with correlated components.
+ *
*
Random vectors with correlated components are built by combining
* the uncorrelated components of another random vector in such a way that
* the resulting correlations are the ones specified by a positive
@@ -57,8 +59,7 @@ import org.apache.commons.math4.legacy.linear.RectangularCholeskyDecomposition;
* @since 1.2
*/
-public class CorrelatedRandomVectorGenerator
- implements RandomVectorGenerator {
+public class CorrelatedRandomVectorGenerator implements Supplier {
/** Mean vector. */
private final double[] mean;
/** Underlying generator. */
@@ -162,8 +163,7 @@ public class CorrelatedRandomVectorGenerator
* is created at each call, the caller can do what it wants with it.
*/
@Override
- public double[] nextVector() {
-
+ public double[] get() {
// generate uncorrelated vector
for (int i = 0; i < normalized.length; ++i) {
normalized[i] = generator.nextNormalizedDouble();
@@ -181,5 +181,4 @@ public class CorrelatedRandomVectorGenerator
return correlated;
}
-
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/random/CorrelatedRandomVectorGeneratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/random/CorrelatedRandomVectorGeneratorTest.java
index 273e12638..1010c6476 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/random/CorrelatedRandomVectorGeneratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/random/CorrelatedRandomVectorGeneratorTest.java
@@ -89,7 +89,7 @@ public class CorrelatedRandomVectorGeneratorTest {
double[] max = new double[mean.length];
Arrays.fill(max, Double.NEGATIVE_INFINITY);
for (int i = 0; i < 10; i++) {
- double[] generated = sg.nextVector();
+ double[] generated = sg.get();
for (int j = 0; j < generated.length; ++j) {
min[j] = FastMath.min(min[j], generated[j]);
max[j] = FastMath.max(max[j], generated[j]);
@@ -118,7 +118,7 @@ public class CorrelatedRandomVectorGeneratorTest {
VectorialMean meanStat = new VectorialMean(mean.length);
VectorialCovariance covStat = new VectorialCovariance(mean.length, true);
for (int i = 0; i < 5000; ++i) {
- double[] v = generator.nextVector();
+ double[] v = generator.get();
meanStat.increment(v);
covStat.increment(v);
}
@@ -181,7 +181,7 @@ public class CorrelatedRandomVectorGeneratorTest {
StorelessCovariance cov = new StorelessCovariance(covMatrix.length);
for (int i = 0; i < samples; ++i) {
- cov.increment(sampler.nextVector());
+ cov.increment(sampler.get());
}
double[][] sampleCov = cov.getData();
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/regression/GLSMultipleLinearRegressionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/regression/GLSMultipleLinearRegressionTest.java
index f507be2eb..0e7bf3ffa 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/regression/GLSMultipleLinearRegressionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/regression/GLSMultipleLinearRegressionTest.java
@@ -276,7 +276,7 @@ public class GLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
for (int i = 0; i < nModels; i++) {
// Generate y = xb + u with u cov
- RealVector u = MatrixUtils.createRealVector(gen.nextVector());
+ RealVector u = MatrixUtils.createRealVector(gen.get());
double[] y = u.add(x.operate(b)).toArray();
// Estimate OLS parameters