# Packages to compute model evidence in the Julia MCMC ecosystem?

**URL:** <https://discourse.julialang.org/t/packages-to-compute-model-evidence-in-the-julia-mcmc-ecosystem/68922>\
**Category:** Probabilistic Programming\
**Created:** [September 29, 2021, 12:05pm UTC](https://discourse.julialang.org/t/packages-to-compute-model-evidence-in-the-julia-mcmc-ecosystem/68922 "2021-09-29T12:05:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sami1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sami1/32/23555_2.png) [@sami1](https://discourse.julialang.org/u/sami1)\
**Post date:** [September 29, 2021, 12:05pm UTC](https://discourse.julialang.org/t/packages-to-compute-model-evidence-in-the-julia-mcmc-ecosystem/68922/1 "2021-09-29T12:05:38Z")

</div>

Hi,

I’m interested in estimating model evidence (marginal likelihood) for probabilistic models (using the DynamicPPL framework, but let me know if there is something on this matter with Soss.jl). The only available solution I’m aware of is [Nested Sampling](https://github.com/TuringLang/NestedSamplers.jl), but it’s currently not integrated with Turing.  
I know they are other solutions out there (e.g. [bridge sampling](https://github.com/quentingronau/bridgesampling) which is maybe more straigthforward when you already have samples drawn from the posterior distribution), but can’t find anything in the Turing ecosystem, and actually in Julia at all.

Is that something people would be interested to have, or is it to specific/model-sensitive to be delivered as a generic package ?

---

<div class="post-metadata">

**Author:** ![torfjelde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torfjelde/32/206542_2.png) [@torfjelde](https://discourse.julialang.org/u/torfjelde)\
**Post date:** [October 24, 2021, 9:03am UTC](https://discourse.julialang.org/t/packages-to-compute-model-evidence-in-the-julia-mcmc-ecosystem/68922/2 "2021-10-24T09:03:44Z")

</div>

There’s definitively an interest in this, as evident by the NestedSamplers.jl package:)

And the reason for not having proper integration with NestedSamplers.jl yet is just because we haven’t gotten around to it yet.

---

<div class="post-metadata">

**Author:** ![sami1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sami1/32/23555_2.png) [@sami1](https://discourse.julialang.org/u/sami1)\
**Post date:** [October 24, 2021, 4:34pm UTC](https://discourse.julialang.org/t/packages-to-compute-model-evidence-in-the-julia-mcmc-ecosystem/68922/3 "2021-10-24T16:34:39Z")

</div>

Hi !  
FWIW I rewrote a bridge sampling package from scratch (mainly from the R source code) : [https://github.com/sqwayer/BridgeSampling.jl](https://github.com/sqwayer/BridgeSampling.jl)

I also added a interface with Turing (via DynamicPPL.logjoint and Bijectors). It’s not registered yet since I’m having trouble with automatizing the documentation 😅

---

<div class="post-metadata">

**Author:** ![cscherrer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cscherrer/32/7631_2.png) [@cscherrer](https://discourse.julialang.org/u/cscherrer)\
**Post date:** [October 24, 2021, 4:37pm UTC](https://discourse.julialang.org/t/packages-to-compute-model-evidence-in-the-julia-mcmc-ecosystem/68922/4 "2021-10-24T16:37:57Z")

</div>

Nice! And thanks for not making it too Turing-specific, it’s great to be able to connect things like this to Soss.

How heavily did it depend on Distributions? Things work much better for us going through MeasureTheory, so ideally things are ecosystem-agnostic

---

<div class="post-metadata">

**Author:** ![sami1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sami1/32/23555_2.png) [@sami1](https://discourse.julialang.org/u/sami1)\
**Post date:** [October 24, 2021, 5:07pm UTC](https://discourse.julialang.org/t/packages-to-compute-model-evidence-in-the-julia-mcmc-ecosystem/68922/5 "2021-10-24T17:07:32Z")

</div>

The basic bridgesampling method requires nothing more than an AbstractMatrix of samples, a function that computes the logjoint (completely arbitrary as soon as it takes a sample input and returns a real scalar) and 2 vectors for lower and upper bounds.  
So yes pretty agnostic ^^ I’m planning to interface with soss as i did with DynamicPPL, but i’m more familiar with the latter so I started there.

---

<div class="post-metadata">

**Author:** ![cscherrer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cscherrer/32/7631_2.png) [@cscherrer](https://discourse.julialang.org/u/cscherrer)\
**Post date:** [October 24, 2021, 5:14pm UTC](https://discourse.julialang.org/t/packages-to-compute-model-evidence-in-the-julia-mcmc-ecosystem/68922/6 "2021-10-24T17:14:30Z")

</div>

Great! Let me know when you get to that, we can talk about a good approach
