Skip to content

Audit and organize all univariate distribution implementations #420

Description

@lrnv

Motivation

Copulas.jl defines many user-facing and internal univariate distributions. Most already live under UnivariateDistribution, but several remain embedded in generator, copula, conditioning, or family implementation files. Gathering them consistently will make the architecture easier to navigate and, more importantly, make duplicated numerical interfaces visible for later rationalization.

Examples worth comparing once colocated include:

  • quantile inversion and root bracketing;
  • finite versus infinite support handling;
  • endpoint values and boundary atoms;
  • cdf/ccdf and pdf/logpdf consistency;
  • expectation and discrete/continuous dispatch;
  • sampling fallbacks and type preservation.

The recent WilliamsonBetaProduct endpoint regression illustrates why these implementations should be easy to audit together: nominal ContinuousUnivariateDistribution subtyping does not by itself guarantee the absence of boundary atoms.

Phase 1: inventory and mechanical organization

Audit every subtype of Distributions.UnivariateDistribution and every Distortion, whether exported or internal. Move misplaced self-contained types and their methods into the appropriate UnivariateDistribution subdirectory without changing behavior.

Known candidates include:

Frailties

  • PowerTiltedFrailty, currently in WilliamsonFromFrailty.jl

Radials

  • WilliamsonBetaProduct, currently in Generator.jl
  • LiouvilleConditionalRadial, currently in LiouvilleCopula.jl

Distortions and transformed distributions

  • LiouvilleDistortion, currently in LiouvilleCopula.jl
  • BernsteinDistortion, currently in BernsteinCopula.jl
  • NestedDistortion, currently in NestedArchimedeanCopula.jl
  • DistortionFromCop and DistortedDist, currently in Conditioning.jl

Also verify that already separated distributions are classified consistently and that no multiline subtype declaration escapes the inventory.

Update the include order in Copulas.jl while preserving dispatch, exports, documentation, and tests.

Coupled cases to assess rather than move blindly

  • The generic Williamson inverse type 𝒲₋₁ is a univariate radial distribution, but also forms the core inverse-transform interface and is tightly coupled to Generator.
  • The abstract Distortion interface belongs conceptually to conditioning even if concrete distortion distributions belong under UnivariateDistribution/Distortions.

Move these only when it improves ownership without forcing an unrelated redesign or awkward include cycle.

Phase 2: numerical-interface follow-ups

Once the types are inventoried and colocated, compare their implementations and open focused follow-up issues or PRs for genuinely reusable machinery. Likely candidates are a shared positive-distribution quantile/bracketing helper, explicit endpoint/atom traits or dispatch, and consistent support-aware cdf/ccdf handling.

Do not combine those behavioral changes with the mechanical move. Keeping both phases separate makes numerical regressions attributable and reviewable.

Acceptance criteria

  • Complete inventory of internal and exported univariate distribution types.
  • Misplaced concrete distributions grouped under Frailties, Radials, Distortions, or another justified category.
  • One clear ownership location per type and its core methods.
  • Generator and copula files primarily contain generator/copula representations and operations.
  • No public API or numerical behavior change in the organizational PR.
  • Follow-up opportunities recorded explicitly rather than implemented speculatively.

This is best done after PR #416 is merged to avoid churn and conflicts in the active Liouville numerical work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions