Generating summary statistics
We can generate summary statistics for data by using the SummaryStatistics class. This is similar to the DescriptiveStatistics class used in the preceding recipe; the major difference is that unlike the DescriptiveStatistics class, the SummaryStatistics class does not store data in memory.
How to do it...
- Like the preceding recipe, create a method that takes a
doublearray as argument:public void getSummaryStats(double[] values){ - Create an object of class
SummaryStatistics:SummaryStatistics stats = new SummaryStatistics();
- Add all the values to this object of theÂ
SummaryStatisticsclass:for( int i = 0; i < values.length; i++) { stats.addValue(values[i]); } - Finally, use methods in the
SummaryStatisticsclass to generate the summary statistics for the values. Close the method when you are done using the statistics:
double mean = stats.getMean();
double std = stats.getStandardDeviation...