Class LsqFit

java.lang.Object
gov.nih.mipav.model.algorithms.LsqFit

public abstract class LsqFit extends 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 Details

    • 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
    • DRAPER24D

      private final int DRAPER24D
      See Also:
    • ROSENBROCK

      private final int ROSENBROCK
      See Also:
    • FREUDENSTEIN_AND_ROTH

      private final int FREUDENSTEIN_AND_ROTH
      See Also:
    • POWELL_BADLY_SCALED

      private final int POWELL_BADLY_SCALED
      See Also:
    • BROWN_BADLY_SCALED

      private final int BROWN_BADLY_SCALED
      See Also:
    • BEALE

      private final int BEALE
      See Also:
    • JENNRICH_AND_SAMPSON

      private final int JENNRICH_AND_SAMPSON
      See Also:
    • HELICAL_VALLEY

      private final int HELICAL_VALLEY
      See Also:
    • BARD

      private final int BARD
      See Also:
    • GAUSSIAN

      private final int GAUSSIAN
      See Also:
    • MEYER

      private final int MEYER
      See Also:
    • GULF_RESEARCH_AND_DEVELOPMENT

      private final int GULF_RESEARCH_AND_DEVELOPMENT
      See Also:
    • BOX_3D

      private final int BOX_3D
      See Also:
    • POWELL_SINGULAR

      private final int POWELL_SINGULAR
      See Also:
    • WOOD

      private final int WOOD
      See Also:
    • KOWALIK_AND_OSBORNE

      private final int KOWALIK_AND_OSBORNE
      See Also:
    • BROWN_AND_DENNIS

      private final int BROWN_AND_DENNIS
      See Also:
    • OSBORNE1

      private final int OSBORNE1
      See Also:
    • BIGGS_EXP6

      private final int BIGGS_EXP6
      See Also:
    • OSBORNE2

      private final int OSBORNE2
      See Also:
    • WATSON

      private final int WATSON
      See Also:
    • EXTENDED_ROSENBROCK

      private final int EXTENDED_ROSENBROCK
      See Also:
    • EXTENDED_POWELL_SINGULAR

      private final int EXTENDED_POWELL_SINGULAR
      See Also:
    • PENALTY_FUNCTION_I

      private final int PENALTY_FUNCTION_I
      See Also:
    • PENALTY_FUNCTION_II

      private final int PENALTY_FUNCTION_II
      See Also:
    • VARIABLY_DIMENSIONED_FUNCTION

      private final int VARIABLY_DIMENSIONED_FUNCTION
      See Also:
    • TRIGONOMETRIC

      private final int TRIGONOMETRIC
      See Also:
    • BROWN_ALMOST_LINEAR

      private final int BROWN_ALMOST_LINEAR
      See Also:
    • DISCRETE_BOUNDARY_VALUE

      private final int DISCRETE_BOUNDARY_VALUE
      See Also:
    • DISCRETE_INTEGRAL

      private final int DISCRETE_INTEGRAL
      See Also:
    • BROYDEN_TRIDIAGONAL

      private final int BROYDEN_TRIDIAGONAL
      See Also:
    • BROYDEN_BANDED

      private final int BROYDEN_BANDED
      See Also:
    • LINEAR_FULL_RANK

      private final int LINEAR_FULL_RANK
      See Also:
    • LINEAR_RANK1

      private final int LINEAR_RANK1
      See Also:
    • LINEAR_RANK1_WITH_ZERO_COLUMNS_AND_ROWS

      private final int LINEAR_RANK1_WITH_ZERO_COLUMNS_AND_ROWS
      See Also:
    • CHEBYQUAD

      private final int CHEBYQUAD
      See Also:
    • HOCK25

      private final int HOCK25
      See Also:
    • LEVMAR_ROSENBROCK

      private final int LEVMAR_ROSENBROCK
      See Also:
    • MODIFIED_ROSENBROCK

      private final int MODIFIED_ROSENBROCK
      See Also:
    • POWELL_2_PARAMETER

      private final int POWELL_2_PARAMETER
      See Also:
    • HOCK1

      private final int HOCK1
      See Also:
    • HOCK21_MODIFIED

      private final int HOCK21_MODIFIED
      See Also:
    • HATFLDB

      private final int HATFLDB
      See Also:
    • HATFLDC

      private final int HATFLDC
      See Also:
    • EQUILIBRIUM_COMBUSTION

      private final int EQUILIBRIUM_COMBUSTION
      See Also:
    • MADSEN

      private final int MADSEN
      See Also:
    • HOCK3

      private final int HOCK3
      See Also:
    • HOCK4

      private final int HOCK4
      See Also:
  • Constructor Details

    • 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 Details

    • 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()