Пример #1
0
  public double getChi2(Graph g) {
    double chi2 = Double.MAX_VALUE;

    for (int i = 0; i < components.length; i++) {
      chi2 = Math.min(chi2, -2 * Math.log(weights[i]) + components[i].getChi2(g));
    }

    return chi2;
  }
Пример #2
0
  public Linearization linearize(Graph g, Linearization lin) {
    double bestChi2 = Double.MAX_VALUE;
    GEdge bestEdge = null;
    int besti = -1;

    for (int i = 0; i < components.length; i++) {
      double thisChi2 = -2 * Math.log(weights[i]) + components[i].getChi2(g);
      if (thisChi2 < bestChi2) {
        bestChi2 = thisChi2;
        bestEdge = components[i];
        besti = i;
      }
      System.out.printf("%d %15f\n", i, thisChi2);
    }

    System.out.println("besti: " + besti);
    return bestEdge.linearize(g, lin);
  }