How to Use a Distribution Estimated via Kernel Density Estimation (KDE) as a Prior in Turing.jl

hinata235
Tue, 07 Jan 2025 16:20:35 +0000
General Usage

Background and Goal

I have a set of discrete samples (e.g., from some existing dataset or posterior). I estimated a continuous distribution from these samples using a kernel density estimation (KDE) approach (such as via KernelDensity.jl). Now, I would like to use that KDE-based distribution as a prior for some parameters in a Bayesian model implemented in Turing.jl.

I have examined Turing’s official documentation for advanced usage, but it is not entirely clear to me how to incorporate a custom KDE-based distribution as a prior, especially regarding how Bijectors.jl might require certain transformations to integrate with Turing.jl’s sampling algorithms (like NUTS).

Question

• How can I take an empirical or discrete dataset, estimate a distribution via KDE, and then directly use that KDE-based distribution as a prior in Turing.jl?

• What concrete implementation steps (i.e., definitions of pdf, logpdf, rand, and possibly a custom bijector) are needed to ensure Turing.jl’s MCMC (particularly NUTS) can handle this custom KDE-based prior without errors?

Any practical code examples or best-practice guidance would be greatly appreciated.

5 posts - 3 participants