@Test
public void testReduce() {

    MeanWithClusterProbAggregator aggregator3 = new MeanWithClusterProbAggregator();
    MeanWithClusterProbAggregator aggregator4 = new MeanWithClusterProbAggregator();
    aggregator3.add(VectorUtils.of(1., 1.), 0.5);
    aggregator3.add(VectorUtils.of(0., 1.), 0.25);
    aggregator3.add(VectorUtils.of(1., 0.), 0.25);
    aggregator3.add(VectorUtils.of(0., 0.), 0.5);
    aggregator4.add(VectorUtils.of(1., 1.), 1.0);
    aggregator4.add(VectorUtils.of(0., 1.), 1.0);
    aggregator4.add(VectorUtils.of(1., 0.), 1.0);
    aggregator4.add(VectorUtils.of(0., 0.), 1.0);
    List<MeanWithClusterProbAggregator> res = MeanWithClusterProbAggregator.reduce(
        Arrays.asList(aggregator1, aggregator3),
        Arrays.asList(aggregator2, aggregator4)
    );
    MeanWithClusterProbAggregator res1 = res.get(0);
    assertEquals(0.70, res1.clusterProb(), 1e-2);
    assertArrayEquals(new double[] {0.580, 0.491}, res1.mean().asArray(), 1e-2);
    MeanWithClusterProbAggregator res2 = res.get(1);
    assertEquals(0.68, res2.clusterProb(), 1e-2);
    assertArrayEquals(new double[] {0.50, 0.50}, res2.mean().asArray(), 1e-2);
}