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: object

Experimental data: x, y, and the statistical error on y.

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; see systematic_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 raw y: the observation stores y = transform(y_raw) and propagates y_stat_err by the delta method, and the Constraint applies the same transform to the model prediction — so transform=rxmc.transforms.log compares 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, y in comparison space.

Type:

np.ndarray

y_raw, y_stat_err_raw

y and its statistical error as given (physical space).

Type:

np.ndarray

y_stat_err#

Statistical error on y in comparison space (raw, not squared).

Type:

np.ndarray

transform#

The comparison-space transform (identity by default).

Type:

Transform

mask#

Active points.

Type:

np.ndarray of bool

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:

Observation

y_sys_err_normalization#

Fractional normalisation uncertainty (dimensionless).

Type:

float or np.ndarray or None

y_sys_err_offset#

Absolute offset uncertainty (units of y).

Type:

float or np.ndarray or None

label#

Human-readable dataset identifier.

Type:

str or None

n_data_pts#

Number of data points.

Type:

int

__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() with mask = predicate(x) (points where it is True).

num_pts_within_interval(ylow, yhigh[, xlim])

Number of active points of y that 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

log_jacobian

sum(log |t'(y_raw)|) over the active points.

n_active

Number of active (unmasked) points.

property n_active: int#

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() with mask = 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 (None for a single-observation constraint).

Returns:

Term – diag(y_stat_err**2) on support (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'| * omega for an offset, |t'(ym_raw)| * eta * ym_raw for a normalisation).

Parameters:

support (np.ndarray, optional) – Indices of this observation’s block in the stacked vector. None binds 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 (see rxmc.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 y that fall within [ylow, yhigh).

Useful for empirical-coverage diagnostics. ylow/yhigh are 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.