rxmc.observation.Observation#
- class rxmc.observation.Observation(x: ndarray, y: ndarray, y_stat_err=None, y_sys_err_normalization=None, y_sys_err_offset=None, label=None, transform=None, mask=None)[source]#
Bases:
objectExperimental data:
x,y, and the statistical error ony.- Parameters:
x (np.ndarray) – Independent-variable data.
y (np.ndarray) – Dependent-variable data, same shape as
x.y_stat_err (np.ndarray, optional) – Statistical (uncorrelated) error on
y. Defaults to zeros.y_sys_err_normalization (float or np.ndarray, optional) – Reported fractional (dimensionless) normalisation uncertainty — inert metadata; see
systematic_terms().y_sys_err_offset (float or np.ndarray, optional) – Reported absolute offset uncertainty, in the same units as
y— inert metadata; seesystematic_terms().label (str, optional) – Human-readable dataset identifier used in error messages.
transform (Transform or callable, optional) – Parameter-free comparison-space transform (see
rxmc.transforms). Pass rawy: the observation storesy = transform(y_raw)and propagatesy_stat_errby the delta method, and theConstraintapplies the same transform to the model prediction — sotransform=rxmc.transforms.logcompares in log space with the model written once, in physical space.mask (array_like of bool, optional) – Which points are active in a likelihood (default all). Inactive points stay in the block (supports/terms are authored over all points) but are excluded from the residual; use
masked()/masked_where()to derive fit/held-out views.
- x, y
The data,
yin comparison space.- Type:
np.ndarray
- y_raw, y_stat_err_raw
yand its statistical error as given (physical space).- Type:
np.ndarray
- y_stat_err#
Statistical error on
yin comparison space (raw, not squared).- Type:
np.ndarray
- identity#
The root observation this one is a view of. Views made by
masked()share it, so anything routing by observation (e.g.rxmc.transforms.per_observation_scaling()) treats a masked view and its root as the same dataset.- Type:
- y_sys_err_normalization#
Fractional normalisation uncertainty (dimensionless).
- Type:
float or np.ndarray or None
- __init__(x: ndarray, y: ndarray, y_stat_err=None, y_sys_err_normalization=None, y_sys_err_offset=None, label=None, transform=None, mask=None)[source]#
Methods
__init__(x, y[, y_stat_err, ...])masked(mask[, label])A shallow copy of this observation with a new point mask.
masked_where(predicate[, label])masked()withmask = predicate(x)(points where it is True).num_pts_within_interval(ylow, yhigh[, xlim])Number of active points of
ythat fall within[ylow, yhigh).statistical_term([support])The always-on, genuinely uncorrelated statistical diagonal.
systematic_terms([support])This dataset's reported correlated systematics as fixed rank-one terms.
Attributes
sum(log |t'(y_raw)|)over the active points.Number of active (unmasked) points.
- masked(mask, label=None)[source]#
A shallow copy of this observation with a new point mask.
No data or pre-computed workspaces are rebuilt: the copy shares them and only changes which points enter a likelihood.
- masked_where(predicate, label=None)[source]#
masked()withmask = predicate(x)(points where it is True).
- property log_jacobian: float#
sum(log |t'(y_raw)|)over the active points.The log-Jacobian of the comparison-space transform: a constant in the parameters, needed only to compare marginal likelihoods (log Z) across different comparison spaces (
log Z_raw = log Z_transformed + log_jacobian). Zero for the identity.
- statistical_term(support=None)[source]#
The always-on, genuinely uncorrelated statistical diagonal.
- Parameters:
support (np.ndarray, optional) – Indices of this observation’s block in the stacked vector (
Nonefor a single-observation constraint).- Returns:
Term –
diag(y_stat_err**2)onsupport(comparison space).
- systematic_terms(support=None) list[source]#
This dataset’s reported correlated systematics as fixed rank-one terms.
Opt-in — not added to any covariance automatically. Pass the result via
Constraint(extra_terms=[*obs.systematic_terms(), ...]). Zero magnitudes are skipped, so an observation without reported systematics yields an empty list. Magnitudes are reported in physical space and propagated to the comparison space by the delta method (|t'| * omegafor an offset,|t'(ym_raw)| * eta * ym_rawfor a normalisation).- Parameters:
support (np.ndarray, optional) – Indices of this observation’s block in the stacked vector.
Nonebinds the terms to the whole constraint, which is right only for a single-observation constraint; in a multi-observation constraint they then fail loudly with a shape error, so pass the block’s support there (seerxmc.covariance.stacked_supports()).- Returns:
list of Term – The absolute offset mode (
outer(omega, omega)) first, then the fractional, prediction-scaled normalisation mode (eta**2 * outer(ym, ym)).
- num_pts_within_interval(ylow: ndarray, yhigh: ndarray, xlim=None)[source]#
Number of active points of
ythat fall within[ylow, yhigh).Useful for empirical-coverage diagnostics.
ylow/yhighare in comparison space and indexed over all points of the block.- Parameters:
ylow, yhigh (np.ndarray) – Interval bounds, same shape as
y.xlim (tuple, optional) –
(x_min, x_max)range to restrict the count.