UncorrelatedRandomVectorGenerator implements RandomVectorGenerator { public double[] nextVector() { double[] random = new double[mean.length]; for (int i = 0; i < random.length; ++i) { random[i] = mean[i] + standardDeviation[i] * generator.nextNormalizedDouble(); } return random; } UncorrelatedRandomVectorGenerator(double[] mean,
                                           double[] standardDeviation,
                                           NormalizedRandomGenerator generator);  UncorrelatedRandomVectorGenerator(int dimension,
                                           NormalizedRandomGenerator generator); double[] nextVector();  }
@Test public void testMeanAndCorrelation() { VectorialMean meanStat = new VectorialMean(mean.length); VectorialCovariance covStat = new VectorialCovariance(mean.length, true); for (int i = 0; i < 10000; ++i) { double[] v = generator.nextVector(); meanStat.increment(v); covStat.increment(v); } double[] estimatedMean = meanStat.getResult(); double scale; RealMatrix estimatedCorrelation = covStat.getResult(); for (int i = 0; i < estimatedMean.length; ++i) { Assert.assertEquals(mean[i], estimatedMean[i], 0.07); for (int j = 0; j < i; ++j) { scale = standardDeviation[i] * standardDeviation[j]; Assert.assertEquals(0, estimatedCorrelation.getEntry(i, j) / scale, 0.03); } scale = standardDeviation[i] * standardDeviation[i]; Assert.assertEquals(1, estimatedCorrelation.getEntry(i, i) / scale, 0.025); } }