Class LorentzianFitter
- All Implemented Interfaces:
IFitStringGetter,IFitter
y(x) = A * (Γ/2)² / [(x - x&sub0;)² + (Γ/2)²] + B
Normalisation
The parameter A is the peak height above baseline (i.e.
y(x₀) = A + B), not the area. This matches the Gaussian fitter
convention used elsewhere in splot, making it easy to switch between the
two.
Parameter ordering
params[0] = A— peak height above baselineparams[1] = x₀— peak centerparams[2] = Γ— full-width at half-maximum (FWHM); enforced>= DEFAULT_MIN_GAMMAparams[3] = B— baseline offset
Relationship to Gaussian
A Lorentzian has heavier tails than a Gaussian of the same FWHM. For a
Gaussian, FWHM = 2√(2 ln 2)·σ ≈ 2.355·σ. Both models have the same
peak-height parameter A and baseline B, so they can be
compared directly.
Typical applications
Resonance peaks in nuclear/particle physics (Breit-Wigner), spectral line shapes in atomic spectroscopy, quality-factor measurements in mechanical or electrical resonators, natural line widths.
- Author:
- heddle
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleMinimum FWHM to avoid divide-by-zero in the Jacobian.static final intIndex of peak-height parameterA.static final intIndex of baseline parameterB.static final intIndex of FWHM parameterΓ.static final intIndex of peak-center parameterx₀.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.LorentzianFitter(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 * (Γ/2)² / [(x − x₀)² + (Γ/2)²] + B.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 peak-height parameterA.- See Also:
-
IDX_X0
public static final int IDX_X0Index of peak-center parameterx₀.- See Also:
-
IDX_G
public static final int IDX_GIndex of FWHM parameterΓ.- See Also:
-
IDX_B
public static final int IDX_BIndex of baseline parameterB.- See Also:
-
PARAM_NAMES
Display names used in legend strings and fit summaries. -
DEFAULT_MIN_GAMMA
public static final double DEFAULT_MIN_GAMMAMinimum FWHM to avoid divide-by-zero in the Jacobian.- See Also:
-
-
Constructor Details
-
LorentzianFitter
public LorentzianFitter()Creates a fitter with the default Levenberg-Marquardt optimizer. -
LorentzianFitter
public LorentzianFitter(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 * (Γ/2)² / [(x − x₀)² + (Γ/2)²] + B.- Specified by:
asEvaluatorin classALeastSquaresFitter- Parameters:
fit- fit result from a previous call toALeastSquaresFitter.fit(double[], double[])- Returns:
- evaluator for the fitted Lorentzian
- 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
-