/** * Finds the cluster which is the closest to each point. The point is the added to the sum for the cluster * and its member count incremented */ protected void matchPointsToClusters(List<double[]> points) { sumDistance = 0; for (int i = 0; i < points.size(); i++) { double[]p = points.get(i); // find the cluster which is closest to the point int bestCluster = findBestMatch(p); // sum up all the points which are members of this cluster double[] c = workClusters.get(bestCluster); for (int j = 0; j < c.length; j++) { c[j] += p[j]; } memberCount.data[bestCluster]++; labels.data[i] = bestCluster; sumDistance += bestDistance; } }
/** * Finds the cluster which is the closest to each point. The point is the added to the sum for the cluster * and its member count incremented */ protected void matchPointsToClusters(List<double[]> points) { sumDistance = 0; for (int i = 0; i < points.size(); i++) { double[]p = points.get(i); // find the cluster which is closest to the point int bestCluster = findBestMatch(p); // sum up all the points which are members of this cluster double[] c = workClusters.get(bestCluster); for (int j = 0; j < c.length; j++) { c[j] += p[j]; } memberCount.data[bestCluster]++; labels.data[i] = bestCluster; sumDistance += bestDistance; } }