code: public static KmeansResult nearestCentroid(KmeansPoint targetPoint, List<KmeansPoint> centroids)
      {
          int nearestCentroidIndex = 0;
          Double minDistance = Double.MAX_VALUE;
          KmeansPoint currentCentroid = null;
          Double currentDistance;
          for (int index = 0; index < centroids.size(); index++)
          {
              currentCentroid = centroids.get(index);
              if (currentCentroid != null && currentCentroid.getDataPoint() != null)
              {
                  currentDistance = MathUtils.distance(targetPoint.getDataPoint(),
                          currentCentroid.getDataPoint());
                  if (currentDistance < minDistance)
                  {
                      minDistance = currentDistance;
                      nearestCentroidIndex = index;
                  }
              }
          }
  
          currentCentroid = centroids.get(nearestCentroidIndex);
  
          KmeansResult result = new KmeansResult();
          result.setDataPoint(targetPoint.getDataPoint());
          result.setCentroidIndex(nearestCentroidIndex);
          result.setCentroid(currentCentroid.getDataPoint());
          result.setDistance(minDistance);
  
          return result;
      }
docs: 対象点と中心点配列を指定し、対象点に最も近い中心点のインデックスを取得し、結果エンティティを返す
  
  @param targetPoint 判定対象ポイント
  @param centroids 中心点リスト
  @return Kmeans算出結果