[ANN] NumericalDistributions.jl: user-defined distributions

I’m happy to share NumericalDistributions.jl, a package for working with numerically defined univariate continuous distributions in Julia. It wraps user-defined PDF functions, numerically normalizes them, and provides sampling and evaluation interfaces fully compatible with Distributions.jl.

Technical Highlights

  • Define custom distributions from arbitrary functions / callable objects.
  • Implements the Distributions.jl API: pdf, cdf, rand, etc.
  • Normalization via numerical integration (QuadGK.jl).
  • Random sampling using binned inverse CDF with linear interpolation.
  • Handles finite and infinite support ranges.

Example

using NumericalDistributions

const m, Γ = 0.77, 0.15
f(x) = 1 / abs2(m^2 - x^2 - 1im * m * Γ * sqrt(x-0.3)/ sqrt(m-0.3))
dist = NumericallyIntegrable(f, (0.3, 1.5))

pdf(dist, 0.77)
rand(dist, 1000)
cdf(dist, 1.0)

The goal is to simplify working with physics-inspired or empirical distributions when no closed-form expression for cdf is available. The package is unregistered for now and can be added directly via:

pkg> add https://github.com/mmikhasenko/NumericalDistributions.jl

A few questions:

  • This extends Distributions.jl with numerical PDFs. If I hadn’t known that Distributions.jl only supports analytic ones, I’d assume this interface should be part of it. Is there interest in including such functionality more broadly?
  • I’d like to share ownership and eventually move the package to JuliaStats. What’s the best way to initiate that?
  • Does it make sense to finalize this transition before registering the package?

Looking forward to your thoughts and feedback.

14 Likes

This is amazing for hep, for posterity / SEO, IIUC this is similar to RooExtendPdf ROOT: RooExtendPdf Class Reference