Package gov.nih.mipav.model.algorithms
Class FitLaplace
- java.lang.Object
-
- gov.nih.mipav.model.algorithms.NLConstrainedEngine
-
- gov.nih.mipav.model.algorithms.NLFittedFunction
-
- gov.nih.mipav.model.algorithms.FitLaplace
-
public class FitLaplace extends NLFittedFunction
FitLaplace -fits an array of points to a normal curve, general from f = a*exp(Math.abs(x-mu)/beta) Will also perform thresholding techniques to determine useful data points for fitting- Version:
- 0.1
- Author:
- senseneyj
- See Also:
NLConstrainedEngine
-
-
Field Summary
Fields Modifier and Type Field Description private double
amp
Amplitude parameterprivate double
beta
Beta parameterprivate int
dataEnd
Location in xSeries where Gaussian data endsprivate int
dataStart
Location in xSeries where Gaussian data startsprivate int
iters
private double
mu
Center parameter-
Fields inherited from class gov.nih.mipav.model.algorithms.NLFittedFunction
chisq, EPSILON, MAX_ITR, MIN_ITR, xSeries, yDataFitted, ySeries
-
Fields inherited from class gov.nih.mipav.model.algorithms.NLConstrainedEngine
a, absoluteConvergence, analyticalJacobian, bl, bounds, bu, ctrlMat, dyda, gues, internalScaling, jacobian, maxIterations, nPts, outputMes, param, parameterConvergence, relativeConvergence, residuals, secondAllowed, stdv, tolerance
-
-
Constructor Summary
Constructors Constructor Description FitLaplace()
FitLaplace - test constructor, builds and test function.FitLaplace(int nPoints, double[] xData, double[] yData)
FitLaplace.FitLaplace(int nPoints, float[] xData, float[] yData)
Constructs new fit laplace distribution.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
calculateChiSq()
Calculates chi squaredprotected void
calculateFittedY()
Calculates yDataFittedvoid
displayResults()
Display results of displaying exponential fitting parameters.private double
dLdA(double x)
Partial derivative of laplace dist with respect to A.private double
dLdbeta(double x)
Partial derivative of laplace dist with respect to beta.private double
dLdmu(double x)
Partial derivative of laplace dist with respect to mu.void
driver()
Starts the analysis.private void
estimateInitial()
void
fitToFunction(double[] a, double[] residuals, double[][] covarMat)
fitToFunction communicates with 3 protected variables param, nPts, and ctrlMat ctrlMat is used as a wrapper for ctrl or lctrl.protected Jama.Matrix
generateJacobian()
Jacobian used for non-linear least squares fitting.protected Jama.Matrix
generateResiduals()
Calculates the residuals for a given function, not implemented since some functions might prefer to only use a subset of data points, or not use yDataFitted if working during an iterationprivate double
laplace(double x)
Gaussian evaluated at a point with given parametersprivate void
testData()
Test data to test fitting of gaussian.-
Methods inherited from class gov.nih.mipav.model.algorithms.NLFittedFunction
getChisq, getFittedY, getMedian
-
Methods inherited from class gov.nih.mipav.model.algorithms.NLConstrainedEngine
dumpTestResults, fitToTestFunction, getChiSquared, getExitStatus, getIterations, getParameters, getResiduals, statusMessage
-
-
-
-
Field Detail
-
dataStart
private int dataStart
Location in xSeries where Gaussian data starts
-
dataEnd
private int dataEnd
Location in xSeries where Gaussian data ends
-
amp
private double amp
Amplitude parameter
-
mu
private double mu
Center parameter
-
beta
private double beta
Beta parameter
-
iters
private int iters
-
-
Constructor Detail
-
FitLaplace
public FitLaplace()
FitLaplace - test constructor, builds and test function.
-
FitLaplace
public FitLaplace(int nPoints, double[] xData, double[] yData)
FitLaplace.- Parameters:
nPoints
- number of points in the functionxData
- DOCUMENT ME!yData
- DOCUMENT ME!
-
FitLaplace
public FitLaplace(int nPoints, float[] xData, float[] yData)
Constructs new fit laplace distribution.- Parameters:
nPoints
- Number of points in the functionxData
- DOCUMENT ME!yData
- DOCUMENT ME!
-
-
Method Detail
-
estimateInitial
private void estimateInitial()
-
driver
public void driver()
Starts the analysis. For some reason a guess with the wrong sign for a2 will not converge. Therefore, try both sign and take the one with the lowest chi-squared value.- Overrides:
driver
in classNLConstrainedEngine
-
calculateChiSq
protected void calculateChiSq()
Description copied from class:NLFittedFunction
Calculates chi squared- Specified by:
calculateChiSq
in classNLFittedFunction
-
calculateFittedY
protected void calculateFittedY()
Description copied from class:NLFittedFunction
Calculates yDataFitted- Specified by:
calculateFittedY
in classNLFittedFunction
-
displayResults
public void displayResults()
Display results of displaying exponential fitting parameters.- Specified by:
displayResults
in classNLFittedFunction
-
fitToFunction
public void fitToFunction(double[] a, double[] residuals, double[][] covarMat)
Description copied from class:NLConstrainedEngine
fitToFunction communicates with 3 protected variables param, nPts, and ctrlMat ctrlMat is used as a wrapper for ctrl or lctrl. Evaluates the residuals or the Jacobian at a certain a[]- Specified by:
fitToFunction
in classNLConstrainedEngine
- Parameters:
a
- DOCUMENT ME!residuals
- DOCUMENT ME!covarMat
- DOCUMENT ME!
-
testData
private void testData()
Test data to test fitting of gaussian.
-
laplace
private double laplace(double x)
Gaussian evaluated at a point with given parameters
-
dLdA
private double dLdA(double x)
Partial derivative of laplace dist with respect to A.
-
dLdmu
private double dLdmu(double x)
Partial derivative of laplace dist with respect to mu.
-
dLdbeta
private double dLdbeta(double x)
Partial derivative of laplace dist with respect to beta.
-
generateJacobian
protected Jama.Matrix generateJacobian()
Jacobian used for non-linear least squares fitting.
-
generateResiduals
protected Jama.Matrix generateResiduals()
Description copied from class:NLFittedFunction
Calculates the residuals for a given function, not implemented since some functions might prefer to only use a subset of data points, or not use yDataFitted if working during an iteration- Specified by:
generateResiduals
in classNLFittedFunction
- Returns:
-
-