code: public DoubleVector[] chooseSeeds(int numCentroids, Matrix dataPoints) {
          DoubleVector[] centers = new DoubleVector[numCentroids];
  
          // In the random chance that there are fewer data points than seeds,
          // simply set the data points as the seeds.
          if (numCentroids >= dataPoints.rows()) {
              for (int i = 0; i < dataPoints.rows(); ++i)
                  centers[i] = dataPoints.getRowVector(i);
  
              // For any extra slots that do not have a data point, use an empty
              // vector, which will have zero similarity with any other data
              // point.
              for (int i = dataPoints.rows(); i < numCentroids; ++i)
                  centers[i] = new DenseVector(dataPoints.columns());
  
              return centers;
          }
  
          // 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;
      }
docs: {@inheritDoc}