Package org.apache.commons.math.optimization.general

Examples of org.apache.commons.math.optimization.general.LevenbergMarquardtOptimizer


        Random randomizer = new Random(64925784252l);
        for (int degree = 1; degree < 10; ++degree) {
            PolynomialFunction p = buildRandomPolynomial(degree, randomizer);

            PolynomialFitter fitter =
                new PolynomialFitter(degree, new LevenbergMarquardtOptimizer());
            for (int i = 0; i <= degree; ++i) {
                fitter.addObservedPoint(1.0, i, p.value(i));
            }

            PolynomialFunction fitted = fitter.fit();
View Full Code Here


        double maxError = 0;
        for (int degree = 0; degree < 10; ++degree) {
            PolynomialFunction p = buildRandomPolynomial(degree, randomizer);

            PolynomialFitter fitter =
                new PolynomialFitter(degree, new LevenbergMarquardtOptimizer());
            for (double x = -1.0; x < 1.0; x += 0.01) {
                fitter.addObservedPoint(1.0, x,
                                        p.value(x) + 0.1 * randomizer.nextGaussian());
            }

View Full Code Here

    }

    @Test
    public void testRedundantSolvable() {
        // Levenberg-Marquardt should handle redundant information gracefully
        checkUnsolvableProblem(new LevenbergMarquardtOptimizer(), true);
    }
View Full Code Here

    @Test
    public void testNoError() throws OptimizationException {
        HarmonicFunction f = new HarmonicFunction(0.2, 3.4, 4.1);

        HarmonicFitter fitter =
            new HarmonicFitter(new LevenbergMarquardtOptimizer());
        for (double x = 0.0; x < 1.3; x += 0.01) {
            fitter.addObservedPoint(1.0, x, f.value(x));
        }

        HarmonicFunction fitted = fitter.fit();
View Full Code Here

    public void test1PercentError() throws OptimizationException {
        Random randomizer = new Random(64925784252l);
        HarmonicFunction f = new HarmonicFunction(0.2, 3.4, 4.1);

        HarmonicFitter fitter =
            new HarmonicFitter(new LevenbergMarquardtOptimizer());
        for (double x = 0.0; x < 10.0; x += 0.1) {
            fitter.addObservedPoint(1.0, x,
                                   f.value(x) + 0.01 * randomizer.nextGaussian());
        }

View Full Code Here

    public void testInitialGuess() throws OptimizationException {
        Random randomizer = new Random(45314242l);
        HarmonicFunction f = new HarmonicFunction(0.2, 3.4, 4.1);

        HarmonicFitter fitter =
            new HarmonicFitter(new LevenbergMarquardtOptimizer(), new double[] { 0.15, 3.6, 4.5 });
        for (double x = 0.0; x < 10.0; x += 0.1) {
            fitter.addObservedPoint(1.0, x,
                                   f.value(x) + 0.01 * randomizer.nextGaussian());
        }

View Full Code Here

    public void testUnsorted() throws OptimizationException {
        Random randomizer = new Random(64925784252l);
        HarmonicFunction f = new HarmonicFunction(0.2, 3.4, 4.1);

        HarmonicFitter fitter =
            new HarmonicFitter(new LevenbergMarquardtOptimizer());

        // build a regularly spaced array of measurements
        int size = 100;
        double[] xTab = new double[size];
        double[] yTab = new double[size];
View Full Code Here

    @Test
    public void testMath303()
        throws OptimizationException, FunctionEvaluationException {

        LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
        CurveFitter fitter = new CurveFitter(optimizer);
        fitter.addObservedPoint(2.805d, 0.6934785852953367d);
        fitter.addObservedPoint(2.74333333333333d, 0.6306772025518496d);
        fitter.addObservedPoint(1.655d, 0.9474675497289684);
        fitter.addObservedPoint(1.725d, 0.9013594835804194d);
View Full Code Here

    @Test
    public void testMath304()
        throws OptimizationException, FunctionEvaluationException {

        LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
        CurveFitter fitter = new CurveFitter(optimizer);
        fitter.addObservedPoint(2.805d, 0.6934785852953367d);
        fitter.addObservedPoint(2.74333333333333d, 0.6306772025518496d);
        fitter.addObservedPoint(1.655d, 0.9474675497289684);
        fitter.addObservedPoint(1.725d, 0.9013594835804194d);
View Full Code Here

          minDegree, maxDegree);

      if (!polyDegreeDialog.isCancelled()) {
        setDegree(polyDegreeDialog.getDegree());

        final AbstractLeastSquaresOptimizer optimizer = new LevenbergMarquardtOptimizer();

        final PolynomialFitter fitter = new PolynomialFitter(
            getDegree(), optimizer);

        model = new IModel() {
          boolean interrupted = false;
          List<ValidObservation> fit;
          List<ValidObservation> residuals;
          PolynomialFunction function;
          // ICoordSource coordSrc = JDCoordSource.instance;
          Map<String, String> functionStrMap = new LinkedHashMap<String, String>();
          double aic = Double.NaN;
          double bic = Double.NaN;

          @Override
          public String getDescription() {
            return LocaleProps
                .get("MODEL_INFO_POLYNOMIAL_DEGREE_DESC")
                + degree
                + " for "
                + obs.get(0).getBand()
                + " series";
          }

          @Override
          public List<ValidObservation> getFit() {
            return fit;
          }

          @Override
          public List<ValidObservation> getResiduals() {
            return residuals;
          }

          @Override
          public String getKind() {
            return LocaleProps.get("ANALYSIS_MENU_POLYNOMIAL_FIT");
          }

          @Override
          public List<PeriodFitParameters> getParameters() {
            // None for a polynomial fit.
            return null;
          }

          @Override
          public boolean hasFuncDesc() {
            return true;
          }

          public String toFitMetricsString() throws AlgorithmError {
            String strRepr = functionStrMap
                .get("MODEL_INFO_FIT_METRICS_TITLE");

            // DecimalFormat fmt = NumericPrecisionPrefs
            // .getOtherOutputFormat();

            // List<Double> derivs = new ArrayList<Double>();

            if (strRepr == null) {
              // Goodness of fit.
              strRepr = "RMS: "
                  + NumericPrecisionPrefs
                      .formatOther(optimizer.getRMS());

              // Akaike and Bayesean Information Criteria.
              if (aic != Double.NaN && bic != Double.NaN) {
                strRepr += "\nAIC: "
                    + NumericPrecisionPrefs
View Full Code Here

TOP

Related Classes of org.apache.commons.math.optimization.general.LevenbergMarquardtOptimizer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.