Skip to content

Mean/median prediction-centering for every noise model (complete the location axis; neg_bin median) #419

@wshlavacek

Description

@wshlavacek

Summary

The location axis (ADR-0011 / ADR-0024) lets the model prediction be interpreted as a chosen summary of the noise distribution -- mean or median. PyBNF should offer both for every noise model / likelihood, with median the default. (Median aligns with PEtab v2's convention, but this is a PyBNF capability decision -- PyBNF deliberately supports more than the PEtab v2 subset.)

Current state

  • Gaussian (normal / lognormal): both supported. On a linear scale mean = median (coincide); on a log scale median is the default (offset 0) and mean adds the Gaussian moment correction mu = log(pred) - ln(base)*sigma**2/2 (noise/scale.py::mean_offset).
  • Per-observable selection via the location = mean|median field on the noise_model line (ADR-0024). A global noise_location default is planned.

Gaps to close

  1. neg_bin median. neg_bin is parameterized directly by its mean (the prediction is the mean), so location = mean is the current (only) interpretation; location = median raises "not implemented" today (objective._apply_location). The negative-binomial median has no closed form, so centering the prediction on it needs a numeric CDF inversion (place prediction at the median by solving nbinom.cdf(median; r, p) = 0.5). Implement so location = median works for neg_bin.

  2. log-laplace mean. Laplace's moment correction on a log scale differs from Gaussian's: the mean of a (natural-log) log-Laplace is e^m / (1 - b**2) (for |b| < 1), not e^(m + sigma**2/2). scale.mean_offset currently implements only the Gaussian correction (noted in ADR-0011 / ADR-0024), so location = mean on a log-scale Laplace would be numerically wrong today. Give the Laplace family its own moment correction (make the offset family-aware).

Default

Median across the board (the ADR-0024 default). neg_bin's existing default is mean; once median is implemented, decide whether to flip neg_bin's default to median (a behavior change) or keep mean as its default with median opt-in (backward-compat consideration).

Acceptance

Every (noise family x additive scale) supports both mean and median centering, correctly, validated against scipy oracles (nbinom, laplace, lognorm). Relates to ADR-0011, ADR-0021, ADR-0024.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions