Summary
_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).
Summary
_prepare_fit_arraysreturnsweights = 1/sigmaand passes them asweights=dytoeasy_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 expects1/sigma,sigma, or1/sigma^2is 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_arraysaccordingly.Related observations in the same area (can be folded in or split):
mcmc_sample(fitting.py:358-437) silently applies the Mighell transform (defaulthybrid) 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.yedefaults tonp.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).