Generating summary statistics from multiple distributions
In this recipe, we will be creating an AggregateSummaryStatistics
instance to accumulate the overall statistics and SummaryStatistics
for the sample data.
How to do it...
- Create a method that takes two
double
array arguments. Each array will contain two different sets of data:public void getAggregateStats(double[] values1, double[] values2){
- Create an object of class
AggregateSummaryStatistics
:AggregateSummaryStatistics aggregate = new AggregateSummaryStatistics();
- To generate summary statistics from the two distributions, create two objects of the
SummaryStatistics
class:SummaryStatistics firstSet = aggregate.createContributingStatistics(); SummaryStatistics secondSet = aggregate.createContributingStatistics();
- Add the values of the two distributions in the two objects created in the preceding step:
for(int i = 0; i < values1.length; i++) { ...