Beispiel #1
0
  /**
   * Find the two clusters with the shortest Wishart distance among all clusters in the given
   * cluster list.
   *
   * @param clusterCenterList The cluster list.
   * @param clusterPair The indices of the two clusters with the shortest Wishart distance.
   * @return The shortest Wishart distance.
   */
  private double computeShortestDistance(
      final java.util.List<ClusterInfo> clusterCenterList, final int[] clusterPair) {

    final int numClusters = clusterCenterList.size();
    double shortestDistance = Double.MAX_VALUE;
    if (numClusters <= 3) {
      return shortestDistance;
    }

    double d;
    for (int i = 0; i < numClusters - 1; i++) {
      if (clusterCenterList.get(i).size >= maxClusterSize) {
        continue;
      }

      for (int j = i + 1; j < numClusters; j++) {
        if (clusterCenterList.get(j).size >= maxClusterSize) {
          continue;
        }

        d =
            HAlphaWishart.computeWishartDistance(
                clusterCenterList.get(i).centerRe,
                clusterCenterList.get(i).centerIm,
                clusterCenterList.get(j));

        if (d < shortestDistance) {
          shortestDistance = d;
          clusterPair[0] = i;
          clusterPair[1] = j;
        }
      }
    }
    return shortestDistance;
  }
Beispiel #2
0
  /**
   * Find the nearest cluster for a given T3 matrix using Wishart distance
   *
   * @param Tr Real part of the T3 matrix
   * @param Ti Imaginary part of the T3 matrix
   * @param clusterCenters The cluster centers
   * @return The zone index for the nearest cluster
   */
  public static int findClosestCluster(
      final double[][] Tr, final double[][] Ti, final java.util.List<ClusterInfo> clusterCenters) {

    double minDistance = Double.MAX_VALUE;
    int clusterIndex = -1;
    for (int c = 0; c < clusterCenters.size(); ++c) {
      final double d = HAlphaWishart.computeWishartDistance(Tr, Ti, clusterCenters.get(c));
      if (minDistance > d) {
        minDistance = d;
        clusterIndex = c;
      }
    }

    return clusterIndex;
  }