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

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


        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

        // Number of transits
        logger.debug("Fit: Gaia will perform "+transits.size()+" transits of the system.");
       
        // Optimizer set-up
        logger.debug("Fit: Start fit.");
        LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
        optimizer.setMaxIterations(MAX_ITERATIONS);
        optimizer.setCostRelativeTolerance(CONVERGENCE);
        optimizer.setParRelativeTolerance(CONVERGENCE);
        optimizer.setOrthoTolerance(CONVERGENCE);
       
        // Function optimization
        VectorialPointValuePair optimum;
       
        optimum = optimizer.optimize(function, targets, weights, FIRST_GUESS);
       
        // Covariances and errors
        logger.debug("Fit: Calculate errors and covariances.");
        double[]   fitErrors     = optimizer.guessParametersErrors();
        double[][] fitCovariance = optimizer.getCovariances();
       
        // Calculate chi square
        double[] bestFit = optimum.getValue();
        double chi2 = 0.0;
        for ( int i = 0; i < targets.length; i++ ) {
View Full Code Here

    nTransits = function.getNTransits();

    System.out.printf("Number of effective transits: %4d\n", nTransits);
     
    // Optimizer set-up
    LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
    optimizer.setMaxIterations(         MAX_ITERATIONS );
    optimizer.setCostRelativeTolerance( CONVERGENCE    );
    optimizer.setParRelativeToleranceCONVERGENCE    );
    optimizer.setOrthoTolerance(        CONVERGENCE    );
   
    // BamFunction optimization
    VectorialPointValuePair optimum = optimizer.optimize(function, target, weight, FIRST_GUESS);
   
    // Covariances and errors
    double[]   fitErrors     = optimizer.guessParametersErrors();
    double[][] fitCovariance = optimizer.getCovariances();
   
    // Output values
    FitResults fitResults = new FitResults(
        optimum.getValue(), optimum.getPoint(), fitErrors, fitCovariance);
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.