NormalDistributionStatisticsComputer implements Serializable { public List<NormalDistributionStatistics> reduceStats(List<NormalDistributionStatistics> left, List<NormalDistributionStatistics> right, List<FeatureMeta> meta) { if (left == null) return right; if (right == null) return left; assert meta.size() == left.size() && meta.size() == right.size(); List<NormalDistributionStatistics> res = new ArrayList<>(); for (int featureId = 0; featureId < meta.size(); featureId++) { NormalDistributionStatistics leftStat = left.get(featureId); NormalDistributionStatistics rightStat = right.get(featureId); res.add(leftStat.plus(rightStat)); } return res; }  List<NormalDistributionStatistics> computeStatistics(List<FeatureMeta> meta, Dataset<EmptyContext,
        BootstrappedDatasetPartition> dataset); List<NormalDistributionStatistics> computeStatsOnPartition(BootstrappedDatasetPartition part,
        List<FeatureMeta> meta); List<NormalDistributionStatistics> reduceStats(List<NormalDistributionStatistics> left,
        List<NormalDistributionStatistics> right,
        List<FeatureMeta> meta);  }
@Test public void reduceStatsTest() { List<NormalDistributionStatistics> left = Arrays.asList( new NormalDistributionStatistics(0, 9, 285, 45, 10), new NormalDistributionStatistics(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0, 0, 10), new NormalDistributionStatistics(2, 11, 505, 65, 10), new NormalDistributionStatistics(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0, 0, 10), new NormalDistributionStatistics(4, 13, 805, 85, 10), new NormalDistributionStatistics(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0, 0, 10), new NormalDistributionStatistics(6, 15, 1185, 105, 10) ); List<NormalDistributionStatistics> right = Arrays.asList( new NormalDistributionStatistics(6, 15, 1185, 105, 10), new NormalDistributionStatistics(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0, 0, 10), new NormalDistributionStatistics(4, 13, 805, 85, 10), new NormalDistributionStatistics(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0, 0, 10), new NormalDistributionStatistics(2, 11, 505, 65, 10), new NormalDistributionStatistics(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0, 0, 10), new NormalDistributionStatistics(0, 9, 285, 45, 10) ); List<NormalDistributionStatistics> res = computer.reduceStats(left, right, meta); NormalDistributionStatistics[] exp = new NormalDistributionStatistics[] { new NormalDistributionStatistics(0, 15, 1470, 150, 20), new NormalDistributionStatistics(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0, 0, 10), new NormalDistributionStatistics(2, 13, 1310, 150, 20), new NormalDistributionStatistics(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0, 0, 10), new NormalDistributionStatistics(2, 13, 1310, 150, 20), new NormalDistributionStatistics(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0, 0, 10), new NormalDistributionStatistics(0, 15, 1470, 150, 20) }; assertEquals(exp.length, res.size()); for (int i = 0; i < exp.length; i++) { NormalDistributionStatistics expStat = exp[i]; NormalDistributionStatistics resStat = res.get(i); assertEquals(expStat.mean(), resStat.mean(), 0.01); assertEquals(expStat.variance(), resStat.variance(), 0.01); assertEquals(expStat.std(), resStat.std(), 0.01); assertEquals(expStat.min(), resStat.min(), 0.01); assertEquals(expStat.max(), resStat.max(), 0.01); } }