DetailedStatistics extends SimpleStatistics<T> { @Override public String toString() { int count = this.getCount(); String samples = Inflector.getInstance().pluralize("sample", count); return StringUtil.createString("{0} {1}: min={2}; avg={3}; median={4}; stddev={5}; max={6}", count, samples, this.getMinimum(), this.getMean(), this.getMedian(), this.getStandardDeviation(), this.getMaximum()); } DetailedStatistics( MathOperations<T> operations ); List<T> getValues(); T getMedian(); double getMedianValue(); double getStandardDeviation(); Histogram<T> getHistogram(); Histogram<T> getHistogram( int numSigmas ); @Override String toString();  }
@Test public void shouldHaveStringRepresentationWithoutStatisticsForSingleSample() { this.intStats.add(19); String str = this.intStats.toString(); System.out.println(str); assertTrue(str.matches("1 sample.*")); assertTrue(str.matches(".*min=\\d{1,5}.*")); assertTrue(str.matches(".*max=\\d{1,5}.*")); assertTrue(str.matches(".*avg=\\d{1,5}.*")); assertTrue(str.matches(".*stddev=\\d{1,5}.*")); assertTrue(str.matches(".*median=\\d{1,5}.*")); }
@Test public void shouldHaveStringRepresentationWithStatisticsForMultipleSample() { this.intStats.add(19); this.intStats.add(10); this.intStats.add(20); String str = this.intStats.toString(); System.out.println(str); assertTrue(str.matches("^\\d{1,5}.*")); assertTrue(str.matches(".*3 samples.*")); assertTrue(str.matches(".*min=\\d{1,5}.*")); assertTrue(str.matches(".*max=\\d{1,5}.*")); assertTrue(str.matches(".*avg=\\d{1,5}.*")); assertTrue(str.matches(".*stddev=\\d{1,5}.*")); assertTrue(str.matches(".*median=\\d{1,5}.*")); }