コード例 #1
0
  /**
   * Normalizes branch sizes so they contain frequencies (stored in "props") instead of counts
   * (stored in "dist").
   *
   * <p>Overwrites the supplied "props"!
   *
   * <p>props.length must be == dist.length.
   */
  protected static void countsToFreqs(double[][] dist, double[] props) {

    for (int k = 0; k < props.length; k++) {
      props[k] = Utils.sum(dist[k]);
    }
    if (Utils.eq(Utils.sum(props), 0)) {
      for (int k = 0; k < props.length; k++) {
        props[k] = 1.0 / (double) props.length;
      }
    } else {
      FastRfUtils.normalize(props);
    }
  }
コード例 #2
0
  /**
   * Normalizes branch sizes so they contain frequencies (stored in "props") instead of counts
   * (stored in "dist"). Creates a new double[] which it returns.
   */
  protected static double[] countsToFreqs(double[][] dist) {

    double[] props = new double[dist.length];

    for (int k = 0; k < props.length; k++) {
      props[k] = Utils.sum(dist[k]);
    }
    if (Utils.eq(Utils.sum(props), 0)) {
      for (int k = 0; k < props.length; k++) {
        props[k] = 1.0 / (double) props.length;
      }
    } else {
      FastRfUtils.normalize(props);
    }
    return props;
  }