Package gov.nih.mipav.model.algorithms
Class LsqFit
- java.lang.Object
-
- gov.nih.mipav.model.algorithms.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 Summary
Fields Modifier and Type Field Description private int
BARD
private int
BEALE
private int
BIGGS_EXP6
private int
BOX_3D
private int
BROWN_ALMOST_LINEAR
private int
BROWN_AND_DENNIS
private int
BROWN_BADLY_SCALED
private int
BROYDEN_BANDED
private int
BROYDEN_TRIDIAGONAL
private int
CHEBYQUAD
private boolean
converged
(package private) double
default_relstep
private int
DISCRETE_BOUNDARY_VALUE
private int
DISCRETE_INTEGRAL
private int
DRAPER24D
(package private) double
epsilon
private int
EQUILIBRIUM_COMBUSTION
private double
exp0p1
private double[]
expap1
private int
EXTENDED_POWELL_SINGULAR
private int
EXTENDED_ROSENBROCK
private int
FREUDENSTEIN_AND_ROTH
protected double
g_tol
private int
GAUSSIAN
protected boolean
geodesicAcceleration
protected double
good_step_quality
private int
GULF_RESEARCH_AND_DEVELOPMENT
private int
HATFLDB
private int
HATFLDC
private int
HELICAL_VALLEY
private int
HOCK1
private int
HOCK21_MODIFIED
private int
HOCK25
private int
HOCK3
private int
HOCK4
protected double
initial_lambda
protected double[]
initial_x
private int
iterCt
private double[][]
J
private int
JENNRICH_AND_SAMPSON
private int
KOWALIK_AND_OSBORNE
protected double
lambda_decrease
protected double
lambda_increase
private int
LEVMAR_ROSENBROCK
private int
LINEAR_FULL_RANK
private int
LINEAR_RANK1
private int
LINEAR_RANK1_WITH_ZERO_COLUMNS_AND_ROWS
protected double[]
lower
protected int
m
integer scalar containing the number of data points.private int
MADSEN
protected int
maxIter
private int
MEYER
protected double
min_step_quality
private int
MODIFIED_ROSENBROCK
protected int
n
variables integer scalar containing the number of unknowns.private int
OSBORNE1
private int
OSBORNE2
private double
p1sqrtem5
private int
PENALTY_FUNCTION_I
private int
PENALTY_FUNCTION_II
private int
POWELL_2_PARAMETER
private int
POWELL_BADLY_SCALED
private int
POWELL_SINGULAR
private double[]
residuals
private int
ROSENBROCK
protected boolean
show_trace
private double
sqrt10
private double
sqrt5
private double
sqrtem5
protected double
tau
private double[]
tdata
private int
testCase
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") endprivate int
TRIGONOMETRIC
protected double[]
upper
protected boolean
useNumerical
private int
VARIABLY_DIMENSIONED_FUNCTION
private int
WATSON
private int
WOOD
private double[]
x
protected double
x_tol
private 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 void
driver()
private void
dumpTestResults()
abstract void
fitToFunction(double[] x, double[] residuals)
fitToFunction communicatesabstract void
fitToHessian(double[] x, double[][][] hessian)
abstract void
fitToJacobian(double[] x, double[][] jacobian)
fitToJacobian communicatesprivate void
fitToNumericalHessian(double[] xinit, double[][][] hessian)
private void
fitToNumericalJacobian(double[] xinit, double[][] jacobian)
void
fitToTestFunction(double[] x, double[] residuals)
private void
fitToTestHessian(double[] x, double[][][] hessian)
private void
fitToTestJacobian(double[] x, double[][] J)
boolean
getConverged()
double[][]
getCovariance()
int
getIterations()
double[]
getParameters()
getParameters accessor to function parameters.double[]
getResiduals()
DOCUMENT ME!private double
shiftedChebyshev(double x, int n)
private double
shiftedChebyshevDerivative(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()
-
-