// Select a subset of data points to be the new centroids.
BitSet selectedCentroids = Statistics.randomDistribution(
numCentroids, dataPoints.rows());
// Convert the selection indices into vectors.
for (int c = 0, i = selectedCentroids.nextSetBit(0); i >= 0;
c++, i = selectedCentroids.nextSetBit(i+1))
centers[c] = dataPoints.getRowVector(i);
return centers;
}