diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index fdb2bd41f..36cd1d690 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -73,6 +73,9 @@ Users are encouraged to upgrade to this version as this release not
2. A few methods in the FastMath class are in fact slower that their
counterpart in either Math or StrictMath (cf. MATH-740 and MATH-901).
">
+
+ Added statistics missing from toString method in SummaryStatistics.
+
Improved performance of "EnumeratedDistribution#sample()" by caching
the cumulative probabilities and using binary rather than a linear search.
diff --git a/src/main/java/org/apache/commons/math3/stat/descriptive/SummaryStatistics.java b/src/main/java/org/apache/commons/math3/stat/descriptive/SummaryStatistics.java
index ff32af5bb..2fe8599a7 100644
--- a/src/main/java/org/apache/commons/math3/stat/descriptive/SummaryStatistics.java
+++ b/src/main/java/org/apache/commons/math3/stat/descriptive/SummaryStatistics.java
@@ -327,10 +327,13 @@ public class SummaryStatistics implements StatisticalSummary, Serializable {
outBuffer.append("n: ").append(getN()).append(endl);
outBuffer.append("min: ").append(getMin()).append(endl);
outBuffer.append("max: ").append(getMax()).append(endl);
+ outBuffer.append("sum: ").append(getSum()).append(endl);
outBuffer.append("mean: ").append(getMean()).append(endl);
outBuffer.append("geometric mean: ").append(getGeometricMean())
.append(endl);
outBuffer.append("variance: ").append(getVariance()).append(endl);
+ outBuffer.append("population variance: ").append(getPopulationVariance()).append(endl);
+ outBuffer.append("second moment: ").append(getSecondMoment()).append(endl);
outBuffer.append("sum of squares: ").append(getSumsq()).append(endl);
outBuffer.append("standard deviation: ").append(getStandardDeviation())
.append(endl);
diff --git a/src/test/java/org/apache/commons/math3/stat/descriptive/SummaryStatisticsTest.java b/src/test/java/org/apache/commons/math3/stat/descriptive/SummaryStatisticsTest.java
index 3c0b749ef..ba77d8709 100644
--- a/src/test/java/org/apache/commons/math3/stat/descriptive/SummaryStatisticsTest.java
+++ b/src/test/java/org/apache/commons/math3/stat/descriptive/SummaryStatisticsTest.java
@@ -335,4 +335,23 @@ public class SummaryStatisticsTest {
}
Assert.assertEquals((new GeometricMean()).evaluate(scores),stats.getGeometricMean(), 0);
}
+
+ @Test
+ public void testToString() {
+ SummaryStatistics u = createSummaryStatistics();
+ for (int i = 0; i < 5; i++) {
+ u.addValue(i);
+ }
+ final String[] labels = {"min", "max", "sum", "geometric mean", "variance",
+ "population variance", "second moment", "sum of squares", "standard deviation",
+ "sum of logs"};
+ final double[] values = {u.getMin(), u.getMax(), u.getSum(), u.getGeometricMean(),
+ u.getVariance(), u.getPopulationVariance(), u.getSecondMoment(), u.getSumsq(),
+ u.getStandardDeviation(), u.getSumOfLogs()};
+ final String toString = u.toString();
+ Assert.assertTrue(toString.indexOf("n: " + u.getN()) > 0); // getN() returns a long
+ for (int i = 0; i < values.length; i++) {
+ Assert.assertTrue(toString.indexOf(labels[i] + ": " + String.valueOf(values[i])) > 0);
+ }
+ }
}