Package de.gsi.math.fitter
Class NonLinearRegressionFitter
- java.lang.Object
-
- de.gsi.math.fitter.NonLinearRegressionFitter
-
public class NonLinearRegressionFitter extends java.lang.Object
Non-linear regression class Nelder & Mead simplex algorithm being the primary back-bone of this implementation initial implementation based on the package provided by: Michael Thomas Flanagan at www.ee.ucl.ac.uk/~mflanaga The code has been cleaned up and adapted to further support multi-dimensional fits- Author:
- rstein
-
-
Field Summary
Fields Modifier and Type Field Description protected double
adjustedF
protected double
adjustedR
protected double
adjustedR2
protected double[]
best
protected double[]
bestSd
protected double
cCoeff
protected double
chiSquare
protected int
constraintMethod
protected double[]
constraints
protected double
constraintTolerance
protected double[][]
corrCoeff
protected double[][]
covar
protected int
degreesOfFreedom
protected double
delta
protected double
dStep
protected double
eCoeff
protected boolean[]
fixed
protected double
fMin
protected double[]
fscale
protected double
fTol
protected double[][]
grad
protected static double
histTol
protected boolean
ignoreDofFcheck
protected boolean
invertFlag
protected int
konvge
protected int
kRestart
protected double
lastSSnoConstraint
protected boolean
linNonLin
protected int
maxConstraintIndex
protected int
minTest
protected double
multipleF
protected boolean
multipleY
protected int
nConstraints
protected int
nData
protected int
nData0
protected boolean
nFactorOption
protected int
nIter
protected boolean
nlrStatus
protected int
nMax
protected int
nSumConstraints
protected int
nTerms
protected int
nXarrays
protected int
nYarrays
protected java.util.ArrayList<java.lang.Object>
penalties
protected boolean
penalty
protected int[]
penaltyCheck
protected int[]
penaltyParam
protected double
penaltyWeight
protected boolean
posVarFlag
protected double[]
pseudoSd
protected double[]
pValues
protected double
rCoeff
protected double
reducedChiSquare
protected double[]
residual
protected double[]
residualW
protected double
sampleR
protected double
sampleR2
protected int
scaleOpt
protected double
simplexSd
protected double[]
startH
protected boolean
statFlag
protected double[]
step
protected double[]
sumConstraints
protected double
sumOfSquares
protected java.util.ArrayList<java.lang.Object>
sumPenalties
protected boolean
sumPenalty
protected int[]
sumPenaltyCheck
protected int[]
sumPenaltyNumber
protected int[][]
sumPenaltyParam
protected double[][]
sumPlusOrMinus
protected boolean
trueFreq
protected double[]
tValues
protected double[]
values
protected double[]
weight
protected int
weightFlag
protected boolean
weightOpt
protected double[][]
xData
protected double[]
yCalc
protected double[]
yData
protected boolean
zeroCheck
-
Constructor Summary
Constructors Constructor Description NonLinearRegressionFitter(double[][] xData, double[] yData)
Constructor with data with x as 2D array and no weights providedNonLinearRegressionFitter(double[][] xxData, double[][] yyData)
Constructor with data with x and y as 2D arrays and no weights providedNonLinearRegressionFitter(double[][] xxData, double[][] yyData, double[][] wWeight)
Constructor with data with x and y as 2D arrays and weights providedNonLinearRegressionFitter(double[][] xData, double[] yData, double[] weight)
Constructor with data with x as 2D array and weights providedNonLinearRegressionFitter(double[] xxData, double[] yData)
Constructor with data with x as 1D array and no weights providedNonLinearRegressionFitter(double[] xxData, double[][] yyData)
Constructor with data with x as 1D array and y as a 2D array and no weights providedNonLinearRegressionFitter(double[] xxData, double[][] yyData, double[][] wWeight)
Constructor with data with x as 1D array and y as 2D array and weights providedNonLinearRegressionFitter(double[] xxData, double[] yData, double[] weight)
Constructor with data with x as 1D array and weights provided
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addConstraint(int[] paramIndices, double[] plusOrMinus, int conDir, double constraint)
add a multiple parameter constraint boundary for the non-linear regressionvoid
addConstraint(int[] paramIndices, int[] plusOrMinus, int conDir, double constraint)
add a multiple parameter constraint boundary for the non-linear regressionvoid
addConstraint(int paramIndex, int conDir, double constraint)
add a single parameter constraint boundary for the non-linear regressionprotected double[]
checkForZeroWeights(double[] weight)
Check entered weights for zeros.double
checkYallSmall(double yPeak, java.lang.String ss)
check y values for all y are very small valuevoid
checkZeroNeg(double[] xx, double[] yy, double[] ww)
check for zero and negative valuesprotected static java.util.ArrayList<java.lang.Object>
dataSign(double[] data)
Deprecated.replace with optimised routinesvoid
enterData(double[][] xData, double[] yData)
Enter data with x as 2D array and no weights providedvoid
enterData(double[][] xxData, double[][] yyData)
Enter data with x and y as 2D arrays and no weights providedvoid
enterData(double[][] xxData, double[][] yyData, double[][] wWeight)
data entry, all 2D arraysvoid
enterData(double[][] xData, double[] yData, double[] weight)
Enter data methodsvoid
enterData(double[] xxData, double[] yData)
Enter data with x as 1D array and no weights providedvoid
enterData(double[] xxData, double[][] yyData)
Enter data with x as 1D array and y as a 2D array and no weights providedvoid
enterData(double[] xxData, double[][] yyData, double[][] wWeight)
Enter datavoid
enterData(double[] xxData, double[] yData, double[] weight)
Enter data as 1D arraysprotected void
generalLinearStats(double[][] xd)
Generalised linear regression statistics (protected method called by linear(), linearGeneral() and polynomial())double
getAdjustedR()
Get the Adjusted Sample Correlation Coefficientdouble
getAdjustedR2()
Get the Adjusted Sample Correlation Coefficient Squareddouble[]
getBestEstimates()
Get the best estimates of the unknown parametersdouble[]
getBestEstimatesErrors()
Get the estimates of the errors of the best estimates of the unknown parametersdouble[]
getBestEstimatesStandardDeviations()
Get the estimates of the standard deviations of the best estimates of the unknown parametersdouble
getChiSquare()
Get the chi square estimatedouble
getchiSquareProb()
Get the chi square probablitydouble[]
getCoeff()
Get the best estimates of the unknown parametersdouble[]
getCoeffSd()
Get the estimates of the errors of the best estimates of the unknown parametersdouble[]
getCoeffVar()
Get the cofficients of variations of the best estimates of the unknown parametersdouble[][]
getCorrCoeffMatrix()
Get the correlation coefficient matrixdouble[][]
getCovMatrix()
Get the covariance matrixdouble
getDegFree()
Get the degrees of freedomdouble
getDelta()
Get the non-linear regression fractional step size used in numerical differencingdouble[][]
getGrad()
Get the non-linear regression pre and post minimum gradientsboolean
getInversionCheck()
Get the non-linear regression statistics Hessian matrix inversion status flagint
getMinTest()
Get the non-linear regression convergence test optiondouble
getMultipleF()
Get the Multiple Correlation Coefficient F ratioint
getNiter()
Get the number of iterations in nonlinear regressionboolean
getNlrStatus()
Get the non-linear regression status true if convergence was achieved false if convergence not achieved before maximum number of iterations current values then returnedint
getNmax()
Get the maximum number of iterations allowed in nonlinear regressiondouble
getNMcontract()
Get the Nelder and Mead contraction coefficient [gamma]double
getNMextend()
Get the Nelder and Mead extension coefficient [beta]double
getNMreflect()
Get the Nelder and Mead reflection coefficient [alpha]int
getNrestarts()
Get the number of restarts in nonlinear regressionint
getNrestartsMax()
Get the maximum number of restarts allowed in nonlinear regressionboolean
getPosVarCheck()
Get the non-linear regression statistics Hessian matrix inverse diagonal status flagdouble[]
getPseudoErrors()
Get the pseudo-estimates of the errors of the best estimates of the unknown parametersdouble[]
getPseudoSd()
Get the pseudo-estimates of the errors of the best estimates of the unknown parametersdouble[]
getPvalues()
Get the p-values of the best estimatesdouble
getReducedChiSquare()
Get the reduced chi square estimatedouble[]
getResiduals()
Get the unweighed residuals, y(experimental) - y(calculated)double
getSampleR()
Get the Sample Correlation Coefficientdouble
getSampleR2()
Get the Sample Correlation Coefficient Squareddouble[]
getScale()
double
getSimplexSd()
Get the simplex sd at the minimumdouble
getSumOfSquares()
Get the unweighed sum of squares of the residualsdouble
getTolerance()
Get the non-linear regression toleranceboolean
getTrueFreq()
Get the true frequency test, trueFreqdouble[]
getTvalues()
Get the t-values of the best estimatesdouble[]
getWeightedResiduals()
Get the weighted residuals, (y(experimental) - y(calculated))/weightdouble[][]
getXdata()
Get the input x valuesdouble[]
getYcalc()
Get the calculated y valuesdouble[]
getYdata()
Get the input y valuesprotected static double
halfWidth(double[] xData, double[] yData)
returns estimate of half-height widthvoid
ignoreDofFcheck()
Ignore check on whether degrees of freedom are greater than zeroboolean
infinityCheck(double yPeak, int peaki)
Check for y value = infinityprotected void
multCorrelCoeff(double[] yy, double[] yyCalc, double[] ww)
Calculate the multiple correlation coefficientprotected void
nelderMead(java.lang.Object regFun, double[] start, double[] step, double fTol, int nMax)
Nelder and Mead Simplex Simplex Non-linear Regressionprotected int
pseudoLinearStats(java.lang.Object regFun)
apply linear statistics to a non-linear regressionvoid
removeConstraints()
remove all constraint boundaries for the non-linear regressionvoid
setConstraintTolerance(double tolerance)
Reset the tolerance used in a fixed value constraintprotected void
setDefaultValues(double[][] xData, double[] yData, double[] weight)
Set data and default valuesvoid
setDelta(double delta)
Set the non-linear regression fractional step size used in numerical differencingvoid
setMinTest(int n)
Reset the non-linear regression convergence test optionvoid
setNmax(int nmax)
Set the maximum number of iterations allowed in nonlinear regressionvoid
setNMcontract(double con)
Reset the Nelder and Mead contraction coefficient [gamma]void
setNMextend(double ext)
Reset the Nelder and Mead extension coefficient [beta]void
setNMreflect(double refl)
Reset the Nelder and Mead reflection coefficient [alpha]void
setNrestartsMax(int nrs)
void
setScale(double[] sc)
Reset scaling factors (scaleOpt 2, see above for scaleOpt 0 and 1)void
setScale(int n)
Reset scaling factors (scaleOpt 0 and 1, see below for scaleOpt 2)void
setTolerance(double tol)
Set the non-linear regression tolerancevoid
setTrueFreq(boolean trFr)
Reset the true frequency test, trueFreq true if yData values are true frequencies, e.g.protected static boolean
setTrueFreqWeights(double[] yData, double[] weight)
void
simplex(Function1D g, double[] start)
Nelder and Mead simplex Default tolerance Default maximum iterations Default step option - all step[i] = dStepvoid
simplex(Function1D g, double[] start, double fTol)
Nelder and Mead simplex Default maximum iterations Default step option - all step[i] = dStepvoid
simplex(Function1D g, double[] start, double[] step)
Nelder and Mead simplexvoid
simplex(Function1D g, double[] start, double[] step, double fTol)
Nelder and Mead simplex Default maximum iterationsvoid
simplex(Function1D g, double[] start, double[] step, double fTol, int nMax)
Nelder and Mead Simplex Simplex Non-linear Regressionvoid
simplex(Function1D g, double[] start, double[] step, int nMax)
Nelder and Mead simplex Default tolerancevoid
simplex(Function1D g, double[] start, double fTol, int nMax)
Nelder and Mead simplex Default step option - all step[i] = dStepvoid
simplex(Function1D g, double[] start, int nMax)
Nelder and Mead simplex Default tolerance Default step option - all step[i] = dStepvoid
simplex2(FunctionND g, double[] start)
Deprecated.do not use yet in a production environment, needs some clean-upvoid
simplex2(FunctionND g, double[] start, double fTol)
Deprecated.do not use yet in a production environment, needs some clean-upvoid
simplex2(FunctionND g, double[] start, double[] step)
Deprecated.do not use yet in a production environment, needs some clean-upvoid
simplex2(FunctionND g, double[] start, double[] step, double fTol)
Deprecated.do not use yet in a production environment, needs some clean-upvoid
simplex2(FunctionND g, double[] start, double[] step, double fTol, int nMax)
Deprecated.do not use yet in a production environment, needs some clean-upvoid
simplex2(FunctionND g, double[] start, double[] step, int nMax)
Deprecated.do not use yet in a production environment, needs some clean-upvoid
simplex2(FunctionND g, double[] start, double fTol, int nMax)
Deprecated.do not use yet in a production environment, needs some clean-upvoid
simplex2(FunctionND g, double[] start, int nMax)
Deprecated.do not use yet in a production environment, needs some clean-upprotected static void
sort(double[] x, double[] y, double[] w)
sort elements x, y and w arrays of doubles into ascending order of the x array using selection sort methodprotected double
sumSquares(java.lang.Object regFun, double[] testParameter)
Calculate the sum of squares of the residuals for non-linear regression
-
-
-
Field Detail
-
histTol
protected static double histTol
-
nData0
protected int nData0
-
nData
protected int nData
-
nXarrays
protected int nXarrays
-
nYarrays
protected int nYarrays
-
nTerms
protected int nTerms
-
degreesOfFreedom
protected int degreesOfFreedom
-
xData
protected double[][] xData
-
yData
protected double[] yData
-
yCalc
protected double[] yCalc
-
weight
protected double[] weight
-
residual
protected double[] residual
-
residualW
protected double[] residualW
-
weightOpt
protected boolean weightOpt
-
weightFlag
protected int weightFlag
-
best
protected double[] best
-
bestSd
protected double[] bestSd
-
pseudoSd
protected double[] pseudoSd
-
tValues
protected double[] tValues
-
pValues
protected double[] pValues
-
chiSquare
protected double chiSquare
-
reducedChiSquare
protected double reducedChiSquare
-
sumOfSquares
protected double sumOfSquares
-
lastSSnoConstraint
protected double lastSSnoConstraint
-
covar
protected double[][] covar
-
corrCoeff
protected double[][] corrCoeff
-
sampleR
protected double sampleR
-
sampleR2
protected double sampleR2
-
adjustedR
protected double adjustedR
-
adjustedR2
protected double adjustedR2
-
multipleF
protected double multipleF
-
adjustedF
protected double adjustedF
-
linNonLin
protected boolean linNonLin
-
trueFreq
protected boolean trueFreq
-
nlrStatus
protected boolean nlrStatus
-
scaleOpt
protected int scaleOpt
-
fscale
protected double[] fscale
-
zeroCheck
protected boolean zeroCheck
-
penalty
protected boolean penalty
-
sumPenalty
protected boolean sumPenalty
-
nConstraints
protected int nConstraints
-
nSumConstraints
protected int nSumConstraints
-
maxConstraintIndex
protected int maxConstraintIndex
-
constraintTolerance
protected double constraintTolerance
-
penalties
protected java.util.ArrayList<java.lang.Object> penalties
-
sumPenalties
protected java.util.ArrayList<java.lang.Object> sumPenalties
-
penaltyCheck
protected int[] penaltyCheck
-
sumPenaltyCheck
protected int[] sumPenaltyCheck
-
penaltyWeight
protected double penaltyWeight
-
penaltyParam
protected int[] penaltyParam
-
sumPenaltyParam
protected int[][] sumPenaltyParam
-
sumPlusOrMinus
protected double[][] sumPlusOrMinus
-
sumPenaltyNumber
protected int[] sumPenaltyNumber
-
constraints
protected double[] constraints
-
sumConstraints
protected double[] sumConstraints
-
constraintMethod
protected int constraintMethod
-
nMax
protected int nMax
-
nIter
protected int nIter
-
konvge
protected int konvge
-
kRestart
protected int kRestart
-
fMin
protected double fMin
-
fTol
protected double fTol
-
rCoeff
protected double rCoeff
-
eCoeff
protected double eCoeff
-
cCoeff
protected double cCoeff
-
startH
protected double[] startH
-
step
protected double[] step
-
dStep
protected double dStep
-
grad
protected double[][] grad
-
delta
protected double delta
-
invertFlag
protected boolean invertFlag
-
posVarFlag
protected boolean posVarFlag
-
minTest
protected int minTest
-
simplexSd
protected double simplexSd
-
statFlag
protected boolean statFlag
-
multipleY
protected boolean multipleY
-
values
protected double[] values
-
fixed
protected boolean[] fixed
-
ignoreDofFcheck
protected boolean ignoreDofFcheck
-
nFactorOption
protected boolean nFactorOption
-
-
Constructor Detail
-
NonLinearRegressionFitter
public NonLinearRegressionFitter(double[] xxData, double[] yData)
Constructor with data with x as 1D array and no weights provided- Parameters:
xxData
- ???yData
- ???
-
NonLinearRegressionFitter
public NonLinearRegressionFitter(double[] xxData, double[] yData, double[] weight)
Constructor with data with x as 1D array and weights provided- Parameters:
xxData
- ???yData
- ???weight
- ???
-
NonLinearRegressionFitter
public NonLinearRegressionFitter(double[] xxData, double[][] yyData)
Constructor with data with x as 1D array and y as a 2D array and no weights provided- Parameters:
xxData
- ???yyData
- ???
-
NonLinearRegressionFitter
public NonLinearRegressionFitter(double[] xxData, double[][] yyData, double[][] wWeight)
Constructor with data with x as 1D array and y as 2D array and weights provided- Parameters:
xxData
- ???yyData
- ???wWeight
- ???
-
NonLinearRegressionFitter
public NonLinearRegressionFitter(double[][] xData, double[] yData)
Constructor with data with x as 2D array and no weights provided- Parameters:
xData
- ???yData
- ???
-
NonLinearRegressionFitter
public NonLinearRegressionFitter(double[][] xData, double[] yData, double[] weight)
Constructor with data with x as 2D array and weights provided- Parameters:
xData
- ???yData
- ???weight
- ???
-
NonLinearRegressionFitter
public NonLinearRegressionFitter(double[][] xxData, double[][] yyData)
Constructor with data with x and y as 2D arrays and no weights provided- Parameters:
xxData
- ???yyData
- ???
-
NonLinearRegressionFitter
public NonLinearRegressionFitter(double[][] xxData, double[][] yyData, double[][] wWeight)
Constructor with data with x and y as 2D arrays and weights provided- Parameters:
xxData
- ???yyData
- ???wWeight
- ???
-
-
Method Detail
-
addConstraint
public void addConstraint(int paramIndex, int conDir, double constraint)
add a single parameter constraint boundary for the non-linear regression- Parameters:
paramIndex
- parameter indexconDir
- ???constraint
- ???
-
addConstraint
public void addConstraint(int[] paramIndices, double[] plusOrMinus, int conDir, double constraint)
add a multiple parameter constraint boundary for the non-linear regression- Parameters:
paramIndices
- parameter indicesplusOrMinus
- positive/negative range constraintconDir
- direction of fit constraintconstraint
- ???
-
addConstraint
public void addConstraint(int[] paramIndices, int[] plusOrMinus, int conDir, double constraint)
add a multiple parameter constraint boundary for the non-linear regression- Parameters:
paramIndices
- parameter indicesplusOrMinus
- positive/negative range constraintconDir
- direction of fit constraintconstraint
- ???
-
checkForZeroWeights
protected double[] checkForZeroWeights(double[] weight)
Check entered weights for zeros. If more than 40% are zero or less than zero, all weights replaced by unity If less than 40% are zero or less than zero, the zero or negative weights are replaced by the average of their nearest neighbours- Parameters:
weight
- weight vector- Returns:
- conditioned vector
-
checkYallSmall
public double checkYallSmall(double yPeak, java.lang.String ss)
check y values for all y are very small value- Parameters:
yPeak
- ???ss
- ???- Returns:
- true: if a very small value has been removed
-
checkZeroNeg
public void checkZeroNeg(double[] xx, double[] yy, double[] ww)
check for zero and negative values- Parameters:
xx
- ???yy
- ???ww
- ???
-
enterData
public void enterData(double[] xxData, double[] yData)
Enter data with x as 1D array and no weights provided- Parameters:
xxData
- ???yData
- ???
-
enterData
public void enterData(double[] xxData, double[] yData, double[] weight)
Enter data as 1D arrays- Parameters:
xxData
- ???yData
- ???weight
- ???
-
enterData
public void enterData(double[] xxData, double[][] yyData)
Enter data with x as 1D array and y as a 2D array and no weights provided- Parameters:
xxData
- ???yyData
- ???
-
enterData
public void enterData(double[] xxData, double[][] yyData, double[][] wWeight)
Enter data- Parameters:
xxData
- 1D arrayyyData
- 2D arraywWeight
- ???
-
enterData
public void enterData(double[][] xData, double[] yData)
Enter data with x as 2D array and no weights provided- Parameters:
xData
- ???yData
- ???
-
enterData
public void enterData(double[][] xData, double[] yData, double[] weight)
Enter data methods- Parameters:
xData
- 2D arrayyData
- 1D arrayweight
- 1D array
-
enterData
public void enterData(double[][] xxData, double[][] yyData)
Enter data with x and y as 2D arrays and no weights provided- Parameters:
xxData
- ???yyData
- ???
-
enterData
public void enterData(double[][] xxData, double[][] yyData, double[][] wWeight)
data entry, all 2D arrays- Parameters:
xxData
- ???yyData
- ???wWeight
- ???
-
generalLinearStats
protected void generalLinearStats(double[][] xd)
Generalised linear regression statistics (protected method called by linear(), linearGeneral() and polynomial())- Parameters:
xd
- ???
-
getAdjustedR
public double getAdjustedR()
Get the Adjusted Sample Correlation Coefficient- Returns:
- Adjusted Sample Correlation Coefficient
-
getAdjustedR2
public double getAdjustedR2()
Get the Adjusted Sample Correlation Coefficient Squared- Returns:
- Adjusted Sample Correlation Coefficient Squared
-
getBestEstimates
public double[] getBestEstimates()
Get the best estimates of the unknown parameters- Returns:
- best estimates of the unknown parameters
-
getBestEstimatesErrors
public double[] getBestEstimatesErrors()
Get the estimates of the errors of the best estimates of the unknown parameters- Returns:
- estimates of the errors of the best estimates
-
getBestEstimatesStandardDeviations
public double[] getBestEstimatesStandardDeviations()
Get the estimates of the standard deviations of the best estimates of the unknown parameters- Returns:
- estimates of the standard deviations
-
getChiSquare
public double getChiSquare()
Get the chi square estimate- Returns:
- chi square estimate
-
getchiSquareProb
public double getchiSquareProb()
Get the chi square probablity- Returns:
- chi square probablity
-
getCoeff
public double[] getCoeff()
Get the best estimates of the unknown parameters- Returns:
- estimates of the unknown parameters
-
getCoeffSd
public double[] getCoeffSd()
Get the estimates of the errors of the best estimates of the unknown parameters- Returns:
- estimates of the errors of the best estimates
-
getCoeffVar
public double[] getCoeffVar()
Get the cofficients of variations of the best estimates of the unknown parameters- Returns:
- cofficients of variations of the best estimates
-
getCorrCoeffMatrix
public double[][] getCorrCoeffMatrix()
Get the correlation coefficient matrix- Returns:
- correlation coefficient matrix
-
getCovMatrix
public double[][] getCovMatrix()
Get the covariance matrix- Returns:
- covariance matrix
-
getDegFree
public double getDegFree()
Get the degrees of freedom- Returns:
- degrees of freedom
-
getDelta
public double getDelta()
Get the non-linear regression fractional step size used in numerical differencing- Returns:
- non-linear regression fractional step size used in numerical differencing
-
getGrad
public double[][] getGrad()
Get the non-linear regression pre and post minimum gradients- Returns:
- non-linear regression pre and post minimum gradients
-
getInversionCheck
public boolean getInversionCheck()
Get the non-linear regression statistics Hessian matrix inversion status flag- Returns:
- non-linear regression statistics Hessian matrix inversion status flag
-
getMinTest
public int getMinTest()
Get the non-linear regression convergence test option- Returns:
- non-linear regression convergence test option
-
getMultipleF
public double getMultipleF()
Get the Multiple Correlation Coefficient F ratio- Returns:
- Multiple Correlation Coefficient F ratio
-
getNiter
public int getNiter()
Get the number of iterations in nonlinear regression- Returns:
- number of iterations in nonlinear regression
-
getNlrStatus
public boolean getNlrStatus()
Get the non-linear regression status true if convergence was achieved false if convergence not achieved before maximum number of iterations current values then returned- Returns:
- the non-linear regression status
-
getNmax
public int getNmax()
Get the maximum number of iterations allowed in nonlinear regression- Returns:
- maximum number of iterations allowed in nonlinear regression
-
getNMcontract
public double getNMcontract()
Get the Nelder and Mead contraction coefficient [gamma]- Returns:
- Nelder and Mead contraction coefficient [gamma]
-
getNMextend
public double getNMextend()
Get the Nelder and Mead extension coefficient [beta]- Returns:
- Nelder and Mead extension coefficient [beta]
-
getNMreflect
public double getNMreflect()
Get the Nelder and Mead reflection coefficient [alpha]- Returns:
- Nelder and Mead reflection coefficient [alpha]
-
getNrestarts
public int getNrestarts()
Get the number of restarts in nonlinear regression- Returns:
- number of restarts in nonlinear regression
-
getNrestartsMax
public int getNrestartsMax()
Get the maximum number of restarts allowed in nonlinear regression- Returns:
- maximum number of restarts allowed in nonlinear regression
-
getPosVarCheck
public boolean getPosVarCheck()
Get the non-linear regression statistics Hessian matrix inverse diagonal status flag- Returns:
- non-linear regression statistics Hessian matrix inverse diagonal status flag
-
getPseudoErrors
public double[] getPseudoErrors()
Get the pseudo-estimates of the errors of the best estimates of the unknown parameters- Returns:
- pseudo-estimates of the errors of the best estimates
-
getPseudoSd
public double[] getPseudoSd()
Get the pseudo-estimates of the errors of the best estimates of the unknown parameters- Returns:
- pseudo-estimates of the errors of the best estimates
-
getPvalues
public double[] getPvalues()
Get the p-values of the best estimates- Returns:
- p-values of the best estimates
-
getReducedChiSquare
public double getReducedChiSquare()
Get the reduced chi square estimate- Returns:
- reduced chi square estimate
-
getResiduals
public double[] getResiduals()
Get the unweighed residuals, y(experimental) - y(calculated)- Returns:
- unweighed residuals, y(experimental) - y(calculated)
-
getSampleR
public double getSampleR()
Get the Sample Correlation Coefficient- Returns:
- Sample Correlation Coefficient
-
getSampleR2
public double getSampleR2()
Get the Sample Correlation Coefficient Squared- Returns:
- Sample Correlation Coefficient Squared
-
getScale
public double[] getScale()
- Returns:
- scaling factors
-
getSimplexSd
public double getSimplexSd()
Get the simplex sd at the minimum- Returns:
- simplex sd at the minimum
-
getSumOfSquares
public double getSumOfSquares()
Get the unweighed sum of squares of the residuals- Returns:
- unweighed sum of squares of the residuals
-
getTolerance
public double getTolerance()
Get the non-linear regression tolerance- Returns:
- non-linear regression tolerance
-
getTrueFreq
public boolean getTrueFreq()
Get the true frequency test, trueFreq- Returns:
- trueFreq
-
getTvalues
public double[] getTvalues()
Get the t-values of the best estimates- Returns:
- t-values of the best estimates
-
getWeightedResiduals
public double[] getWeightedResiduals()
Get the weighted residuals, (y(experimental) - y(calculated))/weight- Returns:
- weighted residuals
-
getXdata
public double[][] getXdata()
Get the input x values- Returns:
- input x values
-
getYcalc
public double[] getYcalc()
Get the calculated y values- Returns:
- calculated y values
-
getYdata
public double[] getYdata()
Get the input y values- Returns:
- input y values
-
ignoreDofFcheck
public void ignoreDofFcheck()
Ignore check on whether degrees of freedom are greater than zero
-
infinityCheck
public boolean infinityCheck(double yPeak, int peaki)
Check for y value = infinity- Parameters:
yPeak
- ???peaki
- ???- Returns:
- true if an infinity value has been removed
-
multCorrelCoeff
protected void multCorrelCoeff(double[] yy, double[] yyCalc, double[] ww)
Calculate the multiple correlation coefficient- Parameters:
yy
- ???yyCalc
- ???ww
- ???
-
nelderMead
protected void nelderMead(java.lang.Object regFun, double[] start, double[] step, double fTol, int nMax)
Nelder and Mead Simplex Simplex Non-linear Regression- Parameters:
regFun
- function to be fitted tostart
- initial parameter valuesstep
- initial parameter step valuesfTol
- tolerancenMax
- maximum number of iterations
-
pseudoLinearStats
protected int pseudoLinearStats(java.lang.Object regFun)
apply linear statistics to a non-linear regression- Parameters:
regFun
- test function- Returns:
- pseudo linear statistics
-
removeConstraints
public void removeConstraints()
remove all constraint boundaries for the non-linear regression
-
setConstraintTolerance
public void setConstraintTolerance(double tolerance)
Reset the tolerance used in a fixed value constraint- Parameters:
tolerance
- fitting tolerance threshold
-
setDefaultValues
protected void setDefaultValues(double[][] xData, double[] yData, double[] weight)
Set data and default values- Parameters:
xData
- ???yData
- ???weight
- ???
-
setDelta
public void setDelta(double delta)
Set the non-linear regression fractional step size used in numerical differencing- Parameters:
delta
- non-linear regression fractional step size used in numerical differencing
-
setMinTest
public void setMinTest(int n)
Reset the non-linear regression convergence test option- Parameters:
n
- 0 or 1
-
setNmax
public void setNmax(int nmax)
Set the maximum number of iterations allowed in nonlinear regression- Parameters:
nmax
- maximum number of iterations
-
setNMcontract
public void setNMcontract(double con)
Reset the Nelder and Mead contraction coefficient [gamma]- Parameters:
con
- Nelder and Mead contraction coefficient [gamma]
-
setNMextend
public void setNMextend(double ext)
Reset the Nelder and Mead extension coefficient [beta]- Parameters:
ext
- extension coefficient beta
-
setNMreflect
public void setNMreflect(double refl)
Reset the Nelder and Mead reflection coefficient [alpha]- Parameters:
refl
- alpha parameter
-
setNrestartsMax
public void setNrestartsMax(int nrs)
- Parameters:
nrs
- maximum number of restarts allowed in nonlinear regression
-
setScale
public void setScale(double[] sc)
Reset scaling factors (scaleOpt 2, see above for scaleOpt 0 and 1)- Parameters:
sc
- scaling factor
-
setScale
public void setScale(int n)
Reset scaling factors (scaleOpt 0 and 1, see below for scaleOpt 2)- Parameters:
n
- 0 or 1
-
setTolerance
public void setTolerance(double tol)
Set the non-linear regression tolerance- Parameters:
tol
- non-linear regression tolerance
-
setTrueFreq
public void setTrueFreq(boolean trFr)
Reset the true frequency test, trueFreq true if yData values are true frequencies, e.g. in a fit to Gaussian; false if not if true chiSquarePoisson (see above) is also calculated- Parameters:
trFr
- ???
-
simplex
public void simplex(Function1D g, double[] start)
Nelder and Mead simplex Default tolerance Default maximum iterations Default step option - all step[i] = dStep- Parameters:
g
- functionstart
- initial parameter values
-
simplex
public void simplex(Function1D g, double[] start, double fTol)
Nelder and Mead simplex Default maximum iterations Default step option - all step[i] = dStep- Parameters:
g
- functionstart
- initial parameter valuesfTol
- fitting tolerance
-
simplex
public void simplex(Function1D g, double[] start, double fTol, int nMax)
Nelder and Mead simplex Default step option - all step[i] = dStep- Parameters:
g
- functionstart
- initial parameter valuesfTol
- fitting tolerancenMax
- maximum number of iterations
-
simplex
public void simplex(Function1D g, double[] start, double[] step)
Nelder and Mead simplex- Parameters:
g
- functionstart
- initial parameter valuesstep
- initial parameter step values
-
simplex
public void simplex(Function1D g, double[] start, double[] step, double fTol)
Nelder and Mead simplex Default maximum iterations- Parameters:
g
- functionstart
- initial parameter valuesstep
- initial parameter step valuesfTol
- fitting tolerance
-
simplex
public void simplex(Function1D g, double[] start, double[] step, double fTol, int nMax)
Nelder and Mead Simplex Simplex Non-linear Regression- Parameters:
g
- functionstart
- initial parameter valuesstep
- initial parameter step valuesfTol
- fitting tolerancenMax
- maximum number of iterations
-
simplex
public void simplex(Function1D g, double[] start, double[] step, int nMax)
Nelder and Mead simplex Default tolerance- Parameters:
g
- functionstart
- initial parameter valuesstep
- initial parameter step valuesnMax
- maximum number of iterations
-
simplex
public void simplex(Function1D g, double[] start, int nMax)
Nelder and Mead simplex Default tolerance Default step option - all step[i] = dStep- Parameters:
g
- functionstart
- initial parameter valuesnMax
- maximum number of iterations
-
simplex2
@Deprecated public void simplex2(FunctionND g, double[] start)
Deprecated.do not use yet in a production environment, needs some clean-upNelder and Mead simplex Default tolerance Default maximum iterations Default step option - all step[i] = dStep- Parameters:
g
- function to fitstart
- initial parameter values
-
simplex2
@Deprecated public void simplex2(FunctionND g, double[] start, double fTol)
Deprecated.do not use yet in a production environment, needs some clean-upNelder and Mead simplex Default maximum iterations Default step option - all step[i] = dStep- Parameters:
g
- function to fitstart
- initial parameter valuesfTol
- fitting tolerance
-
simplex2
@Deprecated public void simplex2(FunctionND g, double[] start, double fTol, int nMax)
Deprecated.do not use yet in a production environment, needs some clean-upNelder and Mead simplex Default step option - all step[i] = dStep- Parameters:
g
- function to fitstart
- initial parameter valuesfTol
- fitting tolerancenMax
- maximum number of iterations
-
simplex2
@Deprecated public void simplex2(FunctionND g, double[] start, double[] step)
Deprecated.do not use yet in a production environment, needs some clean-upNelder and Mead simplex Default tolerance Default maximum iterations- Parameters:
g
- functionstart
- initial parameter valuesstep
- initial parameter step values
-
simplex2
@Deprecated public void simplex2(FunctionND g, double[] start, double[] step, double fTol)
Deprecated.do not use yet in a production environment, needs some clean-upNelder and Mead simplex Default maximum iterations- Parameters:
g
- functionstart
- initial parameter valuesstep
- initial parameter step valuesfTol
- fitting tolerance
-
simplex2
@Deprecated public void simplex2(FunctionND g, double[] start, double[] step, double fTol, int nMax)
Deprecated.do not use yet in a production environment, needs some clean-upNelder and Mead Simplex Simplex2 Non-linear Regression- Parameters:
g
- functionstart
- initial parameter valuesstep
- initial parameter step valuesfTol
- fitting tolerancenMax
- maximum number of iterations
-
simplex2
@Deprecated public void simplex2(FunctionND g, double[] start, double[] step, int nMax)
Deprecated.do not use yet in a production environment, needs some clean-upNelder and Mead simplex Default tolerance- Parameters:
g
- functionstart
- initial parameter valuesstep
- initial parameter step valuesnMax
- maximum number of iterations
-
simplex2
@Deprecated public void simplex2(FunctionND g, double[] start, int nMax)
Deprecated.do not use yet in a production environment, needs some clean-upNelder and Mead simplex Default tolerance Default step option - all step[i] = dStep- Parameters:
g
- function to fitstart
- initial parameter valuesnMax
- maximum number of iterations
-
sumSquares
protected double sumSquares(java.lang.Object regFun, double[] testParameter)
Calculate the sum of squares of the residuals for non-linear regression- Parameters:
regFun
- test functiontestParameter
- test parameter- Returns:
- sum of squares
-
dataSign
@Deprecated protected static java.util.ArrayList<java.lang.Object> dataSign(double[] data)
Deprecated.replace with optimised routinescheck data arrays for sign, max, min and peak- Parameters:
data
- input data- Returns:
- data arrays for sign, max, min and peak
-
halfWidth
protected static double halfWidth(double[] xData, double[] yData)
returns estimate of half-height width- Parameters:
xData
- x coordinate of input datayData
- y coordinate of input data- Returns:
- estimate of half-height width
-
setTrueFreqWeights
protected static boolean setTrueFreqWeights(double[] yData, double[] weight)
-
sort
protected static void sort(double[] x, double[] y, double[] w)
sort elements x, y and w arrays of doubles into ascending order of the x array using selection sort method- Parameters:
x
- ???y
- ???w
- ???
-
-