scippneutron.peaks.FitResult#
- class scippneutron.peaks.FitResult(*, aic, assessment, background, message, p_value, peak, popt, red_chisq, window)[source]#
Optimized parameters and fit statistics for a single peak.
- __init__(*, aic, assessment, background, message, p_value, peak, popt, red_chisq, window)#
Methods
__init__
(*, aic, assessment, background, ...)better_than
(other)Return True if this result is better than another.
eval_model
(x)Evaluate the model with optimized parameters.
eval_peak
(x)Evaluate the peak model with optimized parameters.
for_failure
(*[, assessment, message])Create a
FitResult
for a failed fit.for_too_narrow_window
(*, peak, background, ...)Create a
FitResult
for a fit where the window is too narrow.report
()Format an overview of the fit result.
Attributes
Akaike Information Criterion.
Indicates whether the fit was successful or how if failed.
Model for the background.
Short message describing the fit assessment.
Probability of the given chi-squared or higher.
Model for the peak.
Optimized parameters.
Reduced chi-squared for the model and optimized parameters.
Fit window for this peak.
Return whether the fit was successful.
-
aic:
Variable
# Akaike Information Criterion.
A relative estimate of fit quality. Defined as
\[\mathsf{AIC} = 2k - 2\ln(L)\]Where \(k\) is the number of parameters and \(L\) the likelihood if the model with the optimized parameters.
-
assessment:
FitAssessment
# Indicates whether the fit was successful or how if failed.
- better_than(other)[source]#
Return True if this result is better than another.
Uses
aic
to compare the results.
- classmethod for_failure(*, assessment=None, peak, background, window, message=None)[source]#
Create a
FitResult
for a failed fit.- Return type:
- classmethod for_too_narrow_window(*, peak, background, window)[source]#
Create a
FitResult
for a fit where the window is too narrow.- Return type:
-
p_value:
Variable
# Probability of the given chi-squared or higher.
The \(p\)-value is the probability to get the same \(\chi^2\) or higher when repeating the fit. It is defined as
\[p = 1 - F(\chi^2;\,\nu)\]where \(F(\chi^2;\,\nu)\) is the cumulative distribution function of the \(\chi^2\)–distribution with \(\nu\) degrees of freedom.