Package gov.nih.mipav.model.algorithms
Class LsqFit
- java.lang.Object
-
- gov.nih.mipav.model.algorithms.LsqFit
-
public abstract class LsqFit extends java.lang.ObjectLsqFit.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 Summary
Fields Modifier and Type Field Description private intBARDprivate intBEALEprivate intBIGGS_EXP6private intBOX_3Dprivate intBROWN_ALMOST_LINEARprivate intBROWN_AND_DENNISprivate intBROWN_BADLY_SCALEDprivate intBROYDEN_BANDEDprivate intBROYDEN_TRIDIAGONALprivate intCHEBYQUADprivate booleanconverged(package private) doubledefault_relstepprivate intDISCRETE_BOUNDARY_VALUEprivate intDISCRETE_INTEGRALprivate intDRAPER24D(package private) doubleepsilonprivate intEQUILIBRIUM_COMBUSTIONprivate doubleexp0p1private double[]expap1private intEXTENDED_POWELL_SINGULARprivate intEXTENDED_ROSENBROCKprivate intFREUDENSTEIN_AND_ROTHprotected doubleg_tolprivate intGAUSSIANprotected booleangeodesicAccelerationprotected doublegood_step_qualityprivate intGULF_RESEARCH_AND_DEVELOPMENTprivate intHATFLDBprivate intHATFLDCprivate intHELICAL_VALLEYprivate intHOCK1private intHOCK21_MODIFIEDprivate intHOCK25private intHOCK3private intHOCK4protected doubleinitial_lambdaprotected double[]initial_xprivate intiterCtprivate double[][]Jprivate intJENNRICH_AND_SAMPSONprivate intKOWALIK_AND_OSBORNEprotected doublelambda_decreaseprotected doublelambda_increaseprivate intLEVMAR_ROSENBROCKprivate intLINEAR_FULL_RANKprivate intLINEAR_RANK1private intLINEAR_RANK1_WITH_ZERO_COLUMNS_AND_ROWSprotected double[]lowerprotected intminteger scalar containing the number of data points.private intMADSENprotected intmaxIterprivate intMEYERprotected doublemin_step_qualityprivate intMODIFIED_ROSENBROCKprotected intnvariables integer scalar containing the number of unknowns.private intOSBORNE1private intOSBORNE2private doublep1sqrtem5private intPENALTY_FUNCTION_Iprivate intPENALTY_FUNCTION_IIprivate intPOWELL_2_PARAMETERprivate intPOWELL_BADLY_SCALEDprivate intPOWELL_SINGULARprivate double[]residualsprivate intROSENBROCKprotected booleanshow_traceprivate doublesqrt10private doublesqrt5private doublesqrtem5protected doubletauprivate double[]tdataprivate inttestCaseprivate booleantestModemodule 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") endprivate intTRIGONOMETRICprotected double[]upperprotected booleanuseNumericalprivate intVARIABLY_DIMENSIONED_FUNCTIONprivate intWATSONprivate intWOODprivate double[]xprotected doublex_tolprivate double[]ydata
-
Constructor Summary
Constructors Constructor Description 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; } }LsqFit(int nPts, double[] initial_x)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private voiddriver()private voiddumpTestResults()abstract voidfitToFunction(double[] x, double[] residuals)fitToFunction communicatesabstract voidfitToHessian(double[] x, double[][][] hessian)abstract voidfitToJacobian(double[] x, double[][] jacobian)fitToJacobian communicatesprivate voidfitToNumericalHessian(double[] xinit, double[][][] hessian)private voidfitToNumericalJacobian(double[] xinit, double[][] jacobian)voidfitToTestFunction(double[] x, double[] residuals)private voidfitToTestHessian(double[] x, double[][][] hessian)private voidfitToTestJacobian(double[] x, double[][] J)booleangetConverged()double[][]getCovariance()intgetIterations()double[]getParameters()getParameters accessor to function parameters.double[]getResiduals()DOCUMENT ME!private doubleshiftedChebyshev(double x, int n)private doubleshiftedChebyshevDerivative(double x, int n)
-
-
-
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
-
DRAPER24D
private final int DRAPER24D
- See Also:
- Constant Field Values
-
ROSENBROCK
private final int ROSENBROCK
- See Also:
- Constant Field Values
-
FREUDENSTEIN_AND_ROTH
private final int FREUDENSTEIN_AND_ROTH
- See Also:
- Constant Field Values
-
POWELL_BADLY_SCALED
private final int POWELL_BADLY_SCALED
- See Also:
- Constant Field Values
-
BROWN_BADLY_SCALED
private final int BROWN_BADLY_SCALED
- See Also:
- Constant Field Values
-
BEALE
private final int BEALE
- See Also:
- Constant Field Values
-
JENNRICH_AND_SAMPSON
private final int JENNRICH_AND_SAMPSON
- See Also:
- Constant Field Values
-
HELICAL_VALLEY
private final int HELICAL_VALLEY
- See Also:
- Constant Field Values
-
BARD
private final int BARD
- See Also:
- Constant Field Values
-
GAUSSIAN
private final int GAUSSIAN
- See Also:
- Constant Field Values
-
MEYER
private final int MEYER
- See Also:
- Constant Field Values
-
GULF_RESEARCH_AND_DEVELOPMENT
private final int GULF_RESEARCH_AND_DEVELOPMENT
- See Also:
- Constant Field Values
-
BOX_3D
private final int BOX_3D
- See Also:
- Constant Field Values
-
POWELL_SINGULAR
private final int POWELL_SINGULAR
- See Also:
- Constant Field Values
-
WOOD
private final int WOOD
- See Also:
- Constant Field Values
-
KOWALIK_AND_OSBORNE
private final int KOWALIK_AND_OSBORNE
- See Also:
- Constant Field Values
-
BROWN_AND_DENNIS
private final int BROWN_AND_DENNIS
- See Also:
- Constant Field Values
-
OSBORNE1
private final int OSBORNE1
- See Also:
- Constant Field Values
-
BIGGS_EXP6
private final int BIGGS_EXP6
- See Also:
- Constant Field Values
-
OSBORNE2
private final int OSBORNE2
- See Also:
- Constant Field Values
-
WATSON
private final int WATSON
- See Also:
- Constant Field Values
-
EXTENDED_ROSENBROCK
private final int EXTENDED_ROSENBROCK
- See Also:
- Constant Field Values
-
EXTENDED_POWELL_SINGULAR
private final int EXTENDED_POWELL_SINGULAR
- See Also:
- Constant Field Values
-
PENALTY_FUNCTION_I
private final int PENALTY_FUNCTION_I
- See Also:
- Constant Field Values
-
PENALTY_FUNCTION_II
private final int PENALTY_FUNCTION_II
- See Also:
- Constant Field Values
-
VARIABLY_DIMENSIONED_FUNCTION
private final int VARIABLY_DIMENSIONED_FUNCTION
- See Also:
- Constant Field Values
-
TRIGONOMETRIC
private final int TRIGONOMETRIC
- See Also:
- Constant Field Values
-
BROWN_ALMOST_LINEAR
private final int BROWN_ALMOST_LINEAR
- See Also:
- Constant Field Values
-
DISCRETE_BOUNDARY_VALUE
private final int DISCRETE_BOUNDARY_VALUE
- See Also:
- Constant Field Values
-
DISCRETE_INTEGRAL
private final int DISCRETE_INTEGRAL
- See Also:
- Constant Field Values
-
BROYDEN_TRIDIAGONAL
private final int BROYDEN_TRIDIAGONAL
- See Also:
- Constant Field Values
-
BROYDEN_BANDED
private final int BROYDEN_BANDED
- See Also:
- Constant Field Values
-
LINEAR_FULL_RANK
private final int LINEAR_FULL_RANK
- See Also:
- Constant Field Values
-
LINEAR_RANK1
private final int LINEAR_RANK1
- 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
-
CHEBYQUAD
private final int CHEBYQUAD
- See Also:
- Constant Field Values
-
HOCK25
private final int HOCK25
- See Also:
- Constant Field Values
-
LEVMAR_ROSENBROCK
private final int LEVMAR_ROSENBROCK
- See Also:
- Constant Field Values
-
MODIFIED_ROSENBROCK
private final int MODIFIED_ROSENBROCK
- See Also:
- Constant Field Values
-
POWELL_2_PARAMETER
private final int POWELL_2_PARAMETER
- See Also:
- Constant Field Values
-
HOCK1
private final int HOCK1
- See Also:
- Constant Field Values
-
HOCK21_MODIFIED
private final int HOCK21_MODIFIED
- See Also:
- Constant Field Values
-
HATFLDB
private final int HATFLDB
- See Also:
- Constant Field Values
-
HATFLDC
private final int HATFLDC
- See Also:
- Constant Field Values
-
EQUILIBRIUM_COMBUSTION
private final int EQUILIBRIUM_COMBUSTION
- See Also:
- Constant Field Values
-
MADSEN
private final int MADSEN
- See Also:
- Constant Field Values
-
HOCK3
private final int HOCK3
- See Also:
- Constant Field Values
-
HOCK4
private final int HOCK4
- 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()
-
-