NormalDistributionStatisticsComputer implements Serializable { public List<NormalDistributionStatistics> computeStatsOnPartition(BootstrappedDatasetPartition part, List<FeatureMeta> meta) { double[] sumOfValues = new double[meta.size()]; double[] sumOfSquares = new double[sumOfValues.length]; double[] min = new double[sumOfValues.length]; double[] max = new double[sumOfValues.length]; Arrays.fill(min, Double.POSITIVE_INFINITY); Arrays.fill(max, Double.NEGATIVE_INFINITY); for (int i = 0; i < part.getRowsCount(); i++) { Vector vec = part.getRow(i).features(); for (int featureId = 0; featureId < vec.size(); featureId++) { if (!meta.get(featureId).isCategoricalFeature()) { double featureVal = vec.get(featureId); sumOfValues[featureId] += featureVal; sumOfSquares[featureId] += Math.pow(featureVal, 2); min[featureId] = Math.min(min[featureId], featureVal); max[featureId] = Math.max(max[featureId], featureVal); } } } ArrayList<NormalDistributionStatistics> res = new ArrayList<>(); for (int featureId = 0; featureId < sumOfSquares.length; featureId++) { res.add(new NormalDistributionStatistics( min[featureId], max[featureId], sumOfSquares[featureId], sumOfValues[featureId], part.getRowsCount()) ); } 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 computeStatsOnPartitionTest() { List<NormalDistributionStatistics> res = computer.computeStatsOnPartition(partition, meta); NormalDistributionStatistics[] exp = new NormalDistributionStatistics[] { 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), }; 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); } }