LinearFitResult
Definition
LinearFitResult is an immutable dataclass with slots=True, used as the return object of lin_fit.
Purpose
Collect the fit parameters, associated uncertainties, residuals, diagnostics, and optional figure in a single typed container.
Fields
slope: slope of the fitted line.intercept: intercept of the fitted line.slope_std: standard uncertainty on the slope.intercept_std: standard uncertainty on the intercept.covariance: covariance between the two fit parameters.correlation: correlation coefficient between slope and intercept.residuals: vector of residualsy - (m x + c).residual_std: compact estimate of residual dispersion.chi2: chi-squared of the fit.reduced_chi2: reduced chi-squared.dof: degrees of freedom, equal ton - 2.iterations: number of weight updates performed.converged: indicates whether the iteration withsigma_xsatisfied the stopping criterion.figure: matplotlib object orNonewhenshow_plot=False.
When to read it
Use this object when you want to:
retrieve the fit parameters without having to parse a string or a legend
check fit quality through residuals and
reduced_chi2decide whether to save or reuse the generated figure
Example
result = lin_fit(x, y, sigma_y, show_plot=False)
print(result.slope)
print(result.intercept_std)
print(result.reduced_chi2)
Notes
The class does not perform calculations on its own: it is a representation of the output produced by lin_fit.