feat: Median±MAD and Mean±STDEV columns in fitted-parameters table#30
Open
ahmadomira wants to merge 1 commit into
Open
feat: Median±MAD and Mean±STDEV columns in fitted-parameters table#30ahmadomira wants to merge 1 commit into
ahmadomira wants to merge 1 commit into
Conversation
The Fitted Parameters table previously showed only the median and its MAD (mislabeled '± Uncertainty (optimiser)'). Robust summaries hide the outlier sensitivity a reader may want to judge, so also surface the classical Mean ± STDEV pair, computed from the already-stored accepted-fit pool (parameter_samples) with no re-fit. The info-box now explains when MAD and STDEV agree (STDEV ≈ 1.48×MAD for a clean Gaussian pool) and when they diverge, and the fit-mode/pool context moves from the column header to a caption.
There was a problem hiding this comment.
Pull request overview
Adds side-by-side robust and classical summary statistics to the Fitted Parameters table, making it clearer how parameter estimates behave across the accepted-fit pool without re-fitting.
Changes:
- Add
compute_mean_params/compute_std_paramshelpers overFitResult.parameter_samples(sample STDEV withddof=1, single-sample →0.0). - Update
FitSummaryWidgetto display Median ± MAD and Mean ± STDEV columns plus a mode/pool-size caption and updated explanatory help text. - Add unit tests for the new mean/STDEV aggregation and for widget rendering/fallback behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
core/optimizer/filters.py |
Introduces mean and sample-STDEV aggregation helpers for accepted-fit pools. |
gui/plotting/fit_summary_widget.py |
Updates fitted-parameters table layout to show both stat pairs and adds a caption/help text. |
tests/unit/test_filters_mean_std.py |
Verifies mean/STDEV aggregation math (including outlier and single-sample cases). |
tests/unit/gui/test_fit_summary_stats.py |
Verifies widget wiring: both stat pairs render, fallback for missing pool, caption updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+101
to
+105
| def _fmt_mag(magnitude: float, unit_str: str) -> str: | ||
| """Format a magnitude for display, stripping any unit (shown separately).""" | ||
| if unit_str: | ||
| return f'{Q_(magnitude, unit_str):.3g~H}'.rsplit(' ', 1)[0] | ||
| return f'{magnitude:.3g}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Fitted Parameters table now shows two clearly-labelled stat pairs per parameter:
FitResult.parameter_samples); no re-fit.Both pairs are shown in average and per-replica modes. The fit-mode and pool-size context that used to live in the dynamic column header now appears as a caption under the table (e.g. "Statistics across N = 87 accepted fits (average mode)"). When a result has no pool (e.g. imported from an older JSON), the Mean ± STDEV cell shows
—with an explanatory tooltip while the robust pair still renders.The info-box was rewritten to explain MAD vs STDEV intuitively: they agree after a fixed scaling for a clean Gaussian pool (STDEV ≈ 1.48 × MAD) and diverge under outliers/skew — in which case the robust pair is the one to trust.
Implementation
core/optimizer/filters.py: added pure helperscompute_mean_params/compute_std_paramsoperating on theparameter_samplesdict (the pool consumers actually hold). STDEV is the sample stdev (ddof=1); a single-sample pool returns 0.0, mirroringcompute_mad.gui/plotting/fit_summary_widget.py: 4-column layout (Parameter | Median ± MAD | Mean ± STDEV | Units), mode caption, rewritten info-box.Tests
tests/unit/test_filters_mean_std.py— mean/STDEV aggregation, hand-derived expected values (incl. outlier-skew divergence and single-sample edge).tests/unit/gui/test_fit_summary_stats.py— widget wiring: both pairs render, pool feeds the classical pair,—fallback without a pool, mode caption.uv run pytest -k "summary or filters"→ 13 passed; full fast GUI layer (104) green;ruff check/formatclean.Scope kept to the two in-scope files (+ two new test files);
plot_widget.py,distribution_widget.py,fit_pipeline.py,fitting_session.pyuntouched.Closes #21