fit_utils.py

fit_utils.py contains the package’s weighted linear fit and its associated return type. It is the densest module in the project because it combines statistics, input validation, and optional plotting, while also reusing the style system defined in plot_utils.

Main imports

What it exports

What it does

  • validate x, y, sigma_y, and optionally sigma_x

  • validate decimals, tol, and max_iter

  • estimate slope and intercept with weighted least squares

  • update the weights iteratively when uncertainties on x are also present

  • compute residuals, chi2, reduced_chi2, correlation, and other diagnostics

  • creare, se richiesto, una figura matplotlib con pannello del fit e pannello dei residui fisici o normalizzati usando lo stesso sistema di stile di histogram

Related helpers

Detailed pages