MultivariateSummaryStatistics implements StatisticalMultivariateSummary, Serializable { @Override public String toString() { final String separator = ", "; final String suffix = System.getProperty("line.separator"); StringBuilder outBuffer = new StringBuilder(); outBuffer.append("MultivariateSummaryStatistics:" + suffix); outBuffer.append("n: " + getN() + suffix); append(outBuffer, getMin(), "min: ", separator, suffix); append(outBuffer, getMax(), "max: ", separator, suffix); append(outBuffer, getMean(), "mean: ", separator, suffix); append(outBuffer, getGeometricMean(), "geometric mean: ", separator, suffix); append(outBuffer, getSumSq(), "sum of squares: ", separator, suffix); append(outBuffer, getSumLog(), "sum of logarithms: ", separator, suffix); append(outBuffer, getStandardDeviation(), "standard deviation: ", separator, suffix); outBuffer.append("covariance: " + getCovariance().toString() + suffix); return outBuffer.toString(); } MultivariateSummaryStatistics(int k, boolean isCovarianceBiasCorrected); void addValue(double[] value); int getDimension(); long getN(); double[] getSum(); double[] getSumSq(); double[] getSumLog(); double[] getMean(); double[] getStandardDeviation(); RealMatrix getCovariance(); double[] getMax(); double[] getMin(); double[] getGeometricMean(); @Override String toString(); void clear(); @Override boolean equals(Object object); @Override int hashCode(); StorelessUnivariateStatistic[] getSumImpl(); void setSumImpl(StorelessUnivariateStatistic[] sumImpl); StorelessUnivariateStatistic[] getSumsqImpl(); void setSumsqImpl(StorelessUnivariateStatistic[] sumsqImpl); StorelessUnivariateStatistic[] getMinImpl(); void setMinImpl(StorelessUnivariateStatistic[] minImpl); StorelessUnivariateStatistic[] getMaxImpl(); void setMaxImpl(StorelessUnivariateStatistic[] maxImpl); StorelessUnivariateStatistic[] getSumLogImpl(); void setSumLogImpl(StorelessUnivariateStatistic[] sumLogImpl); StorelessUnivariateStatistic[] getGeoMeanImpl(); void setGeoMeanImpl(StorelessUnivariateStatistic[] geoMeanImpl); StorelessUnivariateStatistic[] getMeanImpl(); void setMeanImpl(StorelessUnivariateStatistic[] meanImpl);  }
@Test public void testToString() { MultivariateSummaryStatistics stats = createMultivariateSummaryStatistics(2, true); stats.addValue(new double[] {1, 3}); stats.addValue(new double[] {2, 2}); stats.addValue(new double[] {3, 1}); Locale d = Locale.getDefault(); Locale.setDefault(Locale.US); final String suffix = System.getProperty("line.separator"); Assert.assertEquals("MultivariateSummaryStatistics:" + suffix+ "n: 3" +suffix+ "min: 1.0, 1.0" +suffix+ "max: 3.0, 3.0" +suffix+ "mean: 2.0, 2.0" +suffix+ "geometric mean: 1.817..., 1.817..." +suffix+ "sum of squares: 14.0, 14.0" +suffix+ "sum of logarithms: 1.791..., 1.791..." +suffix+ "standard deviation: 1.0, 1.0" +suffix+ "covariance: Array2DRowRealMatrix{{1.0,-1.0},{-1.0,1.0}}" +suffix, stats.toString().replaceAll("([0-9]+\\.[0-9][0-9][0-9])[0-9]+", "$1...")); Locale.setDefault(d); }