Skip to content

feat: Median±MAD and Mean±STDEV columns in fitted-parameters table#30

Open
ahmadomira wants to merge 1 commit into
mainfrom
feat/fitted-params-stat-pairs
Open

feat: Median±MAD and Mean±STDEV columns in fitted-parameters table#30
ahmadomira wants to merge 1 commit into
mainfrom
feat/fitted-params-stat-pairs

Conversation

@ahmadomira

Copy link
Copy Markdown
Collaborator

Summary

The Fitted Parameters table now shows two clearly-labelled stat pairs per parameter:

  • Median ± MAD (robust) — reuses the stored median/MAD (previously the lone, mislabeled "± Uncertainty (optimiser)" column).
  • Mean ± STDEV (classical) — computed from the already-stored accepted-fit pool (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 helpers compute_mean_params / compute_std_params operating on the parameter_samples dict (the pool consumers actually hold). STDEV is the sample stdev (ddof=1); a single-sample pool returns 0.0, mirroring compute_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 / format clean.

Scope kept to the two in-scope files (+ two new test files); plot_widget.py, distribution_widget.py, fit_pipeline.py, fitting_session.py untouched.

Closes #21

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.
Copilot AI review requested due to automatic review settings June 25, 2026 15:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_params helpers over FitResult.parameter_samples (sample STDEV with ddof=1, single-sample → 0.0).
  • Update FitSummaryWidget to 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}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Median±MAD and Mean±STDEV stat pairs in Fitted Parameters table

2 participants