}
public void testMeanAndCovariance() throws DimensionMismatchException {
VectorialMean meanStat = new VectorialMean(mean.length);
VectorialCovariance covStat = new VectorialCovariance(mean.length, true);
for (int i = 0; i < 5000; ++i) {
double[] v = generator.nextVector();
meanStat.increment(v);
covStat.increment(v);
}
double[] estimatedMean = meanStat.getResult();
RealMatrix estimatedCovariance = covStat.getResult();
for (int i = 0; i < estimatedMean.length; ++i) {
assertEquals(mean[i], estimatedMean[i], 0.07);
for (int j = 0; j <= i; ++j) {
assertEquals(covariance.getEntry(i, j),
estimatedCovariance.getEntry(i, j),