예제 #1
0
  private void findBracket() {

    if (myWFunction.fx(1.0) > 0.0) {
      myAlphaPos = 1.0;
      double alpha = 1.0;
      do {
        alpha = alpha * 2.0;
      } while (myWFunction.fx(alpha) >= 0.0); // when f(a) < 0, then it drops out of the while loop
      myAlphaNeg = alpha;
    } else {
      myAlphaNeg = 1.0;
      double alpha = 1.0;
      do {
        alpha = alpha / 2.0;
      } while (myWFunction.fx(alpha) <= 0.0); // when f(a) > 0, then it drops out of the while loop
      myAlphaPos = alpha;
    }
  }
예제 #2
0
  private void matchWeibull(double mean, Weibull w) {
    myC2vCDF.setRange(0.0, myMaxC2v);
    boolean flag = true;
    do {
      double c2v = myC2vCDF.getValue();
      myWFunction.setC2v(c2v);
      findBracket();
      myZeroFinder.setInterval(myWFunction, myAlphaNeg, myAlphaPos);
      myZeroFinder.setInitialPoint((myAlphaNeg + myAlphaPos) / 2.0);

      myZeroFinder.evaluate();
      double shape = myZeroFinder.getResult();
      double scale = mean / Gamma.gammaFunction(1.0 + 1.0 / shape);
      w.setScale(scale);
      w.setShape(shape);
      if (myZeroFinder.hasConverged()) flag = true;
      else flag = false;
    } while (flag == false);
  }