You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pin the fit weight convention with an analytic weighted-least-squares test #370
_prepare_fit_arrays returns weights = 1/sigma and passes them as weights=dy to easy_science_multi_fitter.fit (src/easyreflectometry/fitting.py:122, 254). The internal chi^2 helper (fitting.py:138) consistently treats the same array as sigma-denominators, but whether the EasyScience core fitter expects 1/sigma, sigma, or 1/sigma^2 is not pinned by any numerical test. This is the single most load-bearing assumption in the fitting stack: if the convention is wrong, every fitted parameter uncertainty (and the chi^2-based model comparison) is wrong.
Suggested fix
Add a test that fits a straight line (or single-layer reflectivity) with known heteroscedastic errors and asserts both the parameter values and the parameter covariance against the analytic WLS solution. If the convention turns out mismatched, fix _prepare_fit_arrays accordingly.
Related observations in the same area (can be folded in or split):
mcmc_sample (fitting.py:358-437) silently applies the Mighell transform (default hybrid) to zero-variance points feeding the Bayesian likelihood — Mighell is a chi-square bias correction, not a likelihood; at minimum warn (the least-squares path does).
DataSet1D.ye defaults to np.zeros_like(x) (data/data_store.py:108), i.e. zero variance, which the fitter then masks/transforms wholesale; "no uncertainties supplied" deserves a loud error.
Found during deep code review (DEEP_ANALYSIS.md §4.10).
Activity
fixing #370 (#388)
Core fixes (#383)
rozyczko commentedon Sep 11, 2026
The issue is no longer valid. It was fixed in the "Core fixes" merge, commit 01c07d5, whose message includes "fixing #370 (#388)".
🎉 Release: merge develop into master (#442)
Release 2.0.0 (#454)