Class ExponentialDecayFitter
- All Implemented Interfaces:
IFitStringGetter,IFitter
y(x) = A * exp(-x / τ) + C
Parameter ordering
params[0] = A— amplitudeparams[1] = τ— decay constant (enforced> 0)params[2] = C— baseline offset
Typical applications
Radioactive decay, RC circuit discharge, fluorescence lifetime, exponential growth (negative τ via sign of A).
Initial guess strategy
The offset C is estimated from the tail of the data. The
amplitude A comes from the first point minus the offset. The
decay constant τ is estimated by log-linearising the
offset-subtracted data and fitting a line through the log-transformed
values.
Constraint
τ >= DEFAULT_MIN_TAU is enforced by a clamping parameter
validator to prevent division by zero in the Jacobian.
- Author:
- heddle
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleMinimum decay constant to avoid divide-by-zero in the Jacobian.static final intIndex of amplitude parameterA.static final intIndex of baseline-offset parameterC.static final intIndex of decay-constant parameterτ.static final String[]Display names used in legend strings and fit summaries.Fields inherited from class edu.cnu.mdi.splot.fit.ALeastSquaresFitter
CAPSIG, checker, covarianceThreshold, initialGuesser, maxEvaluations, maxIterations, MU, OMEGA, optimizer, PHI, SMALLSIG, SUB0, SUB1, SUB2, subArray, SUBN, SUP0, SUP1, SUP2, SUPN -
Constructor Summary
ConstructorsConstructorDescriptionCreates a fitter with the default Levenberg-Marquardt optimizer.ExponentialDecayFitter(org.apache.commons.math3.fitting.leastsquares.LeastSquaresOptimizer optimizer) Creates a fitter with a custom optimizer. -
Method Summary
Modifier and TypeMethodDescriptionasEvaluator(FitResult fit) Returns anEvaluatorthat computesA * exp(-x / τ) + Cfrom the supplied fit result.protected double[]defaultInitialGuess(double[] x, double[] y, double[] weights) Default initial guess used if the caller does not provide an explicit override.protected org.apache.commons.math3.fitting.leastsquares.ParameterValidatorDefault validator/bounds policy (optional).protected intGet the descriptive string getter for this fitter.protected org.apache.commons.math3.fitting.leastsquares.MultivariateJacobianFunctionmodel(double[] x) Build the model + analytic (or numeric) Jacobian for this fitter, given x values.parameterName(int index) Return the display name of a fitted parameter.Methods inherited from class edu.cnu.mdi.splot.fit.ALeastSquaresFitter
buildFitResult, clampingValidator, fit, fit, fit, getChecker, getCovarianceThreshold, getMaxEvaluations, getMaxIterations, safeCovariances, validateWeights, validateXY, weightsFromSigmaY
-
Field Details
-
IDX_A
public static final int IDX_AIndex of amplitude parameterA.- See Also:
-
IDX_TAU
public static final int IDX_TAUIndex of decay-constant parameterτ.- See Also:
-
IDX_C
public static final int IDX_CIndex of baseline-offset parameterC.- See Also:
-
PARAM_NAMES
Display names used in legend strings and fit summaries. -
DEFAULT_MIN_TAU
public static final double DEFAULT_MIN_TAUMinimum decay constant to avoid divide-by-zero in the Jacobian.- See Also:
-
-
Constructor Details
-
ExponentialDecayFitter
public ExponentialDecayFitter()Creates a fitter with the default Levenberg-Marquardt optimizer. -
ExponentialDecayFitter
public ExponentialDecayFitter(org.apache.commons.math3.fitting.leastsquares.LeastSquaresOptimizer optimizer) Creates a fitter with a custom optimizer.- Parameters:
optimizer- the least-squares optimizer to use (non-null)
-
-
Method Details
-
getParameterCount
protected int getParameterCount()- Specified by:
getParameterCountin classALeastSquaresFitter- Returns:
- number of parameters for this fitter.
-
model
protected org.apache.commons.math3.fitting.leastsquares.MultivariateJacobianFunction model(double[] x) Description copied from class:ALeastSquaresFitterBuild the model + analytic (or numeric) Jacobian for this fitter, given x values.- Specified by:
modelin classALeastSquaresFitter- Parameters:
x- x data (length n)- Returns:
- a
MultivariateJacobianFunctioncompatible with Commons Math least-squares
-
defaultInitialGuess
protected double[] defaultInitialGuess(double[] x, double[] y, double[] weights) Description copied from class:ALeastSquaresFitterDefault initial guess used if the caller does not provide an explicit override. The default implementation delegates to theALeastSquaresFitter.initialGuesser.Subclasses may override if they have a better model-specific guess.
- Overrides:
defaultInitialGuessin classALeastSquaresFitter- Parameters:
x- x datay- y dataweights- optional weights (may be null)- Returns:
- initial parameter vector of length
ALeastSquaresFitter.getParameterCount()
-
defaultValidator
protected org.apache.commons.math3.fitting.leastsquares.ParameterValidator defaultValidator()Description copied from class:ALeastSquaresFitterDefault validator/bounds policy (optional).Return null for "no validation". For simple bound constraints, consider using
ALeastSquaresFitter.clampingValidator(double[], double[]).- Overrides:
defaultValidatorin classALeastSquaresFitter- Returns:
- a parameter validator or null
-
asEvaluator
Returns anEvaluatorthat computesA * exp(-x / τ) + Cfrom the supplied fit result.- Specified by:
asEvaluatorin classALeastSquaresFitter- Parameters:
fit- fit result from a previous call toALeastSquaresFitter.fit(double[], double[])- Returns:
- evaluator for the fitted function
- Throws:
NullPointerException- iffitisnullIllegalArgumentException- if the result has the wrong parameter count
-
modelName
- Returns:
- model name suitable for a legend or report
-
functionForm
- Returns:
- mathematical function form suitable for display
-
parameterName
Description copied from interface:IFitStringGetterReturn the display name of a fitted parameter.- Parameters:
index- zero-based parameter index- Returns:
- parameter name
-
getStringGetter
Description copied from class:ALeastSquaresFitterGet the descriptive string getter for this fitter.- Specified by:
getStringGetterin classALeastSquaresFitter- Returns:
- the string getter
-