@Override
  public double getValue(Distribution d, double total, int strategy) {
    BigInteger termA = BigInteger.ONE,
        termB = BigInteger.ZERO,
        termC = BigInteger.ONE,
        termD = BigInteger.ONE;
    double totalReal = 0;

    if (strategy == 0) totalReal = d.total();
    else totalReal = total;

    for (int i = 0; i < d.numClasses(); i++) {
      termA = termA.multiply(factorial(d.perClass(i)));
    }
    System.out.println("TermA = " + termA);
    //	termA = termA.divide(factorial(sum_weights));

    for (int j = 0; j < d.numBags(); j++) {
      termB = factorial(d.perBag(j));
      termC = BigInteger.ONE;
      for (int k = 0; k < d.numClasses(); k++) {
        termC = termC.multiply(factorial(d.perClassPerBag(j, k)));
      }
      termD = termD.multiply(termB.divide(termC));
    }
    System.out.println("TermD = " + termD);
    termA = termA.multiply(termD);
    System.out.println("Fatorial do total = " + factorial(totalReal));
    System.out.println("Final = " + termA.divide(factorial(totalReal)));
    return (termA.divide(factorial(totalReal))).doubleValue();
  }
Ejemplo n.º 2
0
  @Override
  public double getValue(Distribution d, double total, int strategy) {

    double equation = 0, totalReal = 0;

    if (strategy == 0) totalReal = d.total();
    else totalReal = total;

    for (int i = 0; i < d.numClasses(); i++) {
      for (int j = 0; j < d.numBags(); j++) {
        equation =
            equation
                + d.perClassPerBag(j, i)
                    * loge(d.perClassPerBag(j, i) * totalReal, d.perBag(j) * d.perClass(i));
      }
    }
    equation = equation * (1 / totalReal);
    return equation;
  }