Skip to content

Track differential-sweep coverage rollout across all distribution families #1280

Description

@synesenom

Purpose

Tracking issue. #1265 extends the differential-testing harness to distribution pdf/pmf/cdf but is deliberately scoped to a single pilot family (gamma/beta: Gamma, Beta, ChiSquare, F, StudentT, InverseGamma) because writing independent mpmath references for all distributions cannot fit in one reviewable PR.

src/dist/ contains 165 files. After #1265 lands, roughly 6 of them are swept. Without this issue that 97% gap lives only in a PR description and reads, from the outside, as "distributions are covered by the differential harness" — which would be false.

Coverage tiering — the rollout is NOT uniform

The expensive part of a sweep is not the config entry, it is writing an independent mpmath reference formula. That cost and its value vary enormously across the 165, so the rollout must be tiered rather than applied blanket. Counts below are estimates from the distribution list and should be confirmed against an actual scipy/mpmath mapping.

Tier A — sweep all (~70–80 distributions)

Everything with a direct scipy or mpmath counterpart: gamma, beta, f, chi2, the noncentral-* family, weibull, frechet, johnson-sb/johnson-su, tukey-lambda, von-mises, rice, nakagami, skellam, hypergeometric, binomial, poisson, and similar. The reference is scipy.stats.<name>.cdf or a one-line mpmath expression — genuinely independent, authored elsewhere, and the marginal cost per distribution is a config entry. Sweep every one of these.

Tier B — sweep, with real review effort budgeted (~30–40)

No direct counterpart and numerically delicate: doubly-noncentral-{beta,chi2,f,t}, noncentral-beta, noncentral-chi, hoyt, conway-maxwell-poisson, neyman-a, polya-aeppli, delaporte, generalized-hermite, tweedie, kolmogorov, davis, mielke. These depend on Bessel functions, Marcum Q, or infinite series — the areas with known accuracy gaps. References here must be hand-derived, and each one must be reviewed with the same rigor as production code. scripts/precision-refs-special.py already warns why: "a wrong x=0 guard in this file is exactly as dangerous as a bug in the code under test."

Tier C — do NOT hand-write mpmath references (~50–60)

rademacher, degenerate, discrete-uniform, u-quadratic, raised-cosine, hyperbolic-secant, arcsine, power-law, reciprocal, bates, irwin-hall, wrapped-cauchy, lindley, gamma-gompertz, and similar simple closed forms.

For these an mpmath "reference" written by the same author is the same formula, retyped. CLAUDE.md forbids this explicitly:

never write the same formula in both the production method and the test assertion — such tests pass even when the formula is wrong

Arbitrary precision buys nothing when the formula is f(x) = a·x^(a−1) and there is no cancellation to detect. It would add ~55 Python reference functions to maintain permanently and catch nothing.

Tier C gets reference-free property tests instead: CDF monotone in x, pdf ≥ 0, pdf integrates to 1 via independent quadrature, quantile(cdf(x)) ≈ x, survival(x) + cdf(x) = 1. These require no external reference and can cover all 165 at once.

Scope

This issue exists to hold the rollout, not to do it. It should:

  1. Confirm the Tier A/B/C assignment above against an actual scipy/mpmath availability check, and record the final assignment.
  2. Spawn one follow-up issue per Tier A/B family once Extend differential-testing harness to distribution pdf/pmf and cdf sweeps #1265 has landed and the parameter-domain spec format has proven itself. Filing them before that means rewriting all of them if the spec format changes.
  3. File the Tier C property-test work as a single separate issue — it is one generic harness, not per-distribution work.
  4. Track which families are swept, so Generate documented accuracy bounds table from differential-testing harness reports #1266's accuracy table can mark the rest accurately: "not yet measured" for Tier A/B pending, and "property-verified, bounds not measured" for Tier C.
  5. Close only when every distribution is swept, property-verified, or explicitly excluded with a recorded reason.

Ordering

Prioritise by usage × numerical delicacy, not by completeness. The noncentral family should be near the front on both counts — it depends on marcumQ and the Bessel functions, the two areas with known accuracy gaps (todo.md records the besselK crossover degradation; #1190 covers marcumQ boundary coverage). Simple location-scale families go last; they are the least likely to hide anything.

Do not chase 165/165

Driving toward a "all 165 swept" number reproduces the failure mode CLAUDE.md already rejects for line coverage — "test for meaningful behavior, not line counts." Sweeping Uniform to 1 ULP is worth approximately zero. A distribution correctly placed in Tier C is covered, not a gap, and the accuracy table should say so rather than implying a deficiency.

Not a substitute for work

This issue must not be used to mark distributions as "covered" because a tracking issue exists for them. Coverage means a sweep has actually run and produced measured bounds, or property tests actually pass. Until then #1266's table reports the honest state.

Related

#1264 (harness core), #1265 (pilot family), #1266 (accuracy table), #1269 (quantile sweep), #1190 (marcumQ coverage).

Complementary but distinct: cross-distribution limiting-case tests catch parameterization bugs (rate vs. scale, nu vs nu/2) that are self-consistent across a distribution's own formulas and therefore invisible to any per-distribution reference, no matter how many are written. That coverage is not a substitute for this rollout, and this rollout is not a substitute for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions