Joint fitting
- class asymmetry.core.fitting.joint.JointSeriesProblem(key, datasets, model_fn, global_params, local_params, initial_params, t_min=None, t_max=None, local_param_groups=None)[source]
One series’ contribution to a joint fit: its data, model and partition.
Mirrors what the Batch tab already records for a series — the model, the member runs, the fit range, the per-run parameter table with its global/local/fixed roles — so a joint fit composes series the user has already made rather than asking them to reassign runs to functions.
One quantity held equal across two or more series.
membersmaps a series key to the parameter name that series spells the quantity with, because two models may perfectly well call the same physicsA_bgandbaseline. The seed and bounds belong to the shared row, not to either series: the shared value is a new fitted quantity (the default workflow seeds it from the first contributing series, but that is the caller’s choice to make).
A proposed row of the shared table, with the evidence for it.
tieris"exact"when the same parameter name means the same thing in every model beyond doubt (ticked by default) and"candidate"when the match is a reasonable inference from the models’ structure (offered unticked). Anything more ambiguous than that is not proposed at all.
- asymmetry.core.fitting.joint.fit_joint(problems, shared, *, strategy='least_squares', method='migrad', max_calls=10000, minos=False, fit_engine=None, cancel_callback=None)[source]
Fit several series at once, holding the named parameters equal across them.
One cost function spans every run of every series. Each series keeps its own model, fit range, seeds, bounds and pins; the entries of
sharedare the only thing that couples them. A series that pins a shared member on one of its runs uses its own pinned value there — a file-pinned or user-pinned quantity is a measurement, and the constraint must not overwrite it.- Parameters:
problems – Two or more series. Run numbers must be unique across the whole joint fit: the same data in the cost twice would double-count it.
shared – The shared table. Each entry names two or more series’ parameters that are the same quantity. A member must be a Global parameter of its series (
global_params) and must be free on at least one of that series’ runs — a name that series pins everywhere has no column to share.strategy –
"least_squares"(default, bounded sparse trust region) or"joint"(one Minuit over the whole vector)."profiled"raises: it profiles one set of globals over datasets that share a model, which a joint fit does not have.minos – Asymmetric MINOS intervals;
"joint"strategy only.fit_engine – Optional
FitEngineto reuse; a fresh one is created otherwise.cancel_callback – Cooperative cancel probe polled inside the cost function; a truthy return raises
FitCancelledError, and the run records nothing.
- Raises:
ValueError – Fewer than two series; duplicate series keys; a run number in two series; a shared row with fewer than two members, an unknown series key, a member that is not one of that series’ Global parameters, or a member that series pins on every run; the same parameter shared twice; an unknown
strategy.NotImplementedError –
strategy="profiled", or an affine parameter tie anywhere (ties are honoured only by the single-run path).
Propose the default shared table from the member models and their roles.
Two tiers, and nothing else:
"exact"— the same full parameter name, with the same unit, occurring exactly once in each model and carrying the Global role in each series. There is no room for doubt about what such a row means, so the caller ticks these by default."candidate"— the same base name at a different component index (A_1here,A_2there), or the same component type where each model has exactly one instance of it; again unit-equal and Global everywhere. A reasonable inference, offered unticked.
Anything ambiguous is not proposed. A name that occurs twice in one model, a component type one model instantiates twice, a unit that differs between models, a parameter that is Local or Fixed in any series — each is left for the user, because guessing wrong here silently constrains two quantities that are not the same measurement.
The one caveat the docs must repeat: “initial asymmetry” is shareable only where the model exposes it as one parameter (a fraction-group model with an overall scale). A sum of component amplitudes is a constraint, not a shared parameter, and is out of scope.