Class LsqFit


  • public abstract class LsqFit
    extends java.lang.Object
    LsqFit.jl is licensed under the MIT License: Returns the argmin over x of `sum(f(x).^2)` using the Levenberg-Marquardt algorithm, and an estimate of the Jacobian of `f` at x. > Copyright (c) 2012: John Myles White and other contributors. > > Permission is hereby granted, free of charge, to any person obtaining > a copy of this software and associated documentation files (the > "Software"), to deal in the Software without restriction, including > without limitation the rights to use, copy, modify, merge, publish, > distribute, sublicense, and/or sell copies of the Software, and to > permit persons to whom the Software is furnished to do so, subject to > the following conditions: > > The above copyright notice and this permission notice shall be > included in all copies or substantial portions of the Software. > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND > NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE > LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION > OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION > WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    • Field Detail

      • testMode

        private boolean testMode
        module LsqFit export curve_fit, standard_error, margin_error, confidence_interval, estimate_covar, make_hessian, Avv, # StatsBase reexports dof, coef, nobs, mse, rss, stderror, weights, residuals using Distributions using OptimBase using LinearAlgebra using ForwardDiff import NLSolversBase: value, jacobian import StatsBase import StatsBase: coef, dof, nobs, rss, stderror, weights, residuals import Base.summary include("geodesic.jl") include("levenberg_marquardt.jl") include("curve_fit.jl") end
      • useNumerical

        protected boolean useNumerical
      • x_tol

        protected double x_tol
      • g_tol

        protected double g_tol
      • maxIter

        protected int maxIter
      • min_step_quality

        protected double min_step_quality
      • good_step_quality

        protected double good_step_quality
      • initial_lambda

        protected double initial_lambda
      • tau

        protected double tau
      • lambda_increase

        protected double lambda_increase
      • lambda_decrease

        protected double lambda_decrease
      • show_trace

        protected boolean show_trace
      • lower

        protected double[] lower
      • upper

        protected double[] upper
      • geodesicAcceleration

        protected boolean geodesicAcceleration
      • epsilon

        double epsilon
      • default_relstep

        double default_relstep
      • m

        protected int m
        integer scalar containing the number of data points.
      • n

        protected int n
        variables integer scalar containing the number of unknowns.
      • initial_x

        protected double[] initial_x
      • iterCt

        private int iterCt
      • x

        private double[] x
      • residuals

        private double[] residuals
      • J

        private double[][] J
      • converged

        private boolean converged
      • tdata

        private double[] tdata
      • ydata

        private double[] ydata
      • sqrtem5

        private double sqrtem5
      • p1sqrtem5

        private double p1sqrtem5
      • sqrt5

        private double sqrt5
      • sqrt10

        private double sqrt10
      • expap1

        private double[] expap1
      • exp0p1

        private double exp0p1
      • testCase

        private int testCase
      • GULF_RESEARCH_AND_DEVELOPMENT

        private final int GULF_RESEARCH_AND_DEVELOPMENT
        See Also:
        Constant Field Values
      • VARIABLY_DIMENSIONED_FUNCTION

        private final int VARIABLY_DIMENSIONED_FUNCTION
        See Also:
        Constant Field Values
      • LINEAR_RANK1_WITH_ZERO_COLUMNS_AND_ROWS

        private final int LINEAR_RANK1_WITH_ZERO_COLUMNS_AND_ROWS
        See Also:
        Constant Field Values
    • Constructor Detail

      • LsqFit

        public LsqFit​(int nPts,
                      double[] initial_x)
      • LsqFit

        public LsqFit()
        To run LsqFit() use: boolean fullTest = true; if (fullTest) { FitAll fa = new FitAll(); return; } class FitAll extends LsqFit { public FitAll() { // nPoints data points, 3 coefficients, and exponential fitting super(); } public void fitToFunction(double[] x, double[] residuals) { return; } public void fitToJacobian(double[] x, double[][] jacobian) { return; } public void fitToHessian(double[] x, double[][][] hessian) { // n,n,m hessian return; } }
    • Method Detail

      • dumpTestResults

        private void dumpTestResults()
      • fitToTestFunction

        public void fitToTestFunction​(double[] x,
                                      double[] residuals)
      • fitToTestJacobian

        private void fitToTestJacobian​(double[] x,
                                       double[][] J)
      • fitToTestHessian

        private void fitToTestHessian​(double[] x,
                                      double[][][] hessian)
      • shiftedChebyshev

        private double shiftedChebyshev​(double x,
                                        int n)
      • shiftedChebyshevDerivative

        private double shiftedChebyshevDerivative​(double x,
                                                  int n)
      • fitToNumericalJacobian

        private void fitToNumericalJacobian​(double[] xinit,
                                            double[][] jacobian)
      • fitToNumericalHessian

        private void fitToNumericalHessian​(double[] xinit,
                                           double[][][] hessian)
      • fitToFunction

        public abstract void fitToFunction​(double[] x,
                                           double[] residuals)
        fitToFunction communicates
        Parameters:
        x - DOCUMENT ME!
        residuals - DOCUMENT ME!
      • fitToJacobian

        public abstract void fitToJacobian​(double[] x,
                                           double[][] jacobian)
        fitToJacobian communicates
        Parameters:
        x - DOCUMENT ME!
        Jacobian - DOCUMENT ME!
      • fitToHessian

        public abstract void fitToHessian​(double[] x,
                                          double[][][] hessian)
      • driver

        private void driver()
      • getIterations

        public int getIterations()
      • getParameters

        public double[] getParameters()
        getParameters accessor to function parameters.
        Returns:
        the function parameters determined by the algorithm
      • getResiduals

        public double[] getResiduals()
        DOCUMENT ME!
        Returns:
        double[] residuals
      • getConverged

        public boolean getConverged()
      • getCovariance

        public double[][] getCovariance()