Covariance { public Covariance() { super(); covarianceMatrix = null; n = 0; } Covariance();  Covariance(double[][] data, boolean biasCorrected);  Covariance(double[][] data);  Covariance(RealMatrix matrix, boolean biasCorrected);  Covariance(RealMatrix matrix); RealMatrix getCovarianceMatrix(); int getN(); double covariance(final double[] xArray, final double[] yArray, boolean biasCorrected); double covariance(final double[] xArray, final double[] yArray);  }
@Test public void testConstant() { double[] noVariance = new double[] {1, 1, 1, 1}; double[] values = new double[] {1, 2, 3, 4}; Assert.assertEquals(0d, new Covariance().covariance(noVariance, values, true), Double.MIN_VALUE); Assert.assertEquals(0d, new Covariance().covariance(noVariance, noVariance, true), Double.MIN_VALUE); }
@Test public void testInsufficientData() { double[] one = new double[] {1}; double[] two = new double[] {2}; try { new Covariance().covariance(one, two, false); Assert.fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { } try { new Covariance(new double[][] {{},{}}); Assert.fail("Expecting NotStrictlyPositiveException"); } catch (NotStrictlyPositiveException ex) { } }