The field statistics is MUCH bigger than most people realize. However most of the time people are looking for the basics: min, max, average (mean). These values are easily computed by any novice programmer with a loop and some simple math… but why waste your time when someone else has already done the work?
Commons-Math3 to the Rescue
Beyond using the stats classes on commons-math3, there are a few other “tricks” going here including: FastMath (always use this class over Math), Guava to convert from int to double, and the good old String class to format our results.
SummaryStatistics Vs. DescriptiveStatistics
commons-math3 is packed with VERY useful statistics classes beyond the ones described here. Their documentation is also GREAT. Poke around and explore, there is a ton of stuff there. As always you can find the source for this post on GitHub.
If you have any questions, please post them in the comments. If you find and fix any bugs or have improvements, please fork and make a pull request.
Thanks for reading…