コード例 #1
0
  public double proposal() {
    double logq = 0.0;
    // Pick two indcies at random
    int index1 = Randomizer.nextInt(pointerCount);
    int index2 = index1;
    while (index2 == index1) {
      index2 = Randomizer.nextInt(pointerCount);
    }

    int clusterIndex1 = paramPointers.indexInList(index1, paramList);
    int clusterIndex2 = paramPointers.indexInList(index2, paramList);

    // If the randomly draw sites are from the same cluster, perform a split-move.
    if (clusterIndex1 == clusterIndex2) {

      int[] clusterSites = dpValuableInput.get().getClusterSites(clusterIndex1);

      double temp = split(index1, index2, clusterIndex1, clusterSites);
      // System.out.println("split: "+temp);
      logq += temp;

      // System.out.println("split: "+temp);

    } else {
      // If the the two randomly drawn sites are not from the same cluster, perform a merge-move.

      int[] cluster1Sites = dpValuableInput.get().getClusterSites(clusterIndex1);
      int[] cluster2Sites = dpValuableInput.get().getClusterSites(clusterIndex2);

      // logq = merge(index1, index2,clusterIndex1,clusterIndex2,cluster1Sites,cluster2Sites);
      double temp =
          merge(index1, index2, clusterIndex1, clusterIndex2, cluster1Sites, cluster2Sites);

      // System.out.println("merge: "+temp);
      logq = temp;
    }
    return logq;
  }