# \[ANN\] NumericalDistributions.jl: user-defined distributions

**URL:** https://discourse.julialang.org/t/ann-numericaldistributions-jl-user-defined-distributions/128025
**Category:** Statistics
**Tags:** package, announcement
**Created:** [April 13, 2025, 1:12pm UTC](https://discourse.julialang.org/t/ann-numericaldistributions-jl-user-defined-distributions/128025 "2025-04-13T13:12:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![misha\_mikhasenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/misha_mikhasenko/32/5060_2.png) [@misha\_mikhasenko](https://discourse.julialang.org/u/misha_mikhasenko)
#### Post date: [April 13, 2025, 1:12pm UTC](https://discourse.julialang.org/t/ann-numericaldistributions-jl-user-defined-distributions/128025/1 "2025-04-13T13:12:41Z")

</div>

I’m happy to share [**NumericalDistributions.jl**](https://github.com/mmikhasenko/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

```julia-auto
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:

```julia-auto
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.

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [April 13, 2025, 3:54pm UTC](https://discourse.julialang.org/t/ann-numericaldistributions-jl-user-defined-distributions/128025/2 "2025-04-13T15:54:50Z")

</div>

This is amazing for #hep, for posterity / SEO, IIUC this is similar to RooExtendPdf [ROOT: RooExtendPdf Class Reference](https://root.cern.ch/doc/master/classRooExtendPdf.html)
