code: public static KmeansPoint calculateCentroid(List<KmeansPoint> basePoints)
      {
          double[] firstDataPoint = basePoints.get(0).getDataPoint();
          double[] centroidSum = Arrays.copyOf(firstDataPoint, firstDataPoint.length);
  
          for (int pointIndex = 1; pointIndex < basePoints.size(); pointIndex++)
          {
              for (int coordinateIndex = 0; coordinateIndex < centroidSum.length; coordinateIndex++)
              {
                  centroidSum[coordinateIndex] = centroidSum[coordinateIndex]
                          + basePoints.get(pointIndex).getDataPoint()[coordinateIndex];
              }
          }
  
          double[] centroidPoints = sub(centroidSum, basePoints.size());
          KmeansPoint centroid = new KmeansPoint();
          centroid.setDataPoint(centroidPoints);
          return centroid;
      }
docs: 指定したリスト内での中心点を算出する。
  
  @param basePoints 算出元点リスト
  @return 中心点