Added statistics missing from toString method in SummaryStatistics.
JIRA: MATH-1147
This commit is contained in:
parent
97accb47de
commit
e3dda4407a
|
@ -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).
|
||||
">
|
||||
<action dev="psteitz" type="fix" issue="MATH-1147">
|
||||
Added statistics missing from toString method in SummaryStatistics.
|
||||
</action>
|
||||
<action dev="tn" type="fix" issue="MATH-1152" due-to="Andras Sereny">
|
||||
Improved performance of "EnumeratedDistribution#sample()" by caching
|
||||
the cumulative probabilities and using binary rather than a linear search.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue