Count-domain fitting

asymmetry.core.fitting.count_domain.SEED_FROM_DATA

Seed sentinel — give this as a parameter’s value and the count-fit driver computes the seed from the data instead. Supported for N0, whose right scale is a per-run count level no caller can know in advance — a generic seed drops the forward/backward fit into a spurious minimum (see fit_fb_alpha()). Omitting N0 from the set entirely does the same thing; the sentinel exists for callers that want to state the bounds.

asymmetry.core.fitting.count_domain.fit_fb_alpha(dataset, forward_group, backward_group, model_fn, params, *, cost='poisson', t_min=None, t_max=None, exclude=None, estimate_beta=False, minos=False, cancel_callback=None)[source]

Prepare and jointly fit F/B counts with shared physics and balance.

Physics amplitudes are percent; scales/backgrounds are counts per packed bin. estimate_beta permits a shared backward amplitude ratio, including fixed beta constraints. Otherwise beta is absent. Gaussian cost uses retained count errors; Poisson cost requires uncorrected integer acquisition observations. Optional t0, lifetime, deadtime and pulse nuisances use the same joint solver.

asymmetry.core.fitting.count_domain.fit_single_histogram(dataset, group_id, model_fn, params, *, side='forward', cost='poisson', t_min=None, t_max=None, exclude=None, minos=False, cancel_callback=None)[source]

Fit one detector group’s raw counts (the musrfit fittype-0 analogue).

The count model is N0 * exp(-t/tau) * (1 + s*A*P(t)) + bg with s the forward (+1) / backward (-1) sign set by side ("selected" uses +1). params supplies the nuisances N0 and background plus the physics model parameters; the muon lifetime is held fixed at the physical value.

Scale: the physics model’s asymmetry parameters (A/A0, baseline) are in percent (0–100), as everywhere else in the fitting layer — asymmetry.core.fitting.count_domain._percent_to_fraction divides the 100 out internally so 1 + a combines a true fraction with the counts. Seed and read A in percent. The data here is raw counts, so the percent/fraction question touches only the parameters, not the arrays.

Optional window/nuisance flexibility, all no-ops unless requested: exclude drops an interior time window from the fit; a free t0 parameter shifts the model time axis; free lambda_base / beta_base parameters add a stretched-exponential baseline drift; the deadtime parameter DT0 adds a rational non-paralysable count-loss term; a dpsep parameter selects the double-delta count model with fixed supplied separation. A tau parameter frees the muon lifetime (musrfit-style; default fixed at the physical value); it is not supported together with the double-pulse model.