Package gov.nih.mipav.model.algorithms
Class FitGaussian
java.lang.Object
gov.nih.mipav.model.algorithms.NLConstrainedEngine
gov.nih.mipav.model.algorithms.NLFittedFunction
gov.nih.mipav.model.algorithms.FitGaussian
FitGaussian -fits an array of points to a normal curve, general from f = a*exp(-(x-b)^2/2sigma^2)
Will also perform thresholding techniques to determine useful data points for fitting
- Version:
- 0.1
- Author:
- senseneyj
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate doubleAmplitude parameterprivate intLocation in xSeries where Gaussian data endsprivate intLocation in xSeries where Gaussian data startsprivate intprivate doubleR squaredprivate doubleSigma parameterprivate doubleCenter parameterFields inherited from class gov.nih.mipav.model.algorithms.NLFittedFunction
chisq, EPSILON, MAX_ITR, MIN_ITR, xSeries, yDataFitted, ySeriesFields 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
ConstructorsConstructorDescriptionFitGaussian - test constructor, builds and test function.FitGaussian(int nPoints, double[] xData, double[] yData) FitGaussian.FitGaussian(int nPoints, float[] xData, float[] yData) Constructs new fit gaussian. -
Method Summary
Modifier and TypeMethodDescriptionprivate double[]Apply small kernel to smooth out data.protected voidCalculates chi squaredprotected voidCalculates yDataFittedprivate doubledgdA(double x) Partial derivative of gaussian with respect to A.private doubledgdsigma(double x) Partial derivative of gaussian with respect to sigma.private doubledgdx(double x) Partial derivative of gaussian with respect to x.voidDisplay results of displaying exponential fitting parameters.voiddriver()Starts the analysis.private voidvoidfitToFunction(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.private doublegauss(double x) Gaussian evaluated at a point with given parametersprotected Jama.MatrixJacobian used for non-linear least squares fitting.protected Jama.MatrixCalculates 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 iterationdoubleprivate voidtestData()Test data to test fitting of gaussian.Methods inherited from class gov.nih.mipav.model.algorithms.NLFittedFunction
getChisq, getFittedY, getMedianMethods inherited from class gov.nih.mipav.model.algorithms.NLConstrainedEngine
dumpTestResults, fitToTestFunction, getChiSquared, getExitStatus, getIterations, getParameters, getResiduals, statusMessage
-
Field Details
-
dataStart
private int dataStartLocation in xSeries where Gaussian data starts -
dataEnd
private int dataEndLocation in xSeries where Gaussian data ends -
amp
private double ampAmplitude parameter -
xInit
private double xInitCenter parameter -
sigma
private double sigmaSigma parameter -
rSquared
private double rSquaredR squared -
iters
private int iters
-
-
Constructor Details
-
FitGaussian
public FitGaussian()FitGaussian - test constructor, builds and test function. -
FitGaussian
public FitGaussian(int nPoints, double[] xData, double[] yData) FitGaussian.- Parameters:
nPoints- number of points in the functionxData- DOCUMENT ME!yData- DOCUMENT ME!
-
FitGaussian
public FitGaussian(int nPoints, float[] xData, float[] yData) Constructs new fit gaussian.- Parameters:
nPoints- Number of points in the functionxData- DOCUMENT ME!yData- DOCUMENT ME!
-
-
Method Details
-
applyKernel
private double[] applyKernel()Apply small kernel to smooth out data. Often helpful when too many bins have been applied by user. -
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:
driverin classNLConstrainedEngine
-
calculateChiSq
protected void calculateChiSq()Description copied from class:NLFittedFunctionCalculates chi squared- Specified by:
calculateChiSqin classNLFittedFunction
-
calculateFittedY
protected void calculateFittedY()Description copied from class:NLFittedFunctionCalculates yDataFitted- Specified by:
calculateFittedYin classNLFittedFunction
-
displayResults
public void displayResults()Display results of displaying exponential fitting parameters.- Specified by:
displayResultsin classNLFittedFunction
-
getRSquared
public double getRSquared() -
fitToFunction
public void fitToFunction(double[] a, double[] residuals, double[][] covarMat) Description copied from class:NLConstrainedEnginefitToFunction 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:
fitToFunctionin classNLConstrainedEngine- Parameters:
a- DOCUMENT ME!residuals- DOCUMENT ME!covarMat- DOCUMENT ME!
-
testData
private void testData()Test data to test fitting of gaussian. -
gauss
private double gauss(double x) Gaussian evaluated at a point with given parameters -
dgdA
private double dgdA(double x) Partial derivative of gaussian with respect to A. -
dgdx
private double dgdx(double x) Partial derivative of gaussian with respect to x. -
dgdsigma
private double dgdsigma(double x) Partial derivative of gaussian with respect to sigma. -
generateJacobian
protected Jama.Matrix generateJacobian()Jacobian used for non-linear least squares fitting. -
generateResiduals
protected Jama.Matrix generateResiduals()Description copied from class:NLFittedFunctionCalculates 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:
generateResidualsin classNLFittedFunction- Returns:
-