/*
  * Salichos Stamatakis and Rokas, MBE v31 p1261 (2014)
  * If only two splits are listed, returns IC, the Internode Certainty.
  * If more splits are listed, returns ICA, (IC All).
  */
 private double internodeCertainty(DoubleList<Split, Integer> splits) {
   int sum = 0;
   int n = splits.size(); // number of splits under consideration
   for (int i = 0; i < n; i++) sum += splits.getB(i);
   double ic = 1;
   if (n > 1) {
     ic = Math.log(n);
     for (int i = 0; i < n; i++) {
       double p = ((double) splits.getB(i)) / sum;
       ic += p * Math.log(p);
     }
     ic /= Math.log(n); // convert from natural log to log base n
   }
   return ic;
 }
 /**
  * @return f[] where f[i]==c indicates there were c splits which were present in exactly i trees.
  */
 public int[] countByFrequency() {
   int max = 0;
   if (splitsAddedOnlyViaTrees) max = nTrees;
   else for (int n : counts.values()) max = Math.max(max, n);
   int[] freq = new int[max];
   for (int i : counts.values()) freq[i - 1]++;
   return freq;
 }
 /**
  * Returns the sum of the Robinson Foulds distances between the majority rules consensus tree and
  * each tree in the collection. This does not actually require calculating the majority rule tree.
  *
  * @return
  */
 public int sumRFtoMajRuleTree() {
   // Somebody used 'addSplitSystem()' method to supply splits to this count.
   if (!splitsAddedOnlyViaTrees)
     throw new RuntimeException(
         "Can't determine consensus tree unless splits added only via trees");
   int sumDist = 0;
   for (Integer count : counts.values()) {
     sumDist += Math.min(count, nTrees - count);
   }
   return sumDist;
 }