コード例 #1
0
 /**
  * @param updateFormula formula to use for updating the β parameter, must be one of {@link
  *     Formula#FLETCHER_REEVES} or {@link Formula#POLAK_RIBIERE}.
  * @param checker Convergence checker.
  * @param lineSearchSolver Solver to use during line search.
  * @param preconditioner Preconditioner.
  * @deprecated as of 3.3. Please use {@link
  *     #NonLinearConjugateGradientOptimizer(Formula,ConvergenceChecker,double,double,double,Preconditioner)}
  *     instead.
  */
 @Deprecated
 public NonLinearConjugateGradientOptimizer(
     final Formula updateFormula,
     ConvergenceChecker<PointValuePair> checker,
     final UnivariateSolver lineSearchSolver,
     final Preconditioner preconditioner) {
   this(
       updateFormula,
       checker,
       lineSearchSolver.getRelativeAccuracy(),
       lineSearchSolver.getAbsoluteAccuracy(),
       lineSearchSolver.getAbsoluteAccuracy(),
       preconditioner);
 }
コード例 #2
0
ファイル: Fitter.java プロジェクト: antonl/micro-manager
  /**
   * Finds the x value corresponding to the maximum function value within the range of the provided
   * data set.
   *
   * @param type one of the Fitter.FunctionType predefined functions
   * @param parms parameters describing the function. These need to match the selected function or
   *     an IllegalArgumentEception will be thrown
   * @param data JFreeChart series, used to bracket the range in which the maximum will be found
   * @return x value corresponding to the maximum function value
   */
  public static double getXofMaxY(XYSeries data, FunctionType type, double[] parms) {
    double xAtMax = 0.0;
    double minX = data.getMinX();
    double maxX = data.getMaxX();
    switch (type) {
      case NoFit:
        //  find the position in data with the highest y value
        double highestScore = data.getY(0).doubleValue();
        int highestIndex = 0;
        for (int i = 1; i < data.getItemCount(); i++) {
          double newVal = data.getY(i).doubleValue();
          if (newVal > highestScore) {
            highestScore = newVal;
            highestIndex = i;
          }
        }
        return data.getX(highestIndex).doubleValue();
      case Pol1:
      case Pol2:
      case Pol3:
        checkParms(type, parms);
        PolynomialFunction derivativePolFunction =
            (new PolynomialFunction(parms)).polynomialDerivative();

        final double relativeAccuracy = 1.0e-12;
        final double absoluteAccuracy = 1.0e-8;
        final int maxOrder = 5;
        UnivariateSolver solver =
            new BracketingNthOrderBrentSolver(relativeAccuracy, absoluteAccuracy, maxOrder);
        xAtMax = solver.solve(100, derivativePolFunction, minX, maxX);
        break;
      case Gaussian:
        // for a Gaussian we can take the mean and be sure it is the maximum
        // note that this may be outside our range of X values, but
        // this will be caught by our sanity checks below
        xAtMax = parms[1];
    }

    // sanity checks
    if (xAtMax > maxX) xAtMax = maxX;
    if (xAtMax < minX) xAtMax = minX;

    return xAtMax;
  }