@Test public void testAdd() { assertArrayEquals(new double[] {0.781, 0.468}, aggregator1.mean().asArray(), 1e-2); assertArrayEquals(new double[] {0.5, 0.5}, aggregator2.mean().asArray(), 1e-2); assertEquals(0.4, aggregator1.clusterProb(), 1e-4); assertEquals(1.0, aggregator2.clusterProb(), 1e-4); }
void add(Vector x, double pcxi) { A.ensure(pcxi >= 0 && pcxi <= 1., "pcxi >= 0 && pcxi <= 1."); Vector weightedVector = x.times(pcxi); if (weightedXsSum == null) weightedXsSum = weightedVector; else weightedXsSum = weightedXsSum.plus(weightedVector); pcxiSum += pcxi; rowCount += 1; }
MeanWithClusterProbAggregator implements Serializable { void add(Vector x, double pcxi) { A.ensure(pcxi >= 0 && pcxi <= 1., "pcxi >= 0 && pcxi <= 1."); Vector weightedVector = x.times(pcxi); if (weightedXsSum == null) weightedXsSum = weightedVector; else weightedXsSum = weightedXsSum.plus(weightedVector); pcxiSum += pcxi; rowCount += 1; } }
MeanWithClusterProbAggregator implements Serializable { void add(Vector x, double pcxi) { A.ensure(pcxi >= 0 && pcxi <= 1., "pcxi >= 0 && pcxi <= 1."); Vector weightedVector = x.times(pcxi); if (weightedXsSum == null) weightedXsSum = weightedVector; else weightedXsSum = weightedXsSum.plus(weightedVector); pcxiSum += pcxi; rowCount += 1; } MeanWithClusterProbAggregator();   MeanWithClusterProbAggregator(Vector weightedXsSum, double pcxiSum, int rowCount); }
MeanWithClusterProbAggregator implements Serializable { void add(Vector x, double pcxi) { A.ensure(pcxi >= 0 && pcxi <= 1., "pcxi >= 0 && pcxi <= 1."); Vector weightedVector = x.times(pcxi); if (weightedXsSum == null) weightedXsSum = weightedVector; else weightedXsSum = weightedXsSum.plus(weightedVector); pcxiSum += pcxi; rowCount += 1; } MeanWithClusterProbAggregator();   MeanWithClusterProbAggregator(Vector weightedXsSum, double pcxiSum, int rowCount); Vector mean(); double clusterProb(); static AggregatedStats aggreateStats(Dataset<EmptyContext, GmmPartitionData> dataset, int countOfComponents); }
MeanWithClusterProbAggregator implements Serializable { void add(Vector x, double pcxi) { A.ensure(pcxi >= 0 && pcxi <= 1., "pcxi >= 0 && pcxi <= 1."); Vector weightedVector = x.times(pcxi); if (weightedXsSum == null) weightedXsSum = weightedVector; else weightedXsSum = weightedXsSum.plus(weightedVector); pcxiSum += pcxi; rowCount += 1; } MeanWithClusterProbAggregator();   MeanWithClusterProbAggregator(Vector weightedXsSum, double pcxiSum, int rowCount); Vector mean(); double clusterProb(); static AggregatedStats aggreateStats(Dataset<EmptyContext, GmmPartitionData> dataset, int countOfComponents);  }