StorelessCovariance extends Covariance { public void increment(final double[] data) throws DimensionMismatchException { int length = data.length; if (length != dimension) { throw new DimensionMismatchException(length, dimension); } for (int i = 0; i < length; i++){ for (int j = i; j < length; j++){ getElement(i, j).increment(data[i], data[j]); } } } StorelessCovariance(final int dim);  StorelessCovariance(final int dim, final boolean biasCorrected); double getCovariance(final int xIndex,
                                final int yIndex); void increment(final double[] data); void append(StorelessCovariance sc); @Override RealMatrix getCovarianceMatrix(); double[][] getData(); @Override int getN();  }
@Test public void testLonglySimpleVar(){ double rCov = 12333921.73333333246; StorelessBivariateCovariance cov = new StorelessBivariateCovariance(); for(int i=0;i<longleyDataSimple.length;i++){ cov.increment(longleyDataSimple[i][0],longleyDataSimple[i][0]); } TestUtils.assertEquals("simple covariance test", rCov, cov.getResult(), 10E-7); }
@Test public void testLonglySimpleCov(){ double rCov = 36796.660000; StorelessBivariateCovariance cov = new StorelessBivariateCovariance(); for(int i=0;i<longleyDataSimple.length;i++){ cov.increment(longleyDataSimple[i][0], longleyDataSimple[i][1]); } TestUtils.assertEquals("simple covariance test", rCov, cov.getResult(), 10E-7); }